Address Contract Partially Verified
Address
0xFC0946B334B3bA133D239207a4d01Da1B75CF51B
Balance
0 ETH
Nonce
1
Code Size
8666 bytes
Creator
0xdE9427e5...FB2f at tx 0xa056629b...1f7d6b
Indexed Transactions
0
Contract Bytecode
8666 bytes
0x6080604052600436106101e35760003560e01c80636352211e11610102578063a22cb46511610095578063dab3cca111610064578063dab3cca11461057a578063e985e9c51461058f578063f2fde38b146105d8578063fd4444c3146105f857600080fd5b8063a22cb46514610505578063b88d4fde14610525578063c87b56dd14610545578063caa0f92a1461056557600080fd5b80637362377b116100d15780637362377b1461049d5780638da5cb5b146104b257806395d89b41146104d0578063a0712d68146104e557600080fd5b80636352211e146104325780636817c76c1461045257806370a0823114610468578063715018a61461048857600080fd5b806324bbd0491161017a57806342842e0e1161014957806342842e0e146103b257806342966c68146103d2578063519a2044146103f257806355f804b31461041257600080fd5b806324bbd049146103125780632a55205a1461032c5780632eb4a7ab1461036b578063372f657c1461039f57600080fd5b8063095ea7b3116101b6578063095ea7b31461029b57806318160ddd146102bd5780631f85e3ca146102d257806323b872dd146102f257600080fd5b806301ffc9a7146101e8578063047fc9aa1461021d57806306fdde0314610241578063081812fc14610263575b600080fd5b3480156101f457600080fd5b50610208610203366004611b87565b610625565b60405190151581526020015b60405180910390f35b34801561022957600080fd5b50610233600d5481565b604051908152602001610214565b34801561024d57600080fd5b50610256610636565b6040516102149190611bfc565b34801561026f57600080fd5b5061028361027e366004611c0f565b6106c8565b6040516001600160a01b039091168152602001610214565b3480156102a757600080fd5b506102bb6102b6366004611c44565b610762565b005b3480156102c957600080fd5b50600d54610233565b3480156102de57600080fd5b506102bb6102ed366004611c7e565b610878565b3480156102fe57600080fd5b506102bb61030d366004611c99565b6108cf565b34801561031e57600080fd5b50600e546102089060ff1681565b34801561033857600080fd5b5061034c610347366004611cd5565b610900565b604080516001600160a01b039093168352602083019190915201610214565b34801561037757600080fd5b506102337f3d4dae5d92c06c21fd37932b8d5917646a024b04dedb9cbc496dc6edd14f082081565b6102bb6103ad366004611cf7565b61094e565b3480156103be57600080fd5b506102bb6103cd366004611c99565b610b97565b3480156103de57600080fd5b506102bb6103ed366004611c0f565b610bb2565b3480156103fe57600080fd5b506102bb61040d366004611d6c565b610c09565b34801561041e57600080fd5b506102bb61042d366004611e13565b610cbe565b34801561043e57600080fd5b5061028361044d366004611c0f565b610cff565b34801561045e57600080fd5b50610233600f5481565b34801561047457600080fd5b50610233610483366004611d6c565b610d76565b34801561049457600080fd5b506102bb610dfd565b3480156104a957600080fd5b506102bb610e33565b3480156104be57600080fd5b506008546001600160a01b0316610283565b3480156104dc57600080fd5b50610256610e89565b3480156104f157600080fd5b506102bb610500366004611c0f565b610e98565b34801561051157600080fd5b506102bb610520366004611e5c565b610f0a565b34801561053157600080fd5b506102bb610540366004611e8f565b610f15565b34801561055157600080fd5b50610256610560366004611c0f565b610f4d565b34801561057157600080fd5b50610233611028565b34801561058657600080fd5b50610233611038565b34801561059b57600080fd5b506102086105aa366004611f0b565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b3480156105e457600080fd5b506102bb6105f3366004611d6c565b611063565b34801561060457600080fd5b50610233610613366004611d6c565b600c6020526000908152604090205481565b600061063082611104565b92915050565b60606002805461064590611f35565b80601f016020809104026020016040519081016040528092919081815260200182805461067190611f35565b80156106be5780601f10610693576101008083540402835291602001916106be565b820191906000526020600020905b8154815290600101906020018083116106a157829003601f168201915b5050505050905090565b6000818152600460205260408120546001600160a01b03166107465760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600660205260409020546001600160a01b031690565b600061076d82610cff565b9050806001600160a01b0316836001600160a01b031614156107db5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161073d565b336001600160a01b03821614806107f757506107f781336105aa565b6108695760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161073d565b6108738383611144565b505050565b6008546001600160a01b031633146108a25760405162461bcd60e51b815260040161073d90611f70565b600e805460ff191682151590811790915560ff1680156108c25750600a54155b156108cc5742600a555b50565b6108d933826111b2565b6108f55760405162461bcd60e51b815260040161073d90611fa5565b6108738383836112a9565b6000805481906001600160a01b031661091857600080fd5b6000546001546001600160a01b03909116906103e89061093990869061200c565b6109439190612041565b915091509250929050565b600e5460ff166109905760405162461bcd60e51b815260206004820152600d60248201526c26b4b73a102737ba1027b832b760991b604482015260640161073d565b600d5460095411156109db5760405162461bcd60e51b8152602060048201526014602482015273151bdd185b0814dd5c1c1b1e4814995858da195960621b604482015260640161073d565b600f54341015610a205760405162461bcd60e51b815260206004820152601060248201526f2737ba1022b737bab3b41022ba3432b960811b604482015260640161073d565b610a28611038565b336000908152600c602052604090205410610a7a5760405162461bcd60e51b815260206004820152601260248201527114995858da195908135a5b9d08131a5b5a5d60721b604482015260640161073d565b6040516bffffffffffffffffffffffff193360601b166020820152600090603401604051602081830303815290604052805190602001209050610b138383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152507f3d4dae5d92c06c21fd37932b8d5917646a024b04dedb9cbc496dc6edd14f082092508591506114499050565b610b525760405162461bcd60e51b815260206004820152601060248201526f139bdd08125b8815da1a5d195b1a5cdd60821b604482015260640161073d565b610b6433610b5f60095490565b61145f565b610b72600980546001019055565b336000908152600c60205260408120805491610b8d83612055565b9190505550505050565b61087383838360405180602001604052806000815250610f15565b610bbc33826111b2565b610c005760405162461bcd60e51b81526020600482015260156024820152742737ba1020b8383937bb32b21037b91027bbb732b960591b604482015260640161073d565b6108cc81611479565b6008546001600160a01b03163314610c335760405162461bcd60e51b815260040161073d90611f70565b6001600160a01b038116610c9c5760405162461bcd60e51b815260206004820152602a60248201527f526f79616c747920616464726573732063616e6e6f7420626520746865207a65604482015269726f206164647265737360b01b606482015260840161073d565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6008546001600160a01b03163314610ce85760405162461bcd60e51b815260040161073d90611f70565b8051610cfb90600b906020840190611ad8565b5050565b6000818152600460205260408120546001600160a01b0316806106305760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161073d565b60006001600160a01b038216610de15760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161073d565b506001600160a01b031660009081526005602052604090205490565b6008546001600160a01b03163314610e275760405162461bcd60e51b815260040161073d90611f70565b610e316000611514565b565b6008546001600160a01b03163314610e5d5760405162461bcd60e51b815260040161073d90611f70565b60405133904780156108fc02916000818181858888f193505050501580156108cc573d6000803e3d6000fd5b60606003805461064590611f35565b6008546001600160a01b03163314610ec25760405162461bcd60e51b815260040161073d90611f70565b60005b81811015610cfb57600d546009541115610edd575050565b610eea33610b5f60095490565b610ef8600980546001019055565b80610f0281612055565b915050610ec5565b610cfb338383611566565b610f1f33836111b2565b610f3b5760405162461bcd60e51b815260040161073d90611fa5565b610f4784848484611635565b50505050565b6000818152600460205260409020546060906001600160a01b0316610fcc5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161073d565b6000610fd6611668565b90506000815111610ff65760405180602001604052806000815250611021565b8061100084611677565b604051602001611011929190612070565b6040516020818303038152906040525b9392505050565b600061103360095490565b905090565b60006202a300600a544261104c919061209f565b1061105857601961105b565b60015b60ff16905090565b6008546001600160a01b0316331461108d5760405162461bcd60e51b815260040161073d90611f70565b6001600160a01b0381166110f25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161073d565b6108cc81611514565b80546001019055565b60006001600160e01b031982166380ac58cd60e01b148061113557506001600160e01b03198216635b5e139f60e01b145b80610630575061063082611775565b600081815260066020526040902080546001600160a01b0319166001600160a01b038416908117909155819061117982610cff565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600460205260408120546001600160a01b031661122b5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161073d565b600061123683610cff565b9050806001600160a01b0316846001600160a01b031614806112715750836001600160a01b0316611266846106c8565b6001600160a01b0316145b806112a157506001600160a01b0380821660009081526007602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166112bc82610cff565b6001600160a01b0316146113245760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161073d565b6001600160a01b0382166113865760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161073d565b611391600082611144565b6001600160a01b03831660009081526005602052604081208054600192906113ba90849061209f565b90915550506001600160a01b03821660009081526005602052604081208054600192906113e89084906120b6565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60008261145685846117aa565b14949350505050565b610cfb828260405180602001604052806000815250611856565b600061148482610cff565b9050611491600083611144565b6001600160a01b03811660009081526005602052604081208054600192906114ba90849061209f565b909155505060008281526004602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b031614156115c85760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161073d565b6001600160a01b03838116600081815260076020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6116408484846112a9565b61164c84848484611889565b610f475760405162461bcd60e51b815260040161073d906120ce565b6060600b805461064590611f35565b60608161169b5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156116c557806116af81612055565b91506116be9050600a83612041565b915061169f565b60008167ffffffffffffffff8111156116e0576116e0611d87565b6040519080825280601f01601f19166020018201604052801561170a576020820181803683370190505b5090505b84156112a15761171f60018361209f565b915061172c600a86612120565b6117379060306120b6565b60f81b81838151811061174c5761174c612134565b60200101906001600160f81b031916908160001a90535061176e600a86612041565b945061170e565b60006001600160e01b0319821663152a902d60e11b148061063057506301ffc9a760e01b6001600160e01b0319831614610630565b600081815b845181101561184e5760008582815181106117cc576117cc612134565b6020026020010151905080831161180e57604080516020810185905290810182905260600160405160208183030381529060405280519060200120925061183b565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b508061184681612055565b9150506117af565b509392505050565b6118608383611996565b61186d6000848484611889565b6108735760405162461bcd60e51b815260040161073d906120ce565b60006001600160a01b0384163b1561198b57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906118cd90339089908890889060040161214a565b602060405180830381600087803b1580156118e757600080fd5b505af1925050508015611917575060408051601f3d908101601f1916820190925261191491810190612187565b60015b611971573d808015611945576040519150601f19603f3d011682016040523d82523d6000602084013e61194a565b606091505b5080516119695760405162461bcd60e51b815260040161073d906120ce565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506112a1565b506001949350505050565b6001600160a01b0382166119ec5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161073d565b6000818152600460205260409020546001600160a01b031615611a515760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161073d565b6001600160a01b0382166000908152600560205260408120805460019290611a7a9084906120b6565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611ae490611f35565b90600052602060002090601f016020900481019282611b065760008555611b4c565b82601f10611b1f57805160ff1916838001178555611b4c565b82800160010185558215611b4c579182015b82811115611b4c578251825591602001919060010190611b31565b50611b58929150611b5c565b5090565b5b80821115611b585760008155600101611b5d565b6001600160e01b0319811681146108cc57600080fd5b600060208284031215611b9957600080fd5b813561102181611b71565b60005b83811015611bbf578181015183820152602001611ba7565b83811115610f475750506000910152565b60008151808452611be8816020860160208601611ba4565b601f01601f19169290920160200192915050565b6020815260006110216020830184611bd0565b600060208284031215611c2157600080fd5b5035919050565b80356001600160a01b0381168114611c3f57600080fd5b919050565b60008060408385031215611c5757600080fd5b611c6083611c28565b946020939093013593505050565b80358015158114611c3f57600080fd5b600060208284031215611c9057600080fd5b61102182611c6e565b600080600060608486031215611cae57600080fd5b611cb784611c28565b9250611cc560208501611c28565b9150604084013590509250925092565b60008060408385031215611ce857600080fd5b50508035926020909101359150565b60008060208385031215611d0a57600080fd5b823567ffffffffffffffff80821115611d2257600080fd5b818501915085601f830112611d3657600080fd5b813581811115611d4557600080fd5b8660208260051b8501011115611d5a57600080fd5b60209290920196919550909350505050565b600060208284031215611d7e57600080fd5b61102182611c28565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115611db857611db8611d87565b604051601f8501601f19908116603f01168101908282118183101715611de057611de0611d87565b81604052809350858152868686011115611df957600080fd5b858560208301376000602087830101525050509392505050565b600060208284031215611e2557600080fd5b813567ffffffffffffffff811115611e3c57600080fd5b8201601f81018413611e4d57600080fd5b6112a184823560208401611d9d565b60008060408385031215611e6f57600080fd5b611e7883611c28565b9150611e8660208401611c6e565b90509250929050565b60008060008060808587031215611ea557600080fd5b611eae85611c28565b9350611ebc60208601611c28565b925060408501359150606085013567ffffffffffffffff811115611edf57600080fd5b8501601f81018713611ef057600080fd5b611eff87823560208401611d9d565b91505092959194509250565b60008060408385031215611f1e57600080fd5b611f2783611c28565b9150611e8660208401611c28565b600181811c90821680611f4957607f821691505b60208210811415611f6a57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561202657612026611ff6565b500290565b634e487b7160e01b600052601260045260246000fd5b6000826120505761205061202b565b500490565b600060001982141561206957612069611ff6565b5060010190565b60008351612082818460208801611ba4565b835190830190612096818360208801611ba4565b01949350505050565b6000828210156120b1576120b1611ff6565b500390565b600082198211156120c9576120c9611ff6565b500190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008261212f5761212f61202b565b500690565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061217d90830184611bd0565b9695505050505050565b60006020828403121561219957600080fd5b815161102181611b7156fea264697066735822122086648b0bbc5dac1b34460944427e634f231000a2f7d5b9d46636f6760bb2255264736f6c63430008090033
Verified Source Code Partial Match
Compiler: v0.8.9+commit.e5eed63a
EVM: istanbul
Optimization: Yes (200 runs)
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
ERC721.sol 424 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "IERC721.sol";
import "IERC721Receiver.sol";
import "IERC721Metadata.sol";
import "Address.sol";
import "Context.sol";
import "Strings.sol";
import "ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
EIP2981.sol 61 lines
// SPDX-License-Identifier: MIT
/**
* @title EIP 2981 base contract
* @author Transient Labs, Copyright (C) 2021
* @notice contract implementation of EIP 2981
*/
/*
####### #
# ##### ## # # #### # ###### # # ##### # ## ##### ####
# # # # # ## # # # # ## # # # # # # # #
# # # # # # # # #### # ##### # # # # # # # ##### ####
# ##### ###### # # # # # # # # # # # ###### # # #
# # # # # # ## # # # # # ## # # # # # # # #
# # # # # # # #### # ###### # # # ####### # # ##### ####
0101010011100101100000110111011100101101000110010011011101110100 01001100110000011000101110011
*/
pragma solidity ^0.8.0;
import "ERC165.sol";
import "IEIP2981.sol";
contract EIP2981 is IEIP2981, ERC165 {
address internal royaltyAddr;
uint256 private royaltyPerc; // percentage multiplied by 1000
/**
* @notice constructor
* @dev need inheriting contracts to accept the parameters in their constructor
* @param addr is the royalty payout address
* @param perc is the royalty percentage, multiplied by 1000. Ex: 7.5% => 75
*/
constructor(address addr, uint256 perc) {
royaltyAddr = addr;
royaltyPerc = perc;
}
/**
* @notice override ERC 165 implementation of this function
* @dev if using this contract with another contract that supports ERC 165, will have to override in the inheriting contract
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165) returns (bool) {
return interfaceId == type(IEIP2981).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @notice EIP 2981 royalty support
* @dev royalty payout made to the owner of the contract and the owner can't be the 0 address
* @dev royalty amount determined when contract is deployed, and then divided by 1000 in this function
* @dev royalty amount not dependent on _tokenId
*/
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view returns (address receiver, uint256 royaltyAmount) {
require(royaltyAddr != address(0));
return (royaltyAddr, royaltyPerc * _salePrice / 1000);
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
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);
}
}
Counters.sol 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
IEIP2981.sol 21 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
///
/// @dev Interface for the NFT Royalty Standard
///
interface IEIP2981 {
/// ERC165 bytes to add to interface array - set in parent contract
/// implementing this standard
///
/// bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a
/// @notice Called with the sale price to determine how much royalty
// is owed and to whom.
/// @param _tokenId - the NFT asset queried for royalty information
/// @param _salePrice - the sale price of the NFT asset specified by _tokenId
/// @return receiver - address of who should be sent the royalty payment
/// @return royaltyAmount - the royalty payment amount for _salePrice
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view returns (address receiver,uint256 royaltyAmount);
}
MerkleProof.sol 52 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Trees proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
}
LITProjectTwo.sol 182 lines
// SPDX-License-Identifier: MIT
/**
* @title Lit Project Two
* @author Transient Labs, Copyright (C) 2021
* @notice ERC721 smart contract with single owner, Merkle whitelist, and royalty info per EIP 2981.
*/
/*
####### #
# ##### ## # # #### # ###### # # ##### # ## ##### ####
# # # # # ## # # # # ## # # # # # # # #
# # # # # # # # #### # ##### # # # # # # # ##### ####
# ##### ###### # # # # # # # # # # # ###### # # #
# # # # # # ## # # # # # ## # # # # # # # #
# # # # # # # #### # ###### # # # ####### # # ##### ####
0101010011100101100000110111011100101101000110010011011101110100 01001100110000011000101110011
*/
pragma solidity ^0.8.0;
import "ERC721.sol";
import "Ownable.sol";
import "Counters.sol";
import "MerkleProof.sol";
import "EIP2981.sol";
contract LITProjectTwo is EIP2981, ERC721, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _nextTokenId;
uint256 private _mintStartTimestamp;
string private _baseTokenURI;
mapping(address => uint256) public mintNum;
uint256 public supply = 4620;
bool public mintOpen;
uint256 public mintPrice = 0.068 ether;
bytes32 public immutable merkleRoot;
/**
* @notice constructor for this contract
* @dev increments _nextTokenId so the first mint isn't more expensive
* @param root is the merkle root
* @param addr is the royalty payout address
* @param perc is the royalty payout percentage
*/
constructor(bytes32 root, address addr, uint256 perc) EIP2981(addr, perc) ERC721("LIT Project Two", "LP2") Ownable() {
merkleRoot = root;
_nextTokenId.increment();
}
/**
* @notice overrides EIP721 and EIP2981 supportsInterface function
* @param interfaceId is supplied from anyone/contract calling this function, as defined in ERC 165
* @return a boolean saying if this contract supports the interface or not
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, EIP2981) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice function to view total supply
* @return uint256 with supply
*/
function totalSupply() public view returns(uint256) {
return supply;
}
/**
* @notice function to get next mint token id
* @return uint256 with number of next token id
*/
function getNextTokenId() public view returns(uint256) {
return _nextTokenId.current();
}
/**
* @notice sets the baseURI for the ERC721 tokens
* @dev requires owner
* @param uri is the base URI set for each token
*/
function setBaseURI(string memory uri) public onlyOwner {
_baseTokenURI = uri;
}
/**
* @notice override standard ERC721 base URI
* @dev doesn't require access control since it's internal
* @return string representing base URI
*/
function _baseURI() internal view override returns (string memory) {
return _baseTokenURI;
}
/**
* @notice function to set the mint status
* @dev sets the timestamp for mint, if it hasn't been set yet
* @param status is the true/false flag for the mint status
*/
function setMintStatus(bool status) public onlyOwner {
mintOpen = status;
if (mintOpen && _mintStartTimestamp == 0) {
_mintStartTimestamp = block.timestamp;
}
}
/**
* @notice whitelist mint function
* @dev requires mint to be open
* @dev requires merkle proof to be valid
* @dev requires mint price to be met
* @dev requires that the message sender hasn't already minted more than allowed at the time of the transaction
* @param merkleProof is the proof provided by the minting site
*/
function whitelistMint(bytes32[] calldata merkleProof) public payable {
require(mintOpen, "Mint Not Open");
require(_nextTokenId.current() <= supply, "Total Supply Reached");
require(msg.value >= mintPrice, "Not Enough Ether");
require(mintNum[msg.sender] < getMintAllowance(), "Reached Mint Limit");
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
require(MerkleProof.verify(merkleProof, merkleRoot, leaf), "Not In Whitelist");
_safeMint(msg.sender, _nextTokenId.current());
_nextTokenId.increment();
mintNum[msg.sender]++;
}
/**
* @notice function to calculate number of allowed mints per wallet
* @dev 1 mint in the first 48hrs, then 25 total allowed after that
* @return uint256 value for number of mints allowed per wallet
*/
function getMintAllowance() public view returns(uint256) {
return block.timestamp - _mintStartTimestamp < 48*3600 ? 1 : 25;
}
/**
* @notice owner mint function
* @dev mints to the contract owner wallet
* @dev requires ownership of the contract
* @dev minted pieces can be used for disputes or donated to the DAO
* @param num is the number of mints to perform
*/
function mint(uint256 num) public onlyOwner {
for (uint256 i = 0; i < num; i++) {
if (_nextTokenId.current() > supply) {
break;
}
_safeMint(msg.sender, _nextTokenId.current());
_nextTokenId.increment();
}
}
/**
* @notice function to withdraw minting ether from the contract
* @dev requires owner to call
*/
function withdrawEther() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* @notice function to update the royalty payout address
* @dev ownable
* @param addr is the new payout address
*/
function updateRoyaltyAddress(address addr) public onlyOwner {
require(addr != address(0), "Royalty address cannot be the zero address");
royaltyAddr = addr;
}
/**
* @notice burn function for owners to use at their discretion
* @dev requires the msg sender to be the owner or an approved delegate
* @param tokenId is the token ID to burn
*/
function burn(uint256 tokenId) public {
require(_isApprovedOrOwner(msg.sender, tokenId), "Not Approved or Owner");
_burn(tokenId);
}
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
Read Contract
balanceOf 0x70a08231 → uint256
getApproved 0x081812fc → address
getMintAllowance 0xdab3cca1 → uint256
getNextTokenId 0xcaa0f92a → uint256
isApprovedForAll 0xe985e9c5 → bool
merkleRoot 0x2eb4a7ab → bytes32
mintNum 0xfd4444c3 → uint256
mintOpen 0x24bbd049 → bool
mintPrice 0x6817c76c → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
royaltyInfo 0x2a55205a → address, uint256
supply 0x047fc9aa → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 14 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
burn 0x42966c68
uint256 tokenId
mint 0xa0712d68
uint256 num
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string uri
setMintStatus 0x1f85e3ca
bool status
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
updateRoyaltyAddress 0x519a2044
address addr
whitelistMint 0x372f657c
bytes32[] merkleProof
withdrawEther 0x7362377b
No parameters
Recent Transactions
No transactions found for this address