Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
SharedNFTLogic
Compiler Version
v0.8.6+commit.11564f7e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0 import {StringsUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import {Base64} from "base64-sol/base64.sol"; /// Shared NFT logic for rendering metadata associated with editions /// @dev Can safely be used for generic base64Encode and numberToString functions contract SharedNFTLogic { /// @param unencoded bytes to base64-encode function base64Encode(bytes memory unencoded) public pure returns (string memory) { return Base64.encode(unencoded); } /// Proxy to openzeppelin's toString function /// @param value number to return as a string function numberToString(uint256 value) public pure returns (string memory) { return StringsUpgradeable.toString(value); } /// Generate edition metadata from storage information as base64-json blob /// Combines the media data and metadata /// @param name Name of NFT in metadata /// @param description Description of NFT in metadata /// @param imageUrl URL of image to render for edition /// @param animationUrl URL of animation to render for edition /// @param tokenOfEdition Token ID for specific token /// @param editionSize Size of entire edition to show function createMetadataEdition( string memory name, string memory description, string memory imageUrl, string memory animationUrl, uint256 tokenOfEdition, uint256 editionSize ) external pure returns (string memory) { string memory _tokenMediaData = tokenMediaData( imageUrl, animationUrl, tokenOfEdition ); bytes memory json = createMetadataJSON( name, description, _tokenMediaData, tokenOfEdition, editionSize ); return encodeMetadataJSON(json); } /// Function to create the metadata json string for the nft edition /// @param name Name of NFT in metadata /// @param description Description of NFT in metadata /// @param mediaData Data for media to include in json object /// @param tokenOfEdition Token ID for specific token /// @param editionSize Size of entire edition to show function createMetadataJSON( string memory name, string memory description, string memory mediaData, uint256 tokenOfEdition, uint256 editionSize ) public pure returns (bytes memory) { bytes memory editionSizeText; if (editionSize > 0) { editionSizeText = abi.encodePacked( "/", numberToString(editionSize) ); } return abi.encodePacked( '{"name": "', name, " ", numberToString(tokenOfEdition), editionSizeText, '", "', 'description": "', description, '", "', mediaData, 'properties": {"number": ', numberToString(tokenOfEdition), ', "name": "', name, '"}}' ); } /// Encodes the argument json bytes into base64-data uri format /// @param json Raw json to base64 and turn into a data-uri function encodeMetadataJSON(bytes memory json) public pure returns (string memory) { return string( abi.encodePacked( "data:application/json;base64,", base64Encode(json) ) ); } /// Generates edition metadata from storage information as base64-json blob /// Combines the media data and metadata /// @param imageUrl URL of image to render for edition /// @param animationUrl URL of animation to render for edition function tokenMediaData( string memory imageUrl, string memory animationUrl, uint256 tokenOfEdition ) public pure returns (string memory) { bool hasImage = bytes(imageUrl).length > 0; bool hasAnimation = bytes(animationUrl).length > 0; if (hasImage && hasAnimation) { return string( abi.encodePacked( 'image": "', imageUrl, "?id=", numberToString(tokenOfEdition), '", "animation_url": "', animationUrl, "?id=", numberToString(tokenOfEdition), '", "' ) ); } if (hasImage) { return string( abi.encodePacked( 'image": "', imageUrl, "?id=", numberToString(tokenOfEdition), '", "' ) ); } if (hasAnimation) { return string( abi.encodePacked( 'animation_url": "', animationUrl, "?id=", numberToString(tokenOfEdition), '", "' ) ); } return ""; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT /// @title Base64 /// @author Brecht Devos - <[email protected]> /// @notice Provides a function for encoding some bytes in base64 library Base64 { string internal constant TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { dataPtr := add(dataPtr, 3) // read 3 bytes let input := mload(dataPtr) // write 4 characters mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr( 6, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and( input, 0x3F))))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } }
{ "evmVersion": "berlin", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 100 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"bytes","name":"unencoded","type":"bytes"}],"name":"base64Encode","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"imageUrl","type":"string"},{"internalType":"string","name":"animationUrl","type":"string"},{"internalType":"uint256","name":"tokenOfEdition","type":"uint256"},{"internalType":"uint256","name":"editionSize","type":"uint256"}],"name":"createMetadataEdition","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"mediaData","type":"string"},{"internalType":"uint256","name":"tokenOfEdition","type":"uint256"},{"internalType":"uint256","name":"editionSize","type":"uint256"}],"name":"createMetadataJSON","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"json","type":"bytes"}],"name":"encodeMetadataJSON","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"numberToString","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"imageUrl","type":"string"},{"internalType":"string","name":"animationUrl","type":"string"},{"internalType":"uint256","name":"tokenOfEdition","type":"uint256"}],"name":"tokenMediaData","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50610cd9806100206000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063170dc6601461006757806358464f3014610090578063d01fde8c146100a3578063d5fb1b19146100b6578063df30dba0146100c9578063eb111ab6146100dc575b600080fd5b61007a6100753660046107b5565b6100ef565b6040516100879190610b37565b60405180910390f35b61007a61009e3660046106b0565b610100565b61007a6100b13660046105aa565b61017c565b61007a6100c43660046105aa565b6101ad565b61007a6100d73660046105f2565b6101b8565b61007a6100ea366004610749565b6101f0565b60606100fa826102a9565b92915050565b606080821561013457610112836100ef565b6040516020016101229190610aa0565b60405160208183030381529060405290505b8661013e856100ef565b82888861014a896100ef565b8c6040516020016101619796959493929190610937565b60405160208183030381529060405291505095945050505050565b6060610187826101ad565b6040516020016101979190610a5b565b6040516020818303038152906040529050919050565b60606100fa826103ae565b606060006101c78686866101f0565b905060006101d88989848888610100565b90506101e38161017c565b9998505050505050505050565b825182516060911580159115159082906102075750805b1561024b5785610216856100ef565b86610220876100ef565b604051602001610233949392919061087c565b604051602081830303815290604052925050506102a2565b811561026c578561025b856100ef565b604051602001610233929190610816565b801561028d578461027c856100ef565b604051602001610233929190610ac9565b60405180602001604052806000815250925050505b9392505050565b6060816102cd5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156102f757806102e181610bdc565b91506102f09050600a83610b62565b91506102d1565b6000816001600160401b0381111561031157610311610c4d565b6040519080825280601f01601f19166020018201604052801561033b576020820181803683370190505b5090505b84156103a657610350600183610b95565b915061035d600a86610bf7565b610368906030610b4a565b60f81b81838151811061037d5761037d610c37565b60200101906001600160f81b031916908160001a90535061039f600a86610b62565b945061033f565b949350505050565b60608151600014156103ce57505060408051602081019091526000815290565b6000604051806060016040528060408152602001610c6460409139905060006003845160026103fd9190610b4a565b6104079190610b62565b610412906004610b76565b90506000610421826020610b4a565b6001600160401b0381111561043857610438610c4d565b6040519080825280601f01601f191660200182016040528015610462576020820181803683370190505b509050818152600183018586518101602084015b818310156104d05760039283018051603f601282901c811687015160f890811b8552600c83901c8216880151811b6001860152600683901c8216880151811b60028601529116860151901b93820193909352600401610476565b6003895106600181146104ea57600281146104fb57610507565b613d3d60f01b600119830152610507565b603d60f81b6000198301525b509398975050505050505050565b60006001600160401b038084111561052f5761052f610c4d565b604051601f8501601f19908116603f0116810190828211818310171561055757610557610c4d565b8160405280935085815286868601111561057057600080fd5b858560208301376000602087830101525050509392505050565b600082601f83011261059b57600080fd5b6102a283833560208501610515565b6000602082840312156105bc57600080fd5b81356001600160401b038111156105d257600080fd5b8201601f810184136105e357600080fd5b6103a684823560208401610515565b60008060008060008060c0878903121561060b57600080fd5b86356001600160401b038082111561062257600080fd5b61062e8a838b0161058a565b9750602089013591508082111561064457600080fd5b6106508a838b0161058a565b9650604089013591508082111561066657600080fd5b6106728a838b0161058a565b9550606089013591508082111561068857600080fd5b5061069589828a0161058a565b9350506080870135915060a087013590509295509295509295565b600080600080600060a086880312156106c857600080fd5b85356001600160401b03808211156106df57600080fd5b6106eb89838a0161058a565b9650602088013591508082111561070157600080fd5b61070d89838a0161058a565b9550604088013591508082111561072357600080fd5b506107308882890161058a565b9598949750949560608101359550608001359392505050565b60008060006060848603121561075e57600080fd5b83356001600160401b038082111561077557600080fd5b6107818783880161058a565b9450602086013591508082111561079757600080fd5b506107a48682870161058a565b925050604084013590509250925092565b6000602082840312156107c757600080fd5b5035919050565b600081518084526107e6816020860160208601610bac565b601f01601f19169290920160200192915050565b6000815161080c818560208601610bac565b9290920192915050565b6834b6b0b3b2911d101160b91b8152825160009061083b816009850160208801610bac565b633f69643d60e01b600991840191820152835161085f81600d840160208801610bac565b631116101160e11b600d9290910191820152601101949350505050565b6834b6b0b3b2911d101160b91b815284516000906108a1816009850160208a01610bac565b8083019050633f69643d60e01b80600983015286516108c781600d850160208b01610bac565b741116101130b734b6b0ba34b7b72fbab936111d101160591b600d939091019283015285516108fd816022850160208a01610bac565b60229201918201528351610918816026840160208801610bac565b631116101160e11b60269290910191820152602a019695505050505050565b693d913730b6b2911d101160b11b8152875160009061095d81600a850160208d01610bac565b600160fd1b600a91840191820152885161097e81600b840160208d01610bac565b885191019061099481600b840160208c01610bac565b631116101160e11b600b929091019182018190526e3232b9b1b934b83a34b7b7111d101160891b600f83015287516109d381601e850160208c01610bac565b601e920191820152610a4d610a3e610a38610a21610a1b6109f7602287018c6107fa565b770383937b832b93a34b2b9911d103d91373ab6b132b9111d160451b815260180190565b896107fa565b6a1610113730b6b2911d101160a91b8152600b0190565b866107fa565b62227d7d60e81b815260030190565b9a9950505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000815260008251610a9381601d850160208701610bac565b91909101601d0192915050565b602f60f81b815260008251610abc816001850160208701610bac565b9190910160010192915050565b7030b734b6b0ba34b7b72fbab936111d101160791b81528251600090610af6816011850160208801610bac565b633f69643d60e01b6011918401918201528351610b1a816015840160208801610bac565b631116101160e11b60159290910191820152601901949350505050565b6020815260006102a260208301846107ce565b60008219821115610b5d57610b5d610c0b565b500190565b600082610b7157610b71610c21565b500490565b6000816000190483118215151615610b9057610b90610c0b565b500290565b600082821015610ba757610ba7610c0b565b500390565b60005b83811015610bc7578181015183820152602001610baf565b83811115610bd6576000848401525b50505050565b6000600019821415610bf057610bf0610c0b565b5060010190565b600082610c0657610c06610c21565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa2646970667358221220d8fe5ad467b2d6b939a5d131d547e6d29c391bb1f056e629d065ac9f787a9a1e64736f6c63430008060033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100625760003560e01c8063170dc6601461006757806358464f3014610090578063d01fde8c146100a3578063d5fb1b19146100b6578063df30dba0146100c9578063eb111ab6146100dc575b600080fd5b61007a6100753660046107b5565b6100ef565b6040516100879190610b37565b60405180910390f35b61007a61009e3660046106b0565b610100565b61007a6100b13660046105aa565b61017c565b61007a6100c43660046105aa565b6101ad565b61007a6100d73660046105f2565b6101b8565b61007a6100ea366004610749565b6101f0565b60606100fa826102a9565b92915050565b606080821561013457610112836100ef565b6040516020016101229190610aa0565b60405160208183030381529060405290505b8661013e856100ef565b82888861014a896100ef565b8c6040516020016101619796959493929190610937565b60405160208183030381529060405291505095945050505050565b6060610187826101ad565b6040516020016101979190610a5b565b6040516020818303038152906040529050919050565b60606100fa826103ae565b606060006101c78686866101f0565b905060006101d88989848888610100565b90506101e38161017c565b9998505050505050505050565b825182516060911580159115159082906102075750805b1561024b5785610216856100ef565b86610220876100ef565b604051602001610233949392919061087c565b604051602081830303815290604052925050506102a2565b811561026c578561025b856100ef565b604051602001610233929190610816565b801561028d578461027c856100ef565b604051602001610233929190610ac9565b60405180602001604052806000815250925050505b9392505050565b6060816102cd5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156102f757806102e181610bdc565b91506102f09050600a83610b62565b91506102d1565b6000816001600160401b0381111561031157610311610c4d565b6040519080825280601f01601f19166020018201604052801561033b576020820181803683370190505b5090505b84156103a657610350600183610b95565b915061035d600a86610bf7565b610368906030610b4a565b60f81b81838151811061037d5761037d610c37565b60200101906001600160f81b031916908160001a90535061039f600a86610b62565b945061033f565b949350505050565b60608151600014156103ce57505060408051602081019091526000815290565b6000604051806060016040528060408152602001610c6460409139905060006003845160026103fd9190610b4a565b6104079190610b62565b610412906004610b76565b90506000610421826020610b4a565b6001600160401b0381111561043857610438610c4d565b6040519080825280601f01601f191660200182016040528015610462576020820181803683370190505b509050818152600183018586518101602084015b818310156104d05760039283018051603f601282901c811687015160f890811b8552600c83901c8216880151811b6001860152600683901c8216880151811b60028601529116860151901b93820193909352600401610476565b6003895106600181146104ea57600281146104fb57610507565b613d3d60f01b600119830152610507565b603d60f81b6000198301525b509398975050505050505050565b60006001600160401b038084111561052f5761052f610c4d565b604051601f8501601f19908116603f0116810190828211818310171561055757610557610c4d565b8160405280935085815286868601111561057057600080fd5b858560208301376000602087830101525050509392505050565b600082601f83011261059b57600080fd5b6102a283833560208501610515565b6000602082840312156105bc57600080fd5b81356001600160401b038111156105d257600080fd5b8201601f810184136105e357600080fd5b6103a684823560208401610515565b60008060008060008060c0878903121561060b57600080fd5b86356001600160401b038082111561062257600080fd5b61062e8a838b0161058a565b9750602089013591508082111561064457600080fd5b6106508a838b0161058a565b9650604089013591508082111561066657600080fd5b6106728a838b0161058a565b9550606089013591508082111561068857600080fd5b5061069589828a0161058a565b9350506080870135915060a087013590509295509295509295565b600080600080600060a086880312156106c857600080fd5b85356001600160401b03808211156106df57600080fd5b6106eb89838a0161058a565b9650602088013591508082111561070157600080fd5b61070d89838a0161058a565b9550604088013591508082111561072357600080fd5b506107308882890161058a565b9598949750949560608101359550608001359392505050565b60008060006060848603121561075e57600080fd5b83356001600160401b038082111561077557600080fd5b6107818783880161058a565b9450602086013591508082111561079757600080fd5b506107a48682870161058a565b925050604084013590509250925092565b6000602082840312156107c757600080fd5b5035919050565b600081518084526107e6816020860160208601610bac565b601f01601f19169290920160200192915050565b6000815161080c818560208601610bac565b9290920192915050565b6834b6b0b3b2911d101160b91b8152825160009061083b816009850160208801610bac565b633f69643d60e01b600991840191820152835161085f81600d840160208801610bac565b631116101160e11b600d9290910191820152601101949350505050565b6834b6b0b3b2911d101160b91b815284516000906108a1816009850160208a01610bac565b8083019050633f69643d60e01b80600983015286516108c781600d850160208b01610bac565b741116101130b734b6b0ba34b7b72fbab936111d101160591b600d939091019283015285516108fd816022850160208a01610bac565b60229201918201528351610918816026840160208801610bac565b631116101160e11b60269290910191820152602a019695505050505050565b693d913730b6b2911d101160b11b8152875160009061095d81600a850160208d01610bac565b600160fd1b600a91840191820152885161097e81600b840160208d01610bac565b885191019061099481600b840160208c01610bac565b631116101160e11b600b929091019182018190526e3232b9b1b934b83a34b7b7111d101160891b600f83015287516109d381601e850160208c01610bac565b601e920191820152610a4d610a3e610a38610a21610a1b6109f7602287018c6107fa565b770383937b832b93a34b2b9911d103d91373ab6b132b9111d160451b815260180190565b896107fa565b6a1610113730b6b2911d101160a91b8152600b0190565b866107fa565b62227d7d60e81b815260030190565b9a9950505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000815260008251610a9381601d850160208701610bac565b91909101601d0192915050565b602f60f81b815260008251610abc816001850160208701610bac565b9190910160010192915050565b7030b734b6b0ba34b7b72fbab936111d101160791b81528251600090610af6816011850160208801610bac565b633f69643d60e01b6011918401918201528351610b1a816015840160208801610bac565b631116101160e11b60159290910191820152601901949350505050565b6020815260006102a260208301846107ce565b60008219821115610b5d57610b5d610c0b565b500190565b600082610b7157610b71610c21565b500490565b6000816000190483118215151615610b9057610b90610c0b565b500290565b600082821015610ba757610ba7610c0b565b500390565b60005b83811015610bc7578181015183820152602001610baf565b83811115610bd6576000848401525b50505050565b6000600019821415610bf057610bf0610c0b565b5060010190565b600082610c0657610c06610c21565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa2646970667358221220d8fe5ad467b2d6b939a5d131d547e6d29c391bb1f056e629d065ac9f787a9a1e64736f6c63430008060033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.