Address Contract Partially Verified
Address
0xd5af737470e963F40f9E681b2e9D12ACDBbB5492
Balance
0 ETH
Nonce
1
Code Size
9502 bytes
Creator
0x124b0B99...96Ef at tx 0x96f4589f...a7e222
Indexed Transactions
0
Contract Bytecode
9502 bytes
0x60806040526004361061020f5760003560e01c80636352211e11610118578063a22cb465116100a0578063c87b56dd1161006f578063c87b56dd146105a4578063d5abeb01146105c4578063e0a80853146105d9578063e985e9c5146105f9578063f2fde38b146106195761020f565b8063a22cb4651461053a578063b88d4fde1461055a578063ba7d2c761461057a578063c66828621461058f5761020f565b80637ec4a659116100e75780637ec4a659146104bd5780638da5cb5b146104dd57806395d89b41146104f2578063962e0f5a14610507578063a0712d68146105275761020f565b80636352211e146104485780636b9d3e411461046857806370a0823114610488578063715018a6146104a85761020f565b806318cae2691161019b578063438b63001161016a578063438b6300146103bc57806344a0d68a146103e957806351830227146104095780635c975abb1461041e57806362b99ad4146104335761020f565b806318cae2691461034757806323b872dd146103675780633ccfd60b1461038757806342842e0e1461039c5761020f565b8063081c8c44116101e2578063081c8c44146102bb578063095ea7b3146102d057806313faede6146102f057806316c38b3c1461031257806318160ddd146103325761020f565b80630188541d1461021457806301ffc9a71461023657806306fdde031461026c578063081812fc1461028e575b600080fd5b34801561022057600080fd5b5061023461022f366004611bd9565b610639565b005b34801561024257600080fd5b50610256610251366004611ba1565b610698565b6040516102639190611e36565b60405180910390f35b34801561027857600080fd5b506102816106e0565b6040516102639190611e41565b34801561029a57600080fd5b506102ae6102a9366004611c1f565b610772565b6040516102639190611da1565b3480156102c757600080fd5b506102816107b5565b3480156102dc57600080fd5b506102346102eb366004611b5e565b610843565b3480156102fc57600080fd5b506103056108db565b6040516102639190612383565b34801561031e57600080fd5b5061023461032d366004611b87565b6108e1565b34801561033e57600080fd5b50610305610933565b34801561035357600080fd5b50610305610362366004611a35565b610944565b34801561037357600080fd5b50610234610382366004611a81565b610956565b34801561039357600080fd5b5061023461098e565b3480156103a857600080fd5b506102346103b7366004611a81565b610a40565b3480156103c857600080fd5b506103dc6103d7366004611a35565b610a5b565b6040516102639190611df2565b3480156103f557600080fd5b50610234610404366004611c1f565b610b58565b34801561041557600080fd5b50610256610b9c565b34801561042a57600080fd5b50610256610baa565b34801561043f57600080fd5b50610281610bb3565b34801561045457600080fd5b506102ae610463366004611c1f565b610bc0565b34801561047457600080fd5b50610234610483366004611bd9565b610bf5565b34801561049457600080fd5b506103056104a3366004611a35565b610c47565b3480156104b457600080fd5b50610234610c8b565b3480156104c957600080fd5b506102346104d8366004611bd9565b610cd6565b3480156104e957600080fd5b506102ae610d28565b3480156104fe57600080fd5b50610281610d37565b34801561051357600080fd5b50610234610522366004611c37565b610d46565b610234610535366004611c1f565b610e1e565b34801561054657600080fd5b50610234610555366004611b35565b610eaf565b34801561056657600080fd5b50610234610575366004611abc565b610ec1565b34801561058657600080fd5b50610305610f00565b34801561059b57600080fd5b50610281610f06565b3480156105b057600080fd5b506102816105bf366004611c1f565b610f13565b3480156105d057600080fd5b5061030561103a565b3480156105e557600080fd5b506102346105f4366004611b87565b611040565b34801561060557600080fd5b50610256610614366004611a4f565b611099565b34801561062557600080fd5b50610234610634366004611a35565b6110c7565b610641611135565b6001600160a01b0316610652610d28565b6001600160a01b0316146106815760405162461bcd60e51b815260040161067890612192565b60405180910390fd5b805161069490600a906020840190611905565b5050565b60006001600160e01b031982166380ac58cd60e01b14806106c957506001600160e01b03198216635b5e139f60e01b145b806106d857506106d882611139565b90505b919050565b6060600080546106ef90612426565b80601f016020809104026020016040519081016040528092919081815260200182805461071b90612426565b80156107685780601f1061073d57610100808354040283529160200191610768565b820191906000526020600020905b81548152906001019060200180831161074b57829003601f168201915b5050505050905090565b600061077d82611152565b6107995760405162461bcd60e51b815260040161067890612146565b506000908152600460205260409020546001600160a01b031690565b600a80546107c290612426565b80601f01602080910402602001604051908101604052809291908181526020018280546107ee90612426565b801561083b5780601f106108105761010080835404028352916020019161083b565b820191906000526020600020905b81548152906001019060200180831161081e57829003601f168201915b505050505081565b600061084e82610bc0565b9050806001600160a01b0316836001600160a01b031614156108825760405162461bcd60e51b815260040161067890612296565b806001600160a01b0316610894611135565b6001600160a01b031614806108b057506108b081610614611135565b6108cc5760405162461bcd60e51b815260040161067890612021565b6108d6838361116f565b505050565b600b5481565b6108e9611135565b6001600160a01b03166108fa610d28565b6001600160a01b0316146109205760405162461bcd60e51b815260040161067890612192565b600e805460ff1916911515919091179055565b600061093f60076111dd565b905090565b600f6020526000908152604090205481565b610967610961611135565b826111e1565b6109835760405162461bcd60e51b815260040161067890612305565b6108d6838383611266565b610996611135565b6001600160a01b03166109a7610d28565b6001600160a01b0316146109cd5760405162461bcd60e51b815260040161067890612192565b60006109d7610d28565b6001600160a01b0316476040516109ed90611d9e565b60006040518083038185875af1925050503d8060008114610a2a576040519150601f19603f3d011682016040523d82523d6000602084013e610a2f565b606091505b5050905080610a3d57600080fd5b50565b6108d683838360405180602001604052806000815250610ec1565b60606000610a6883610c47565b905060008167ffffffffffffffff811115610a9357634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610abc578160200160208202803683370190505b509050600160005b8381108015610ad55750600c548211155b15610b4e576000610ae583610bc0565b9050866001600160a01b0316816001600160a01b03161415610b3b5782848381518110610b2257634e487b7160e01b600052603260045260246000fd5b602090810291909101015281610b3781612461565b9250505b82610b4581612461565b93505050610ac4565b5090949350505050565b610b60611135565b6001600160a01b0316610b71610d28565b6001600160a01b031614610b975760405162461bcd60e51b815260040161067890612192565b600b55565b600e54610100900460ff1681565b600e5460ff1681565b600880546107c290612426565b6000818152600260205260408120546001600160a01b0316806106d85760405162461bcd60e51b8152600401610678906120c8565b610bfd611135565b6001600160a01b0316610c0e610d28565b6001600160a01b031614610c345760405162461bcd60e51b815260040161067890612192565b8051610694906009906020840190611905565b60006001600160a01b038216610c6f5760405162461bcd60e51b81526004016106789061207e565b506001600160a01b031660009081526003602052604090205490565b610c93611135565b6001600160a01b0316610ca4610d28565b6001600160a01b031614610cca5760405162461bcd60e51b815260040161067890612192565b610cd46000611393565b565b610cde611135565b6001600160a01b0316610cef610d28565b6001600160a01b031614610d155760405162461bcd60e51b815260040161067890612192565b8051610694906008906020840190611905565b6006546001600160a01b031690565b6060600180546106ef90612426565b82600c5481610d5560076111dd565b610d5f9190612398565b1115610d7d5760405162461bcd60e51b8152600401610678906122d7565b610d85611135565b6001600160a01b0316610d96610d28565b6001600160a01b031614610dbc5760405162461bcd60e51b815260040161067890612192565b60005b82811015610e1757610e05848483818110610dea57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610dff9190611a35565b866113e5565b80610e0f81612461565b915050610dbf565b5050505050565b80600c5481610e2d60076111dd565b610e379190612398565b1115610e555760405162461bcd60e51b8152600401610678906122d7565b600e5460ff1615610e785760405162461bcd60e51b8152600401610678906121c7565b81600b54610e8691906123c4565b341015610ea55760405162461bcd60e51b815260040161067890612356565b610694338361141f565b610694610eba611135565b83836114af565b610ed2610ecc611135565b836111e1565b610eee5760405162461bcd60e51b815260040161067890612305565b610efa84848484611552565b50505050565b600d5481565b600980546107c290612426565b6060610f1e82611152565b610f3a5760405162461bcd60e51b815260040161067890612247565b600e54610100900460ff16610fdb57600a8054610f5690612426565b80601f0160208091040260200160405190810160405280929190818152602001828054610f8290612426565b8015610fcf5780601f10610fa457610100808354040283529160200191610fcf565b820191906000526020600020905b815481529060010190602001808311610fb257829003601f168201915b505050505090506106db565b6000610fe5611585565b905060008151116110055760405180602001604052806000815250611033565b8061100f84611594565b600960405160200161102393929190611cdc565b6040516020818303038152906040525b9392505050565b600c5481565b611048611135565b6001600160a01b0316611059610d28565b6001600160a01b03161461107f5760405162461bcd60e51b815260040161067890612192565b600e80549115156101000261ff0019909216919091179055565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6110cf611135565b6001600160a01b03166110e0610d28565b6001600160a01b0316146111065760405162461bcd60e51b815260040161067890612192565b6001600160a01b03811661112c5760405162461bcd60e51b815260040161067890611ea6565b610a3d81611393565b3390565b6001600160e01b031981166301ffc9a760e01b14919050565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906111a482610bc0565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b5490565b60006111ec82611152565b6112085760405162461bcd60e51b815260040161067890611fd5565b600061121383610bc0565b9050806001600160a01b0316846001600160a01b0316148061124e5750836001600160a01b031661124384610772565b6001600160a01b0316145b8061125e575061125e8185611099565b949350505050565b826001600160a01b031661127982610bc0565b6001600160a01b03161461129f5760405162461bcd60e51b8152600401610678906121fe565b6001600160a01b0382166112c55760405162461bcd60e51b815260040161067890611f5a565b6112d08383836108d6565b6112db60008261116f565b6001600160a01b03831660009081526003602052604081208054600192906113049084906123e3565b90915550506001600160a01b0382166000908152600360205260408120805460019290611332908490612398565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60005b818110156108d6576113fa60076116af565b61140d8361140860076111dd565b6116b8565b8061141781612461565b9150506113e8565b336000908152600f6020526040902054600d5461143c8383612398565b111561145a5760405162461bcd60e51b815260040161067890611f23565b60005b82811015610efa5761146f60076116af565b336000908152600f6020526040812080549161148a83612461565b919050555061149d8461140860076111dd565b806114a781612461565b91505061145d565b816001600160a01b0316836001600160a01b031614156114e15760405162461bcd60e51b815260040161067890611f9e565b6001600160a01b0383811660008181526005602090815260408083209487168084529490915290819020805460ff1916851515179055517f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3190611545908590611e36565b60405180910390a3505050565b61155d848484611266565b611569848484846116d2565b610efa5760405162461bcd60e51b815260040161067890611e54565b6060600880546106ef90612426565b6060816115b957506040805180820190915260018152600360fc1b60208201526106db565b8160005b81156115e357806115cd81612461565b91506115dc9050600a836123b0565b91506115bd565b60008167ffffffffffffffff81111561160c57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611636576020820181803683370190505b5090505b841561125e5761164b6001836123e3565b9150611658600a8661247c565b611663906030612398565b60f81b81838151811061168657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506116a8600a866123b0565b945061163a565b80546001019055565b6106948282604051806020016040528060008152506117ed565b60006116e6846001600160a01b0316611820565b156117e257836001600160a01b031663150b7a02611702611135565b8786866040518563ffffffff1660e01b81526004016117249493929190611db5565b602060405180830381600087803b15801561173e57600080fd5b505af192505050801561176e575060408051601f3d908101601f1916820190925261176b91810190611bbd565b60015b6117c8573d80801561179c576040519150601f19603f3d011682016040523d82523d6000602084013e6117a1565b606091505b5080516117c05760405162461bcd60e51b815260040161067890611e54565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061125e565b506001949350505050565b6117f78383611826565b61180460008484846116d2565b6108d65760405162461bcd60e51b815260040161067890611e54565b3b151590565b6001600160a01b03821661184c5760405162461bcd60e51b815260040161067890612111565b61185581611152565b156118725760405162461bcd60e51b815260040161067890611eec565b61187e600083836108d6565b6001600160a01b03821660009081526003602052604081208054600192906118a7908490612398565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461191190612426565b90600052602060002090601f0160209004810192826119335760008555611979565b82601f1061194c57805160ff1916838001178555611979565b82800160010185558215611979579182015b8281111561197957825182559160200191906001019061195e565b50611985929150611989565b5090565b5b80821115611985576000815560010161198a565b600067ffffffffffffffff808411156119b9576119b96124bc565b604051601f8501601f1916810160200182811182821017156119dd576119dd6124bc565b6040528481529150818385018610156119f557600080fd5b8484602083013760006020868301015250509392505050565b80356001600160a01b03811681146106db57600080fd5b803580151581146106db57600080fd5b600060208284031215611a46578081fd5b61103382611a0e565b60008060408385031215611a61578081fd5b611a6a83611a0e565b9150611a7860208401611a0e565b90509250929050565b600080600060608486031215611a95578081fd5b611a9e84611a0e565b9250611aac60208501611a0e565b9150604084013590509250925092565b60008060008060808587031215611ad1578081fd5b611ada85611a0e565b9350611ae860208601611a0e565b925060408501359150606085013567ffffffffffffffff811115611b0a578182fd5b8501601f81018713611b1a578182fd5b611b298782356020840161199e565b91505092959194509250565b60008060408385031215611b47578182fd5b611b5083611a0e565b9150611a7860208401611a25565b60008060408385031215611b70578182fd5b611b7983611a0e565b946020939093013593505050565b600060208284031215611b98578081fd5b61103382611a25565b600060208284031215611bb2578081fd5b8135611033816124d2565b600060208284031215611bce578081fd5b8151611033816124d2565b600060208284031215611bea578081fd5b813567ffffffffffffffff811115611c00578182fd5b8201601f81018413611c10578182fd5b61125e8482356020840161199e565b600060208284031215611c30578081fd5b5035919050565b600080600060408486031215611c4b578283fd5b83359250602084013567ffffffffffffffff80821115611c69578384fd5b818601915086601f830112611c7c578384fd5b813581811115611c8a578485fd5b8760208083028501011115611c9d578485fd5b6020830194508093505050509250925092565b60008151808452611cc88160208601602086016123fa565b601f01601f19169290920160200192915050565b600084516020611cef8285838a016123fa565b855191840191611d028184848a016123fa565b8554920191839060028104600180831680611d1e57607f831692505b858310811415611d3c57634e487b7160e01b88526022600452602488fd5b808015611d505760018114611d6157611d8d565b60ff19851688528388019550611d8d565b611d6a8b61238c565b895b85811015611d855781548a820152908401908801611d6c565b505083880195505b50939b9a5050505050505050505050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611de890830184611cb0565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015611e2a57835183529284019291840191600101611e0e565b50909695505050505050565b901515815260200190565b6000602082526110336020830184611cb0565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6020808252601c908201527f6d6178204e465420706572206164647265737320657863656564656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526017908201527f54686520636f6e74726163742069732070617573656421000000000000000000604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b6020808252601490820152734d617820737570706c792065786365656465642160601b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b602080825260139082015272496e73756666696369656e742066756e64732160681b604082015260600190565b90815260200190565b60009081526020902090565b600082198211156123ab576123ab612490565b500190565b6000826123bf576123bf6124a6565b500490565b60008160001904831182151516156123de576123de612490565b500290565b6000828210156123f5576123f5612490565b500390565b60005b838110156124155781810151838201526020016123fd565b83811115610efa5750506000910152565b60028104600182168061243a57607f821691505b6020821081141561245b57634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561247557612475612490565b5060010190565b60008261248b5761248b6124a6565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610a3d57600080fdfea2646970667358221220fd2f13c2005ff5ff9c2d4a1a76954f2397be005793016cd5a9f51bb06a71b95464736f6c63430008000033
Verified Source Code Partial Match
Compiler: v0.8.0+commit.c7dfd78e
EVM: istanbul
Optimization: Yes (200 runs)
ToastPunkGenesis.sol 1295 lines
// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/utils/Counters.sol
// 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;
}
}
// File: @openzeppelin/contracts/utils/Strings.sol
// 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);
}
}
// File: @openzeppelin/contracts/utils/Context.sol
// 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;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
}
// File: @openzeppelin/contracts/utils/Address.sol
// 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);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// 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);
}
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
// 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);
}
// File: @openzeppelin/contracts/utils/introspection/ERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
/**
* @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;
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
/**
* @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;
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
/**
* @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 {}
}
// File: contracts/ToastPunkGenesis.sol
pragma solidity >=0.7.0 <0.9.0;
contract ToastPunkGenesis is ERC721, Ownable {
using Strings for uint256;
using Counters for Counters.Counter;
Counters.Counter private supply;
string public uriPrefix ;
string public baseExtension = ".json";
string public notRevealedUri;
uint256 public cost = 0.05 ether;
uint256 public maxSupply = 10000;
uint256 public nftPerAddressLimit = 20;
bool public paused = true;
bool public revealed = false;
mapping(address => uint256) public addressMintedBalance;
constructor() ERC721("ToastPunk Genesis", "TPG") {
setnotRevealedUri("ipfs://QmcqWNhBgnMTBakEz9viDRbRWrXAXGFWpoqc8CjTR8CCSE/hidden.json");
}
modifier mintCompliance(uint256 _mintAmount) {
require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!");
_;
}
function totalSupply() public view returns (uint256) {
return supply.current();
}
function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) {
require(!paused, "The contract is paused!");
require(msg.value >= cost * _mintAmount, "Insufficient funds!");
_mintLoop(msg.sender, _mintAmount);
}
function mintForAddress(uint256 _mintAmount, address[] calldata _receiver) public mintCompliance(_mintAmount) onlyOwner {
for (uint i = 0; i < _receiver.length; i++) {
_mintLoop2(_receiver[i], _mintAmount);
}
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount);
uint256 currentTokenId = 1;
uint256 ownedTokenIndex = 0;
while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) {
address currentTokenOwner = ownerOf(currentTokenId);
if (currentTokenOwner == _owner) {
ownedTokenIds[ownedTokenIndex] = currentTokenId;
ownedTokenIndex++;
}
currentTokenId++;
}
return ownedTokenIds;
}
function tokenURI(uint256 _tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(_tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), baseExtension))
: "";
}
function setRevealed(bool _state) public onlyOwner {
revealed = _state;
}
function setCost(uint256 _cost) public onlyOwner {
cost = _cost;
}
function setnotRevealedUri(string memory _notRevealedUri) public onlyOwner {
notRevealedUri = _notRevealedUri;
}
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
function setbaseExtension(string memory _baseExtension) public onlyOwner {
baseExtension = _baseExtension;
}
function setPaused(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public onlyOwner {
// This will transfer the remaining contract balance to the owner.
// Do not remove this otherwise you will not be able to withdraw the funds.
// =============================================================================
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
// =============================================================================
}
function _mintLoop(address _receiver, uint256 _mintAmount) internal {
uint256 ownerMintedCount = addressMintedBalance[msg.sender];
require(ownerMintedCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded");
for (uint256 i = 0; i < _mintAmount; i++) {
supply.increment();
addressMintedBalance[msg.sender]++;
_safeMint(_receiver, supply.current());
}
}
function _mintLoop2(address _receiver, uint256 _mintAmount) internal {
for (uint256 i = 0; i < _mintAmount; i++) {
supply.increment();
_safeMint(_receiver, supply.current());
}
}
function _baseURI() internal view virtual override returns (string memory) {
return uriPrefix;
}
}
Read Contract
addressMintedBalance 0x18cae269 → uint256
balanceOf 0x70a08231 → uint256
baseExtension 0xc6682862 → string
cost 0x13faede6 → uint256
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
maxSupply 0xd5abeb01 → uint256
name 0x06fdde03 → string
nftPerAddressLimit 0xba7d2c76 → uint256
notRevealedUri 0x081c8c44 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
revealed 0x51830227 → bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
uriPrefix 0x62b99ad4 → string
walletOfOwner 0x438b6300 → uint256[]
Write Contract 16 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
mint 0xa0712d68
uint256 _mintAmount
mintForAddress 0x962e0f5a
uint256 _mintAmount
address[] _receiver
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
setCost 0x44a0d68a
uint256 _cost
setPaused 0x16c38b3c
bool _state
setRevealed 0xe0a80853
bool _state
setUriPrefix 0x7ec4a659
string _uriPrefix
setbaseExtension 0x6b9d3e41
string _baseExtension
setnotRevealedUri 0x0188541d
string _notRevealedUri
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address