Address Contract Partially Verified
Address
0x9c61b1869f45b2A39d7300D9eb02157e912FD3fB
Balance
0.390000 ETH
Nonce
1
Code Size
10166 bytes
Creator
0x2f4342A4...8220 at tx 0xd84c8e57...331ae5
Indexed Transactions
0
Contract Bytecode
10166 bytes
0x60806040526004361061020d5760003560e01c806301ffc9a71461021257806306fdde0314610247578063081812fc14610269578063095ea7b3146102a157806316ba10e0146102c357806316c38b3c146102e357806318160ddd1461030357806318cae2691461032657806323957c661461035357806323b872dd146103735780632a23d07d146103935780632a5cde09146103a9578063336256de146103d65780633ccfd60b146103f657806342842e0e1461040b5780634fdd43cb1461042b578063518302271461044b5780635503a0e81461046b5780635c975abb1461048057806361cb91611461049a57806362b99ad4146104b95780636352211e146104ce57806370a08231146104ee578063715018a61461050e5780637ec4a65914610523578063811d2437146105435780638693da20146105635780638da5cb5b146105795780638fdcf9421461054357806394354fd01461058e57806395d89b41146105a45780639bcadc14146105b9578063a0712d68146105d9578063a22cb465146105ec578063a45ba8e71461060c578063b071401b14610621578063b88d4fde14610641578063ba7d2c7614610661578063c87b56dd14610677578063ca777e2114610697578063d33e196f146106b7578063d5abeb01146106d7578063e0a80853146106ed578063e985e9c51461070d578063efbd73f41461072d578063f2fde38b1461074d575b600080fd5b34801561021e57600080fd5b5061023261022d366004612258565b61076d565b60405190151581526020015b60405180910390f35b34801561025357600080fd5b5061025c6107bf565b60405161023e9190612487565b34801561027557600080fd5b506102896102843660046122da565b610851565b6040516001600160a01b03909116815260200161023e565b3480156102ad57600080fd5b506102c16102bc36600461219f565b6108de565b005b3480156102cf57600080fd5b506102c16102de366004612292565b6109ef565b3480156102ef57600080fd5b506102c16102fe36600461223d565b610a35565b34801561030f57600080fd5b50610318610a77565b60405190815260200161023e565b34801561033257600080fd5b50610318610341366004612070565b60126020526000908152604090205481565b34801561035f57600080fd5b506102c161036e3660046121c9565b610a87565b34801561037f57600080fd5b506102c161038e3660046120be565b610ace565b34801561039f57600080fd5b50610318600c5481565b3480156103b557600080fd5b506103c96103c4366004612070565b610aff565b60405161023e9190612443565b3480156103e257600080fd5b506102c16103f13660046122da565b610bdf565b34801561040257600080fd5b506102c1610c13565b34801561041757600080fd5b506102c16104263660046120be565b610cac565b34801561043757600080fd5b506102c1610446366004612292565b610cc7565b34801561045757600080fd5b506010546102329062010000900460ff1681565b34801561047757600080fd5b5061025c610d09565b34801561048c57600080fd5b506010546102329060ff1681565b3480156104a657600080fd5b5060105461023290610100900460ff1681565b3480156104c557600080fd5b5061025c610d97565b3480156104da57600080fd5b506102896104e93660046122da565b610da4565b3480156104fa57600080fd5b50610318610509366004612070565b610e1b565b34801561051a57600080fd5b506102c1610ea2565b34801561052f57600080fd5b506102c161053e366004612292565b610edd565b34801561054f57600080fd5b506102c161055e3660046122da565b610f1f565b34801561056f57600080fd5b50610318600b5481565b34801561058557600080fd5b50610289610f53565b34801561059a57600080fd5b50610318600e5481565b3480156105b057600080fd5b5061025c610f62565b3480156105c557600080fd5b506102326105d4366004612070565b610f71565b6102c16105e73660046122da565b610fdb565b3480156105f857600080fd5b506102c1610607366004612175565b611282565b34801561061857600080fd5b5061025c61128d565b34801561062d57600080fd5b506102c161063c3660046122da565b61129a565b34801561064d57600080fd5b506102c161065c3660046120fa565b6112ce565b34801561066d57600080fd5b50610318600f5481565b34801561068357600080fd5b5061025c6106923660046122da565b611306565b3480156106a357600080fd5b506102c16106b236600461223d565b611476565b3480156106c357600080fd5b506102896106d23660046122da565b6114bf565b3480156106e357600080fd5b50610318600d5481565b3480156106f957600080fd5b506102c161070836600461223d565b6114e9565b34801561071957600080fd5b5061023261072836600461208b565b611534565b34801561073957600080fd5b506102c16107483660046122f3565b611562565b34801561075957600080fd5b506102c1610768366004612070565b61161f565b60006001600160e01b031982166380ac58cd60e01b148061079e57506001600160e01b03198216635b5e139f60e01b145b806107b957506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546107ce90612688565b80601f01602080910402602001604051908101604052809291908181526020018280546107fa90612688565b80156108475780601f1061081c57610100808354040283529160200191610847565b820191906000526020600020905b81548152906001019060200180831161082a57829003601f168201915b5050505050905090565b600061085c826116cf565b6108c25760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006108e982610da4565b9050806001600160a01b0316836001600160a01b031614156109575760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108b9565b336001600160a01b038216148061097357506109738133611534565b6109e05760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776044820152771b995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b60421b60648201526084016108b9565b6109ea83836116ec565b505050565b336109f8610f53565b6001600160a01b031614610a1e5760405162461bcd60e51b81526004016108b99061251a565b8051610a31906009906020840190611ec5565b5050565b33610a3e610f53565b6001600160a01b031614610a645760405162461bcd60e51b81526004016108b99061251a565b6010805460ff1916911515919091179055565b6000610a8260075490565b905090565b33610a90610f53565b6001600160a01b031614610ab65760405162461bcd60e51b81526004016108b99061251a565b610ac260116000611f49565b6109ea60118383611f67565b610ad8338261175a565b610af45760405162461bcd60e51b81526004016108b9906125a9565b6109ea838383611824565b60606000610b0c83610e1b565b90506000816001600160401b03811115610b2857610b28612734565b604051908082528060200260200182016040528015610b51578160200160208202803683370190505b509050600160005b8381108015610b6a5750600d548211155b15610bd5576000610b7a83610da4565b9050866001600160a01b0316816001600160a01b03161415610bc25782848381518110610ba957610ba961271e565b602090810291909101015281610bbe816126c3565b9250505b82610bcc816126c3565b93505050610b59565b5090949350505050565b33610be8610f53565b6001600160a01b031614610c0e5760405162461bcd60e51b81526004016108b99061251a565b600f55565b33610c1c610f53565b6001600160a01b031614610c425760405162461bcd60e51b81526004016108b99061251a565b6000610c4c610f53565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610c96576040519150601f19603f3d011682016040523d82523d6000602084013e610c9b565b606091505b5050905080610ca957600080fd5b50565b6109ea838383604051806020016040528060008152506112ce565b33610cd0610f53565b6001600160a01b031614610cf65760405162461bcd60e51b81526004016108b99061251a565b8051610a3190600a906020840190611ec5565b60098054610d1690612688565b80601f0160208091040260200160405190810160405280929190818152602001828054610d4290612688565b8015610d8f5780601f10610d6457610100808354040283529160200191610d8f565b820191906000526020600020905b815481529060010190602001808311610d7257829003601f168201915b505050505081565b60088054610d1690612688565b6000818152600260205260408120546001600160a01b0316806107b95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108b9565b60006001600160a01b038216610e865760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108b9565b506001600160a01b031660009081526003602052604090205490565b33610eab610f53565b6001600160a01b031614610ed15760405162461bcd60e51b81526004016108b99061251a565b610edb60006119b2565b565b33610ee6610f53565b6001600160a01b031614610f0c5760405162461bcd60e51b81526004016108b99061251a565b8051610a31906008906020840190611ec5565b33610f28610f53565b6001600160a01b031614610f4e5760405162461bcd60e51b81526004016108b99061251a565b600b55565b6006546001600160a01b031690565b6060600180546107ce90612688565b6000805b601154811015610fd257826001600160a01b031660118281548110610f9c57610f9c61271e565b6000918252602090912001546001600160a01b03161415610fc05750600192915050565b80610fca816126c3565b915050610f75565b50600092915050565b80610fe4610f53565b6001600160a01b0316336001600160a01b03161461102a5760008111801561100e5750600e548111155b61102a5760405162461bcd60e51b81526004016108b9906124ec565b600d548161103760075490565b61104191906125fa565b111561105f5760405162461bcd60e51b81526004016108b99061254f565b60105460ff16156110ac5760405162461bcd60e51b815260206004820152601760248201527654686520636f6e7472616374206973207061757365642160481b60448201526064016108b9565b6110b4610f53565b6001600160a01b0316336001600160a01b03161461123a5760105460ff61010090910416151560011415611161576110eb33610f71565b6111345760405162461bcd60e51b815260206004820152601a6024820152797573657220646f6573206e6f7420686176652070726573616c6560301b60448201526064016108b9565b81600c546111429190612626565b3410156111615760405162461bcd60e51b81526004016108b99061257d565b61116a33610f71565b156111a15781600c5461117d9190612626565b34101561119c5760405162461bcd60e51b81526004016108b99061257d565b6111ce565b81600b546111af9190612626565b3410156111ce5760405162461bcd60e51b81526004016108b99061257d565b33600090815260126020526040902054600f546111eb84836125fa565b11156112385760405162461bcd60e51b815260206004820152601c60248201527b1b585e08139195081c195c881859191c995cdcc8195e18d95959195960221b60448201526064016108b9565b505b60015b8281116112775733600090815260126020526040812080549161125f836126c3565b9190505550808061126f906126c3565b91505061123d565b50610a313383611a04565b610a31338383611a41565b600a8054610d1690612688565b336112a3610f53565b6001600160a01b0316146112c95760405162461bcd60e51b81526004016108b99061251a565b600e55565b6112d8338361175a565b6112f45760405162461bcd60e51b81526004016108b9906125a9565b61130084848484611b0c565b50505050565b6060611311826116cf565b6113755760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016108b9565b60105462010000900460ff1661141757600a805461139290612688565b80601f01602080910402602001604051908101604052809291908181526020018280546113be90612688565b801561140b5780601f106113e05761010080835404028352916020019161140b565b820191906000526020600020905b8154815290600101906020018083116113ee57829003601f168201915b50505050509050919050565b6000611421611b3f565b90506000815111611441576040518060200160405280600081525061146f565b8061144b84611b4e565b600960405160200161145f93929190612342565b6040516020818303038152906040525b9392505050565b3361147f610f53565b6001600160a01b0316146114a55760405162461bcd60e51b81526004016108b99061251a565b601080549115156101000261ff0019909216919091179055565b601181815481106114cf57600080fd5b6000918252602090912001546001600160a01b0316905081565b336114f2610f53565b6001600160a01b0316146115185760405162461bcd60e51b81526004016108b99061251a565b60108054911515620100000262ff000019909216919091179055565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b8161156b610f53565b6001600160a01b0316336001600160a01b0316146115b1576000811180156115955750600e548111155b6115b15760405162461bcd60e51b81526004016108b9906124ec565b600d54816115be60075490565b6115c891906125fa565b11156115e65760405162461bcd60e51b81526004016108b99061254f565b336115ef610f53565b6001600160a01b0316146116155760405162461bcd60e51b81526004016108b99061251a565b6109ea8284611a04565b33611628610f53565b6001600160a01b03161461164e5760405162461bcd60e51b81526004016108b99061251a565b6001600160a01b0381166116b35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108b9565b610ca9816119b2565b80546001019055565b5490565b3b151590565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061172182610da4565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611765826116cf565b6117c65760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108b9565b60006117d183610da4565b9050806001600160a01b0316846001600160a01b0316148061180c5750836001600160a01b031661180184610851565b6001600160a01b0316145b8061181c575061181c8185611534565b949350505050565b826001600160a01b031661183782610da4565b6001600160a01b03161461189f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108b9565b6001600160a01b0382166119015760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108b9565b61190c6000826116ec565b6001600160a01b0383166000908152600360205260408120805460019290611935908490612645565b90915550506001600160a01b03821660009081526003602052604081208054600192906119639084906125fa565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03868116918217909255915184939187169160008051602061276183398151915291a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60005b818110156109ea57611a1d600780546001019055565b611a2f83611a2a60075490565b611c4b565b80611a39816126c3565b915050611a07565b816001600160a01b0316836001600160a01b03161415611a9f5760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b60448201526064016108b9565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611b17848484611824565b611b2384848484611c65565b6113005760405162461bcd60e51b81526004016108b99061249a565b6060600880546107ce90612688565b606081611b725750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611b9c5780611b86816126c3565b9150611b959050600a83612612565b9150611b76565b6000816001600160401b03811115611bb657611bb6612734565b6040519080825280601f01601f191660200182016040528015611be0576020820181803683370190505b5090505b841561181c57611bf5600183612645565b9150611c02600a866126de565b611c0d9060306125fa565b60f81b818381518110611c2257611c2261271e565b60200101906001600160f81b031916908160001a905350611c44600a86612612565b9450611be4565b610a31828260405180602001604052806000815250611d72565b60006001600160a01b0384163b15611d6757604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611ca9903390899088908890600401612406565b602060405180830381600087803b158015611cc357600080fd5b505af1925050508015611cf3575060408051601f3d908101601f19168201909252611cf091810190612275565b60015b611d4d573d808015611d21576040519150601f19603f3d011682016040523d82523d6000602084013e611d26565b606091505b508051611d455760405162461bcd60e51b81526004016108b99061249a565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061181c565b506001949350505050565b611d7c8383611da5565b611d896000848484611c65565b6109ea5760405162461bcd60e51b81526004016108b99061249a565b6001600160a01b038216611dfb5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108b9565b611e04816116cf565b15611e505760405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b60448201526064016108b9565b6001600160a01b0382166000908152600360205260408120805460019290611e799084906125fa565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051839290600080516020612761833981519152908290a45050565b828054611ed190612688565b90600052602060002090601f016020900481019282611ef35760008555611f39565b82601f10611f0c57805160ff1916838001178555611f39565b82800160010185558215611f39579182015b82811115611f39578251825591602001919060010190611f1e565b50611f45929150611fba565b5090565b5080546000825590600052602060002090810190610ca99190611fba565b828054828255906000526020600020908101928215611f39579160200282015b82811115611f395781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190611f87565b5b80821115611f455760008155600101611fbb565b60006001600160401b0380841115611fe957611fe9612734565b604051601f8501601f19908116603f0116810190828211818310171561201157612011612734565b8160405280935085815286868601111561202a57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b038116811461205b57600080fd5b919050565b8035801515811461205b57600080fd5b60006020828403121561208257600080fd5b61146f82612044565b6000806040838503121561209e57600080fd5b6120a783612044565b91506120b560208401612044565b90509250929050565b6000806000606084860312156120d357600080fd5b6120dc84612044565b92506120ea60208501612044565b9150604084013590509250925092565b6000806000806080858703121561211057600080fd5b61211985612044565b935061212760208601612044565b92506040850135915060608501356001600160401b0381111561214957600080fd5b8501601f8101871361215a57600080fd5b61216987823560208401611fcf565b91505092959194509250565b6000806040838503121561218857600080fd5b61219183612044565b91506120b560208401612060565b600080604083850312156121b257600080fd5b6121bb83612044565b946020939093013593505050565b600080602083850312156121dc57600080fd5b82356001600160401b03808211156121f357600080fd5b818501915085601f83011261220757600080fd5b81358181111561221657600080fd5b8660208260051b850101111561222b57600080fd5b60209290920196919550909350505050565b60006020828403121561224f57600080fd5b61146f82612060565b60006020828403121561226a57600080fd5b813561146f8161274a565b60006020828403121561228757600080fd5b815161146f8161274a565b6000602082840312156122a457600080fd5b81356001600160401b038111156122ba57600080fd5b8201601f810184136122cb57600080fd5b61181c84823560208401611fcf565b6000602082840312156122ec57600080fd5b5035919050565b6000806040838503121561230657600080fd5b823591506120b560208401612044565b6000815180845261232e81602086016020860161265c565b601f01601f19169290920160200192915050565b6000845160206123558285838a0161265c565b8551918401916123688184848a0161265c565b8554920191600090600181811c908083168061238557607f831692505b8583108114156123a357634e487b7160e01b85526022600452602485fd5b8080156123b757600181146123c8576123f5565b60ff198516885283880195506123f5565b60008b81526020902060005b858110156123ed5781548a8201529084019088016123d4565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061243990830184612316565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561247b5783518352928401929184019160010161245f565b50909695505050505050565b60208152600061146f6020830184612316565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b602080825260149082015273496e76616c6964206d696e7420616d6f756e742160601b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601490820152734d617820737570706c792065786365656465642160601b604082015260600190565b602080825260129082015271696e73756666696369656e742066756e647360701b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561260d5761260d6126f2565b500190565b60008261262157612621612708565b500490565b6000816000190483118215151615612640576126406126f2565b500290565b600082821015612657576126576126f2565b500390565b60005b8381101561267757818101518382015260200161265f565b838111156113005750506000910152565b600181811c9082168061269c57607f821691505b602082108114156126bd57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156126d7576126d76126f2565b5060010190565b6000826126ed576126ed612708565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610ca957600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212204da8eac82529d85b1aca5c907366e51b9ca93d12f2a2d928ac96a482883cd4c664736f6c63430008070033
Verified Source Code Partial Match
Compiler: v0.8.7+commit.e28d00a7
EVM: london
Optimization: Yes (1 runs)
CrypToilets.sol 1355 lines
// SPDX-License-Identifier: GPL-3.0
/// @title: CrypToilets
/**
____ _____ _ _ _
/ ___| _ __ _ _ _ __|_ _|___ (_)| | ___ | |_ ___
| | | '__|| | | || '_ \ | | / _ \ | || | / _ \| __|/ __|
| |___ | | | |_| || |_) || || (_) || || || __/| |_ \__ \
\____||_| \__, || .__/ |_| \___/ |_||_| \___| \__||___/
|___/ |_|
-/hMNMMM`
-ohNMNhyNMMd\
`:sddys+dMMMMMh\
`yMMMMMMMMhs\MMMN/
`hMMNNy.MMMMho\MNo.
sMMMo/../MMMMy/MhyMMMMMMMMhyMMMMMMMMMMhyMMMMMMMMMhyNMMMMMMMMhyMMMMMMMMMhy
-MMMMy.yNMMMM/hyNMMMMMMMhyNMMMMMMMMMhyNMMMMMMMMhyNMMMMMMMMhyNMMMMMMMNhy
-MMMMMMMMMN/yNMMMMMMMhyNMMMMMMMMMyhNMMMMMMMNhyNMMMMMMMNhyNMMMMMMMNhy
`:shNNhNNyNNNNNNNNhyNNNNNNNNNMyhNNNNNNNNNhyNNNNNNNNNhyNNNNNNNNNhy
*/
// 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/crypToiletsTEST.sol
pragma solidity >=0.7.0 <0.9.0;
contract CrypToilets is ERC721, Ownable {
using Strings for uint256;
using Counters for Counters.Counter;
Counters.Counter private supply;
string public uriPrefix = "";
string public uriSuffix = ".json";
string public hiddenMetadataUri;
uint256 public publicCost = 30000000000000000; // 0.03 ether;
uint256 public presaleCost = 20000000000000000; // 0.02 ether;
uint256 public maxSupply = 3333;
uint256 public maxMintAmountPerTx = 10;
uint256 public nftPerAddressLimit = 10;
bool public paused = true;
bool public onlyPresale = true;
bool public revealed = false;
address[] public presaleAddresses;
mapping(address => uint256) public addressMintedBalance;
constructor(
string memory _name,
string memory _symbol
) ERC721(_name, _symbol) {
setHiddenMetadataUri("ipfs://QmeTiBrqFHVGc3qNV31nGTPHb5iwCgb9HMMRvXKdAcoyMA/unrevealed.json");
_mintLoop(msg.sender, 150);
}
modifier mintCompliance(uint256 _mintAmount) {
if (msg.sender != owner()) {
require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!");
}
require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!");
_;
}
function totalSupply() public view returns (uint256) {
return supply.current();
}
function isPresale(address _user) public view returns (bool) {
for (uint i = 0; i < presaleAddresses.length; i++) {
if (presaleAddresses[i] == _user) {
return true;
}
}
return false;
}
function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) {
require(!paused, "The contract is paused!");
if (msg.sender != owner()) {
if (onlyPresale == true) {
require(isPresale(msg.sender), "user does not have presale");
require(msg.value >= presaleCost * _mintAmount, "insufficient funds");
}
if(isPresale(msg.sender)) {
require(msg.value >= presaleCost * _mintAmount, "insufficient funds");
} else {
require(msg.value >= publicCost * _mintAmount, "insufficient funds");
}
uint256 senderMintedCount = addressMintedBalance[msg.sender];
require(senderMintedCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
addressMintedBalance[msg.sender]++;
}
_mintLoop(msg.sender, _mintAmount);
}
function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner {
_mintLoop(_receiver, _mintAmount);
}
function walletQuery(address _wallet)
public
view
returns (uint256[] memory)
{
uint256 tokenCount = balanceOf(_wallet);
uint256[] memory ownedTokenIds = new uint256[](tokenCount);
uint256 currentTokenId = 1;
uint256 ownedTokenIndex = 0;
while (ownedTokenIndex < tokenCount && currentTokenId <= maxSupply) {
address currentTokenOwner = ownerOf(currentTokenId);
if (currentTokenOwner == _wallet) {
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 hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix))
: "";
}
function setRevealed(bool _state) public onlyOwner {
revealed = _state;
}
function setOnlyPresale(bool _state) public onlyOwner {
onlyPresale = _state;
}
function setPublicCost(uint256 _publicCost) public onlyOwner {
publicCost = _publicCost;
}
function setPresaleCost(uint256 _presaleCost) public onlyOwner {
publicCost = _presaleCost;
}
function setPresaleUsers(address[] calldata _users) public onlyOwner {
delete presaleAddresses;
presaleAddresses = _users;
}
function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {
maxMintAmountPerTx = _maxMintAmountPerTx;
}
function setMaxNftPerAddress(uint256 _maxNftsPerAddress) public onlyOwner {
nftPerAddressLimit = _maxNftsPerAddress;
}
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
function setUriSuffix(string memory _uriSuffix) public onlyOwner {
uriSuffix = _uriSuffix;
}
function setPaused(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public onlyOwner {
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
}
function _mintLoop(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
getApproved 0x081812fc → address
hiddenMetadataUri 0xa45ba8e7 → string
isApprovedForAll 0xe985e9c5 → bool
isPresale 0x9bcadc14 → bool
maxMintAmountPerTx 0x94354fd0 → uint256
maxSupply 0xd5abeb01 → uint256
name 0x06fdde03 → string
nftPerAddressLimit 0xba7d2c76 → uint256
onlyPresale 0x61cb9161 → bool
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
presaleAddresses 0xd33e196f → address
presaleCost 0x2a23d07d → uint256
publicCost 0x8693da20 → uint256
revealed 0x51830227 → bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
uriPrefix 0x62b99ad4 → string
uriSuffix 0x5503a0e8 → string
walletQuery 0x2a5cde09 → uint256[]
Write Contract 21 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
mint 0xa0712d68
uint256 _mintAmount
mintForAddress 0xefbd73f4
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
setHiddenMetadataUri 0x4fdd43cb
string _hiddenMetadataUri
setMaxMintAmountPerTx 0xb071401b
uint256 _maxMintAmountPerTx
setMaxNftPerAddress 0x336256de
uint256 _maxNftsPerAddress
setOnlyPresale 0xca777e21
bool _state
setPaused 0x16c38b3c
bool _state
setPresaleCost 0x8fdcf942
uint256 _presaleCost
setPresaleUsers 0x23957c66
address[] _users
setPublicCost 0x811d2437
uint256 _publicCost
setRevealed 0xe0a80853
bool _state
setUriPrefix 0x7ec4a659
string _uriPrefix
setUriSuffix 0x16ba10e0
string _uriSuffix
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address