Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xb487A91382cD66076fc4C1AF4D7d8CE7f929A9bA
Balance 0 ETH
Nonce 1
Code Size 19166 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

19166 bytes
0x6080604052600436106104565760003560e01c80636824a7041161023f578063a22cb46511610139578063de0ec164116100b6578063e7e987241161007a578063e7e9872414610de2578063e985e9c514610df8578063f1147bae14610e41578063f2fde38b14610e56578063f4a0a52814610e76576104e3565b8063de0ec16414610d35578063e44a2d7014610d4b578063e4dc70ff14610d6b578063e53f2fb114610d98578063e63ab1e914610dae576104e3565b8063c986cb30116100fd578063c986cb3014610c96578063ca15c87314610cac578063d42457cb14610ccc578063d539139314610ce1578063d547741f14610d15576104e3565b8063a22cb46514610bf6578063a910195214610c16578063ad225a9f14610c36578063b88d4fde14610c56578063c87b56dd14610c76576104e3565b80638456cb59116101c75780639010d07c1161018b5780639010d07c14610b6d57806391d1485414610b8d57806395d89b4114610bad5780639c0abd6914610bc2578063a217fddf14610be1576104e3565b80638456cb5914610ade57806386e3ff7514610af35780638895283f14610b135780638bac9ff314610b335780638da5cb5b14610b48576104e3565b80636b37fbaa1161020e5780636b37fbaa14610a3357806370a0823114610a485780637a4e571514610a685780637f64978314610a88578063833ef82314610aa8576104e3565b80636824a704146109b7578063687de78d146109e75780636a2b477f146109fd5780636a62784214610a13576104e3565b80633b3a7f621161035057806348b0ccf4116102d857806355f804b31161029c57806355f804b3146109415780635a7adf7f146109615780635c975abb146109695780636352211e146109815780636817c76c146109a1576104e3565b806348b0ccf4146108945780634f6ccce7146108b657806350372e72146108d6578063523a3f08146108eb5780635328302f1461090b576104e3565b806342842e0e1161031f57806342842e0e146107e457806342966c6814610804578063438b630014610824578063457621f614610844578063464bd6401461087a576104e3565b80633b3a7f62146107625780633ddb3cfb146107825780633f4ba83a146107a25780634213c7b3146107b7576104e3565b806318160ddd116103de5780632f2ff15d116103a25780632f2ff15d146106e45780632f745c591461070457806330666a4d1461072457806333bc1c5c1461073a57806336568abe14610742576104e3565b806318160ddd1461064957806321f4697d1461065e57806322d8882c1461067e57806323b872dd14610694578063248a9ca3146106b4576104e3565b8063081812fc11610425578063081812fc14610581578063095ea7b3146105b95780631365b277146105d9578063146ca53114610613578063155dd5ee14610629576104e3565b806301e33667146104e857806301ffc9a71461050a57806306fdde031461053f5780630700849014610561576104e3565b366104e357604080513381523460208201527f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f88525874910160405180910390a160006104a0606434614936565b905080601b60008282546104b4919061491e565b90915550600090506104c68234614969565b905080602560008282546104da919061491e565b90915550505050005b600080fd5b3480156104f457600080fd5b506105086105033660046142cf565b610e96565b005b34801561051657600080fd5b5061052a610525366004614540565b611029565b60405190151581526020015b60405180910390f35b34801561054b57600080fd5b5061055461103c565b604051610536919061478c565b34801561056d57600080fd5b5061050861057c3660046144e3565b6110ce565b34801561058d57600080fd5b506105a161059c3660046144e3565b611103565b6040516001600160a01b039091168152602001610536565b3480156105c557600080fd5b506105086105d43660046143b9565b611198565b3480156105e557600080fd5b506106056105f436600461427b565b602080526000908152604090205481565b604051908152602001610536565b34801561061f57600080fd5b5061060560115481565b34801561063557600080fd5b506105086106443660046144e3565b6112ae565b34801561065557600080fd5b50600a54610605565b34801561066a57600080fd5b506105086106793660046144ab565b6112fd565b34801561068a57600080fd5b5061060560145481565b3480156106a057600080fd5b506105086106af3660046142cf565b611347565b3480156106c057600080fd5b506106056106cf3660046144e3565b60009081526020819052604090206001015490565b3480156106f057600080fd5b506105086106ff3660046144fb565b611379565b34801561071057600080fd5b5061060561071f3660046143b9565b61139b565b34801561073057600080fd5b5061060560185481565b610508611434565b34801561074e57600080fd5b5061050861075d3660046144fb565b611690565b34801561076e57600080fd5b5061050861077d366004614478565b6116b2565b34801561078e57600080fd5b5061050861079d3660046144e3565b61177c565b3480156107ae57600080fd5b506105086117b2565b3480156107c357600080fd5b506107d76107d236600461427b565b61185a565b6040516105369190614754565b3480156107f057600080fd5b506105086107ff3660046142cf565b61192b565b34801561081057600080fd5b5061050861081f3660046144e3565b611946565b34801561083057600080fd5b506107d761083f36600461427b565b6119bd565b34801561085057600080fd5b506105a161085f3660046144e3565b6024602052600090815260409020546001600160a01b031681565b34801561088657600080fd5b5060105461052a9060ff1681565b3480156108a057600080fd5b506108a9611a73565b6040516105369190614707565b3480156108c257600080fd5b506106056108d13660046144e3565b611b18565b3480156108e257600080fd5b50610508611bb9565b3480156108f757600080fd5b506105086109063660046144e3565b611c9d565b34801561091757600080fd5b506105a16109263660046144e3565b6000908152602460205260409020546001600160a01b031690565b34801561094d57600080fd5b5061050861095c366004614578565b611d7b565b610508611dbe565b34801561097557600080fd5b50600c5460ff1661052a565b34801561098d57600080fd5b506105a161099c3660046144e3565b612005565b3480156109ad57600080fd5b5061060560175481565b3480156109c357600080fd5b5061052a6109d23660046144e3565b601f6020526000908152604090205460ff1681565b3480156109f357600080fd5b5061060560195481565b348015610a0957600080fd5b5061060560135481565b348015610a1f57600080fd5b50610508610a2e36600461427b565b61207c565b348015610a3f57600080fd5b50610508612138565b348015610a5457600080fd5b50610605610a6336600461427b565b61227d565b348015610a7457600080fd5b50610508610a833660046144e3565b612304565b348015610a9457600080fd5b50610508610aa33660046143e4565b612339565b348015610ab457600080fd5b506105a1610ac33660046144e3565b601e602052600090815260409020546001600160a01b031681565b348015610aea57600080fd5b506105086123db565b348015610aff57600080fd5b50610605610b0e3660046144e3565b61247f565b348015610b1f57600080fd5b50610508610b2e3660046144ab565b6124b4565b348015610b3f57600080fd5b50602554610605565b348015610b5457600080fd5b506105a16010546201000090046001600160a01b031690565b348015610b7957600080fd5b506105a1610b8836600461451f565b6124f7565b348015610b9957600080fd5b5061052a610ba83660046144fb565b61250f565b348015610bb957600080fd5b50610554612538565b348015610bce57600080fd5b5060105461052a90610100900460ff1681565b348015610bed57600080fd5b50610605600081565b348015610c0257600080fd5b50610508610c1136600461438c565b612547565b348015610c2257600080fd5b50610508610c31366004614478565b612619565b348015610c4257600080fd5b50610508610c51366004614417565b6126fc565b348015610c6257600080fd5b50610508610c7136600461430f565b612824565b348015610c8257600080fd5b50610554610c913660046144e3565b612856565b348015610ca257600080fd5b50610605601a5481565b348015610cb857600080fd5b50610605610cc73660046144e3565b612922565b348015610cd857600080fd5b506108a9612939565b348015610ced57600080fd5b506106057f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b348015610d2157600080fd5b50610508610d303660046144fb565b6129d4565b348015610d4157600080fd5b5061060560125481565b348015610d5757600080fd5b50610508610d66366004614578565b6129de565b348015610d7757600080fd5b50610605610d863660046144e3565b60266020526000908152604090205481565b348015610da457600080fd5b5061060560165481565b348015610dba57600080fd5b506106057f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b348015610dee57600080fd5b5061060560155481565b348015610e0457600080fd5b5061052a610e13366004614297565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610e4d57600080fd5b50610508612a21565b348015610e6257600080fd5b50610508610e7136600461427b565b612aa6565b348015610e8257600080fd5b50610508610e913660046144e3565b612b00565b6010546201000090046001600160a01b03163314610ecf5760405162461bcd60e51b8152600401610ec690614841565b60405180910390fd5b6040516370a0823160e01b815230600482015281906001600160a01b038516906370a082319060240160206040518083038186803b158015610f1057600080fd5b505afa158015610f24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4891906145be565b1015610fa15760405162461bcd60e51b815260206004820152602260248201527f596f7520646f206e6f7420686176652073756666696369656e742042616c616e604482015261636560f01b6064820152608401610ec6565b60405163a9059cbb60e01b81526001600160a01b0383811660048301526024820183905284169063a9059cbb90604401602060405180830381600087803b158015610feb57600080fd5b505af1158015610fff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102391906144c7565b50505050565b600061103482612b54565b90505b919050565b60606002805461104b906149c3565b80601f0160208091040260200160405190810160405280929190818152602001828054611077906149c3565b80156110c45780601f10611099576101008083540402835291602001916110c4565b820191906000526020600020905b8154815290600101906020018083116110a757829003601f168201915b5050505050905090565b6010546201000090046001600160a01b031633146110fe5760405162461bcd60e51b8152600401610ec690614841565b601555565b6000818152600460205260408120546001600160a01b031661117c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610ec6565b506000908152600660205260409020546001600160a01b031690565b60006111a382612005565b9050806001600160a01b0316836001600160a01b031614156112115760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610ec6565b336001600160a01b038216148061122d575061122d8133610e13565b61129f5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610ec6565b6112a98383612b79565b505050565b6010546201000090046001600160a01b031633146112de5760405162461bcd60e51b8152600401610ec690614841565b6010546112fa906201000090046001600160a01b031682612be7565b50565b6010546201000090046001600160a01b0316331461132d5760405162461bcd60e51b8152600401610ec690614841565b601080549115156101000261ff0019909216919091179055565b611352335b82612c81565b61136e5760405162461bcd60e51b8152600401610ec690614878565b6112a9838383612d78565b6113838282612f23565b60008281526001602052604090206112a99082612b3f565b60006113a68361227d565b82106114085760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610ec6565b506001600160a01b03821660009081526008602090815260408083208484529091529020545b92915050565b601054610100900460ff166114805760405162461bcd60e51b81526020600482015260126024820152711c1d589b1a58d35a5b9d0e8814185d5cd95960721b6044820152606401610ec6565b3332146114bd5760405162461bcd60e51b815260206004820152600b60248201526a139bdd08105b1b1bddd95960aa1b6044820152606401610ec6565b6000601754346114cd9190614a19565b90506000601754346114df9190614936565b905081156115425760405162461bcd60e51b815260206004820152602a60248201527f7075626c69634d696e743a2053656e64206120646976697369626c6520616d6f6044820152690eadce840decc40cae8d60b31b6064820152608401610ec6565b600034116115925760405162461bcd60e51b815260206004820152601960248201527f7075626c69634d696e743a20496e76616c69642056616c7565000000000000006044820152606401610ec6565b6018548111156115e45760405162461bcd60e51b815260206004820152601860248201527f7075626c69634d696e743a204d617820352070657220747800000000000000006044820152606401610ec6565b601c5481601354601254601954601a546115fe919061491e565b611608919061491e565b611612919061491e565b61161c919061491e565b111561166a5760405162461bcd60e51b815260206004820152601960248201527f7075626c69634d696e743a2053757270617373657320636170000000000000006044820152606401610ec6565b806013600082825461167c919061491e565b9091555061168c90503382612f4a565b5050565b61169a8282613064565b60008281526001602052604090206112a990826130de565b60005b815181101561168c5760648282815181106116e057634e487b7160e01b600052603260045260246000fd5b60200260200101511115801561171d5750600082828151811061171357634e487b7160e01b600052603260045260246000fd5b6020026020010151115b6117395760405162461bcd60e51b8152600401610ec6906147f1565b61176982828151811061175c57634e487b7160e01b600052603260045260246000fd5b60200260200101516130f3565b5080611774816149fe565b9150506116b5565b6064811115801561178d5750600081115b6117a95760405162461bcd60e51b8152600401610ec6906147f1565b61168c816130f3565b6117dc7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a33610ba8565b611850576040805162461bcd60e51b81526020600482015260248101919091527f4552433732315072657365744d696e7465725061757365724175746f49643a2060448201527f6d75737420686176652070617573657220726f6c6520746f20756e70617573656064820152608401610ec6565b61185861324f565b565b606060006118678361227d565b905060008167ffffffffffffffff81111561189257634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156118bb578160200160208202803683370190505b50905060005b8281101561192357602260006118d7878461139b565b81526020019081526020016000205482828151811061190657634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061191b816149fe565b9150506118c1565b509392505050565b6112a983838360405180602001604052806000815250612824565b61194f3361134c565b6119b45760405162461bcd60e51b815260206004820152603060248201527f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760448201526f1b995c881b9bdc88185c1c1c9bdd995960821b6064820152608401610ec6565b6112fa816132e2565b606060006119ca8361227d565b905060008167ffffffffffffffff8111156119f557634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611a1e578160200160208202803683370190505b50905060005b8281101561192357611a36858261139b565b828281518110611a5657634e487b7160e01b600052603260045260246000fd5b602090810291909101015280611a6b816149fe565b915050611a24565b604080516127118082526204e240820190925260609160009190602082016204e2208036833701905050905060005b6127108111611b125760008181526024602052604090205482516001600160a01b0390911690839083908110611ae857634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015280611b0a816149fe565b915050611aa2565b50905090565b6000611b23600a5490565b8210611b865760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610ec6565b600a8281548110611ba757634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000611bc43361227d565b905060008111611c245760405162461bcd60e51b815260206004820152602560248201527f61646f7074696f6e4d696e743a20596f7520646f6e2774206f776e20616e79206044820152643a37b5b2b760d91b6064820152608401610ec6565b60005b8181101561168c576000611c3b338361139b565b905060648111611c8a576000818152602260205260409020548015611c885760008281526022602052604081208054839290611c78908490614969565b90915550611c8890503382612f4a565b505b5080611c95816149fe565b915050611c27565b33611ca782612005565b6001600160a01b0316148015611cbe575060648111155b611cf75760405162461bcd60e51b815260206004820152600a60248201526915d48e925b9d985b1a5960b21b6044820152606401610ec6565b601a54600082815260216020526040812054601b54919291611d199190614969565b611d239190614936565b905060008111611d5f5760405162461bcd60e51b8152602060048201526007602482015266546f6f204c6f7760c81b6044820152606401610ec6565b601b5460008381526021602052604090205561168c3382612be7565b6010546201000090046001600160a01b03163314611dab5760405162461bcd60e51b8152600401610ec690614841565b805161168c90600f9060208401906140b5565b60105460ff16611e025760405162461bcd60e51b815260206004820152600f60248201526e1c1c9954d85b194e8814185d5cd959608a1b6044820152606401610ec6565b333214611e3f5760405162461bcd60e51b815260206004820152600b60248201526a139bdd08105b1b1bddd95960aa1b6044820152606401610ec6565b600060175434611e4f9190614a19565b9050600060175434611e619190614936565b905060003411611eac5760405162461bcd60e51b815260206004820152601660248201527570726553616c653a20496e76616c69642056616c756560501b6044820152606401610ec6565b8115611f0a5760405162461bcd60e51b815260206004820152602760248201527f70726553616c653a2053656e64206120646976697369626c6520616d6f756e74604482015266040decc40cae8d60cb1b6064820152608401610ec6565b60165481601254611f1b919061491e565b1115611f625760405162461bcd60e51b8152602060048201526016602482015275070726553616c653a20537572706173736573206361760541b6044820152606401610ec6565b336000908152602080526040902054811115611fd05760405162461bcd60e51b815260206004820152602760248201527f70726553616c653a20416d6f756e742067726561746572207468616e20616c6c60448201526637b1b0ba34b7b760c91b6064820152608401610ec6565b8060126000828254611fe2919061491e565b90915550503360009081526020805260408120805483929061167c908490614969565b6000818152600460205260408120546001600160a01b0316806110345760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610ec6565b6120a67f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a633610ba8565b6121185760405162461bcd60e51b815260206004820152603d60248201527f4552433732315072657365744d696e7465725061757365724175746f49643a2060448201527f6d7573742068617665206d696e74657220726f6c6520746f206d696e740000006064820152608401610ec6565b61212a81612125600d5490565b613389565b6112fa600d80546001019055565b336000612144826119bd565b90506000805b825181101561223757606483828151811061217557634e487b7160e01b600052603260045260246000fd5b60200260200101511161222557601a54602160008584815181106121a957634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002054601b546121cd9190614969565b6121d79190614936565b6121e1908361491e565b9150601b546021600085848151811061220a57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020819055505b8061222f816149fe565b91505061214a565b50600081116122735760405162461bcd60e51b81526020600482015260086024820152675741523a204c544360c01b6044820152606401610ec6565b6112a93382612be7565b60006001600160a01b0382166122e85760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610ec6565b506001600160a01b031660009081526005602052604090205490565b6010546201000090046001600160a01b031633146123345760405162461bcd60e51b8152600401610ec690614841565b601855565b6010546201000090046001600160a01b031633146123695760405162461bcd60e51b8152600401610ec690614841565b60005b815181101561168c576015546020600084848151811061239c57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000208190555080806123d3906149fe565b91505061236c565b6124057f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a33610ba8565b6124775760405162461bcd60e51b815260206004820152603e60248201527f4552433732315072657365744d696e7465725061757365724175746f49643a2060448201527f6d75737420686176652070617573657220726f6c6520746f20706175736500006064820152608401610ec6565b6118586134d7565b601a54600082815260216020526040812054601b549192839290916124a391614969565b6124ad9190614936565b9392505050565b6010546201000090046001600160a01b031633146124e45760405162461bcd60e51b8152600401610ec690614841565b6010805460ff1916911515919091179055565b60008281526001602052604081206124ad9083613552565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60606003805461104b906149c3565b6001600160a01b0382163314156125a05760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610ec6565b3360008181526007602090815260408083206001600160a01b0387168085529252909120805460ff1916841515179055906001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161260d911515815260200190565b60405180910390a35050565b6010546201000090046001600160a01b031633146126495760405162461bcd60e51b8152600401610ec690614841565b60005b815181101561168c5781818151811061267557634e487b7160e01b600052603260045260246000fd5b60200260200101516022600083600161268e919061491e565b8152602001908152602001600020819055508181815181106126c057634e487b7160e01b600052603260045260246000fd5b6020026020010151602360008360016126d9919061491e565b8152602081019190915260400160002055806126f4816149fe565b91505061264c565b6010546201000090046001600160a01b0316331461272c5760405162461bcd60e51b8152600401610ec690614841565b60005b82518110156112a95782818151811061275857634e487b7160e01b600052603260045260246000fd5b6020026020010151601e600084848151811061278457634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055506001601f60008484815181106127e457634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a81548160ff021916908315150217905550808061281c906149fe565b91505061272f565b61282e3383612c81565b61284a5760405162461bcd60e51b8152600401610ec690614878565b6110238484848461355e565b6000818152600460205260409020546060906001600160a01b03166128d55760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610ec6565b60006128df613591565b905060006128eb6135a0565b905080826128f8866135af565b60405160200161290a93929190614602565b60405160208183030381529060405292505050919050565b6000818152600160205260408120611034906136ca565b604080516065808252610cc082019092526060916000919060208201610ca08036833701905050905060005b60648111611b12576000818152601e602052604090205482516001600160a01b03909116908390839081106129aa57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0390921660209283029190910190910152806129cc816149fe565b915050612965565b61169a82826136d4565b6010546201000090046001600160a01b03163314612a0e5760405162461bcd60e51b8152600401610ec690614841565b805161168c90601d9060208401906140b5565b6010546201000090046001600160a01b03163314612a515760405162461bcd60e51b8152600401610ec690614841565b600060255411612a935760405162461bcd60e51b815260206004820152600d60248201526c15d49315164e925b9d985b1a59609a1b6044820152606401610ec6565b6025805460009091556112fa3382612be7565b6010546201000090046001600160a01b03163314612ad65760405162461bcd60e51b8152600401610ec690614841565b601080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b6010546201000090046001600160a01b03163314612b305760405162461bcd60e51b8152600401610ec690614841565b601755565b61168c82826136fa565b60006124ad836001600160a01b03841661377e565b60006001600160e01b0319821663780e9d6360e01b14806110345750611034826137cd565b600081815260066020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612bae82612005565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612c34576040519150601f19603f3d011682016040523d82523d6000602084013e612c39565b606091505b50509050806112a95760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321032ba3432b960611b6044820152606401610ec6565b6000818152600460205260408120546001600160a01b0316612cfa5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610ec6565b6000612d0583612005565b9050806001600160a01b0316846001600160a01b03161480612d405750836001600160a01b0316612d3584611103565b6001600160a01b0316145b80612d7057506001600160a01b0380821660009081526007602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316612d8b82612005565b6001600160a01b031614612df35760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610ec6565b6001600160a01b038216612e555760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610ec6565b612e6083838361380d565b612e6b600082612b79565b6001600160a01b0383166000908152600560205260408120805460019290612e94908490614969565b90915550506001600160a01b0382166000908152600560205260408120805460019290612ec290849061491e565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600082815260208190526040902060010154612f4081335b613818565b6112a983836136fa565b601c54600a5410612f935760405162461bcd60e51b815260206004820152601360248201527204d696e743a205375727061737365732063617606c1b6044820152606401610ec6565b60005b818110156112a957600160146000828254612fb1919061491e565b909155505060148054600090815260246020526040902080546001600160a01b0319166001600160a01b03861617905554612fed90849061387c565b601480546000908152602160209081526040808320839055805180830182524281528454845260269092528083209151909155915491516001600160a01b038616917f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688591a38061305c816149fe565b915050612f96565b6001600160a01b03811633146130d45760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610ec6565b61168c8282613896565b60006124ad836001600160a01b0384166138fb565b6000818152600460205260408120546001600160a01b0316156131585760405162461bcd60e51b815260206004820152601960248201527f4d696e7420666f72206578697374696e6720746f6b656e4964000000000000006044820152606401610ec6565b606482111580156131695750600082115b6131855760405162461bcd60e51b8152600401610ec6906147f1565b6000828152601f602052604090205460ff166131e35760405162461bcd60e51b815260206004820152601e60248201527f4e6f206164647265737320617661696c61626c6520666f7220746f6b656e00006044820152606401610ec6565b6000828152601e6020908152604080832054602490925290912080546001600160a01b0319166001600160a01b039092169182179055613223818461387c565b505060408051602080820183524282526000848152602682528381209251909255602190529081205590565b600c5460ff166132985760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610ec6565b600c805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60006132ed82612005565b90506132fb8160008461380d565b613306600083612b79565b6001600160a01b038116600090815260056020526040812080546001929061332f908490614969565b909155505060008281526004602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6001600160a01b0382166133df5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610ec6565b6000818152600460205260409020546001600160a01b0316156134445760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610ec6565b6134506000838361380d565b6001600160a01b038216600090815260056020526040812080546001929061347990849061491e565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600c5460ff161561351d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610ec6565b600c805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586132c53390565b60006124ad8383613a18565b613569848484612d78565b61357584848484613a50565b6110235760405162461bcd60e51b8152600401610ec69061479f565b6060600f805461104b906149c3565b6060601d805461104b906149c3565b6060816135d457506040805180820190915260018152600360fc1b6020820152611037565b8160005b81156135fe57806135e8816149fe565b91506135f79050600a83614936565b91506135d8565b60008167ffffffffffffffff81111561362757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613651576020820181803683370190505b5090505b8415612d7057613666600183614969565b9150613673600a86614a19565b61367e90603061491e565b60f81b8183815181106136a157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506136c3600a86614936565b9450613655565b6000611034825490565b6000828152602081905260409020600101546136f08133612f3b565b6112a98383613896565b613704828261250f565b61168c576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905561373a3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008181526001830160205260408120546137c55750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561142e565b50600061142e565b60006001600160e01b031982166380ac58cd60e01b14806137fe57506001600160e01b03198216635b5e139f60e01b145b80611034575061103482613b5d565b6112a9838383613b82565b613822828261250f565b61168c5761383a816001600160a01b03166014613bf4565b613845836020613bf4565b604051602001613856929190614655565b60408051601f198184030181529082905262461bcd60e51b8252610ec69160040161478c565b61168c828260405180602001604052806000815250613dd6565b6138a0828261250f565b1561168c576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008181526001830160205260408120548015613a0e57600061391f600183614969565b855490915060009061393390600190614969565b90508181146139b457600086600001828154811061396157634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508087600001848154811061399257634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b85548690806139d357634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061142e565b600091505061142e565b6000826000018281548110613a3d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60006001600160a01b0384163b15613b5257604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613a949033908990889088906004016146ca565b602060405180830381600087803b158015613aae57600080fd5b505af1925050508015613ade575060408051601f3d908101601f19168201909252613adb9181019061455c565b60015b613b38573d808015613b0c576040519150601f19603f3d011682016040523d82523d6000602084013e613b11565b606091505b508051613b305760405162461bcd60e51b8152600401610ec69061479f565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612d70565b506001949350505050565b60006001600160e01b03198216635a05180f60e01b1480611034575061103482613e09565b613b8d838383613e3e565b600c5460ff16156112a95760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b6064820152608401610ec6565b60606000613c0383600261494a565b613c0e90600261491e565b67ffffffffffffffff811115613c3457634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613c5e576020820181803683370190505b509050600360fc1b81600081518110613c8757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613cc457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000613ce884600261494a565b613cf390600161491e565b90505b6001811115613d87576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613d3557634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110613d5957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93613d80816149ac565b9050613cf6565b5083156124ad5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610ec6565b613de08383613389565b613ded6000848484613a50565b6112a95760405162461bcd60e51b8152600401610ec69061479f565b60006001600160e01b03198216637965db0b60e01b148061103457506301ffc9a760e01b6001600160e01b0319831614611034565b6001600160a01b038316613e9957613e9481600a80546000838152600b60205260408120829055600182018355919091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80155565b613ebc565b816001600160a01b0316836001600160a01b031614613ebc57613ebc8382613efb565b6001600160a01b038216613ed857613ed381613f98565b6112a9565b826001600160a01b0316826001600160a01b0316146112a9576112a98282614071565b60006001613f088461227d565b613f129190614969565b600083815260096020526040902054909150808214613f65576001600160a01b03841660009081526008602090815260408083208584528252808320548484528184208190558352600990915290208190555b5060009182526009602090815260408084208490556001600160a01b039094168352600881528383209183525290812055565b600a54600090613faa90600190614969565b6000838152600b6020526040812054600a8054939450909284908110613fe057634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600a838154811061400f57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152600b9091526040808220849055858252812055600a80548061405557634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061407c8361227d565b6001600160a01b039093166000908152600860209081526040808320868452825280832085905593825260099052919091209190915550565b8280546140c1906149c3565b90600052602060002090601f0160209004810192826140e35760008555614129565b82601f106140fc57805160ff1916838001178555614129565b82800160010185558215614129579182015b8281111561412957825182559160200191906001019061410e565b50614135929150614139565b5090565b5b80821115614135576000815560010161413a565b600067ffffffffffffffff83111561416857614168614a59565b61417b601f8401601f19166020016148c9565b905082815283838301111561418f57600080fd5b828260208301376000602084830101529392505050565b600082601f8301126141b6578081fd5b813560206141cb6141c6836148fa565b6148c9565b80838252828201915082860187848660051b89010111156141ea578586fd5b855b858110156142115781356141ff81614a6f565b845292840192908401906001016141ec565b5090979650505050505050565b600082601f83011261422e578081fd5b8135602061423e6141c6836148fa565b80838252828201915082860187848660051b890101111561425d578586fd5b855b858110156142115781358452928401929084019060010161425f565b60006020828403121561428c578081fd5b81356124ad81614a6f565b600080604083850312156142a9578081fd5b82356142b481614a6f565b915060208301356142c481614a6f565b809150509250929050565b6000806000606084860312156142e3578081fd5b83356142ee81614a6f565b925060208401356142fe81614a6f565b929592945050506040919091013590565b60008060008060808587031215614324578081fd5b843561432f81614a6f565b9350602085013561433f81614a6f565b925060408501359150606085013567ffffffffffffffff811115614361578182fd5b8501601f81018713614371578182fd5b6143808782356020840161414e565b91505092959194509250565b6000806040838503121561439e578182fd5b82356143a981614a6f565b915060208301356142c481614a84565b600080604083850312156143cb578182fd5b82356143d681614a6f565b946020939093013593505050565b6000602082840312156143f5578081fd5b813567ffffffffffffffff81111561440b578182fd5b612d70848285016141a6565b60008060408385031215614429578182fd5b823567ffffffffffffffff80821115614440578384fd5b61444c868387016141a6565b93506020850135915080821115614461578283fd5b5061446e8582860161421e565b9150509250929050565b600060208284031215614489578081fd5b813567ffffffffffffffff81111561449f578182fd5b612d708482850161421e565b6000602082840312156144bc578081fd5b81356124ad81614a84565b6000602082840312156144d8578081fd5b81516124ad81614a84565b6000602082840312156144f4578081fd5b5035919050565b6000806040838503121561450d578182fd5b8235915060208301356142c481614a6f565b60008060408385031215614531578182fd5b50508035926020909101359150565b600060208284031215614551578081fd5b81356124ad81614a92565b60006020828403121561456d578081fd5b81516124ad81614a92565b600060208284031215614589578081fd5b813567ffffffffffffffff81111561459f578182fd5b8201601f810184136145af578182fd5b612d708482356020840161414e565b6000602082840312156145cf578081fd5b5051919050565b600081518084526145ee816020860160208601614980565b601f01601f19169290920160200192915050565b60008451614614818460208901614980565b845190830190614628818360208901614980565b845191019061463b818360208801614980565b64173539b7b760d91b910190815260050195945050505050565b60007f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008252835161468d816017850160208801614980565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516146be816028840160208801614980565b01602801949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906146fd908301846145d6565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156147485783516001600160a01b031683529284019291840191600101614723565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561474857835183529284019291840191600101614770565b6000602082526124ad60208301846145d6565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526030908201527f4572726f723a204d6178696d756d206e756d626572206f6620746f6b656e732060408201526f1a185d99481899595b881b5a5b9d195960821b606082015260800190565b60208082526019908201527f4572726f723a20416374696f6e204e6f7420416c6c6f77656400000000000000604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff811182821017156148f2576148f2614a59565b604052919050565b600067ffffffffffffffff82111561491457614914614a59565b5060051b60200190565b6000821982111561493157614931614a2d565b500190565b60008261494557614945614a43565b500490565b600081600019048311821515161561496457614964614a2d565b500290565b60008282101561497b5761497b614a2d565b500390565b60005b8381101561499b578181015183820152602001614983565b838111156110235750506000910152565b6000816149bb576149bb614a2d565b506000190190565b600181811c908216806149d757607f821691505b602082108114156149f857634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415614a1257614a12614a2d565b5060010190565b600082614a2857614a28614a43565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146112fa57600080fd5b80151581146112fa57600080fd5b6001600160e01b0319811681146112fa57600080fdfea2646970667358221220320e00f51cae994f6af3e7e09015f59d4469656f2fca5e21f78342ecc59278e564736f6c63430008030033

Verified Source Code Partial Match

Compiler: v0.8.3+commit.8d00100c EVM: istanbul Optimization: Yes (200 runs)
GiraffeTower.sol 385 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.8 <0.9.0;

import "@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract GiraffeTower is ERC721PresetMinterPauserAutoId {
    string private _currentBaseURI;
    bool public preSaleStatus;
    bool public mainSaleStatus;
    address private ownerAddress;
    uint256 public round;
    uint256 public preSaleCount = 0;
    uint256 public publicSaleCount = 0;
    uint256 public stotalSupply = 100;
    uint256 public maxItemsPerPreSale = 5; // Mutable by owner
    uint256 public preSaleMaxItems = 3000;
    uint256 public mintPrice = 0.05 ether;
    uint256 public maxItemsPerTx = 5; // Mutable by owner
    uint256 public adoptionsCount = 800;
    uint256 public OgsCount = 100;
    uint256 totalDividends = 0;
    using Address for address;
    uint256 private maxToken;
    string private _currentGatewayURI;
    bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;
    mapping(uint256 => address) public Ogs; //Maps address to their tokenId
    mapping(uint256 => bool) public addressExist; //Stores if address exist;
    mapping(address => uint256) public preMints; // Maps address to how many they can premint
    mapping(uint256 => uint256) tokenRound;
    mapping(uint256 => uint256) tokenAdoption;
    mapping(uint256 => uint256) staticTokenAdoption;
    mapping(uint256 => address) public genesisAddress;
    event Mint(address indexed owner, uint256 indexed tokenId);
    event Received(address, uint256);
    uint256 ownerRoyalty = 0;
    struct Giraffe {
        uint256 birthday;
    }
    mapping(uint256 => Giraffe) public giraffes;

    constructor()
        ERC721PresetMinterPauserAutoId(
            "Giraffe Tower",
            "GT",
            "https://ipfs.io/ipfs/QmUtvDXWka1wSJkPFWMGtVv2K6fRPcVLxZQkqinpBqjPWv/"
        )
    {
        ownerAddress = msg.sender;
        maxToken = 10000;
        setGateway("https://ipfs.io/ipfs/");
        preSaleStatus = false;
        mainSaleStatus = false;
    }

    function owner() public view returns (address) {
        return ownerAddress;
    }

    function _ownerRoyalty() public view returns (uint256) {
        return ownerRoyalty;
    }

    receive() external payable {
        emit Received(msg.sender, msg.value);
        uint256 tt = msg.value / 100;
        totalDividends += tt;
        uint256 ot = msg.value - tt;
        ownerRoyalty += ot;
    }

    function withdrawReward(uint256 tokenId) external {
        require(ownerOf(tokenId) == msg.sender && tokenId <= 100, "WR:Invalid");
        uint256 total = (totalDividends - tokenRound[tokenId]) / OgsCount;
        require(total > 0,"Too Low");
        tokenRound[tokenId] = totalDividends;
        sendEth(msg.sender, total);
    }

    function withdrawAllReward() external {
        address _address = msg.sender;
        uint256[] memory _tokensOwned = walletOfOwner(_address);
        uint256 totalClaim;
        for (uint256 i; i < _tokensOwned.length; i++) {
            if (_tokensOwned[i] <= 100) {
                totalClaim +=
                    (totalDividends - tokenRound[_tokensOwned[i]]) /
                    OgsCount;
                tokenRound[_tokensOwned[i]] = totalDividends;
            }
        }
        require(totalClaim > 0, "WAR: LTC");
        sendEth(msg.sender, totalClaim);
    }

    function withdrawRoyalty() external ownerOnly {
        require(ownerRoyalty > 0, "WRLTY:Invalid");
        uint256 total = ownerRoyalty;
        ownerRoyalty = 0;
        sendEth(msg.sender, total);
    }

    function preSale() external payable {
        require(preSaleStatus, "preSale: Paused");
        require(msg.sender == tx.origin, "Not Allowed");
        uint256 remainder = msg.value % mintPrice;
        uint256 amount = msg.value / mintPrice;
        require(msg.value > 0, "preSale: Invalid Value");
        require(remainder == 0, "preSale: Send a divisible amount of eth");
        require(
            preSaleCount + amount <= preSaleMaxItems,
            "preSale: Surpasses cap"
        );
        require(
            amount <= preMints[msg.sender],
            "preSale: Amount greater than allocation"
        );
        preSaleCount += amount;
        preMints[msg.sender] -= amount;
        _mintWithoutValidation(msg.sender, amount);
    }

    function adoptionMint() external {
        uint256 tokenCount = balanceOf(msg.sender);
        require(tokenCount > 0, "adoptionMint: You don't own any token");
        for (uint256 i; i < tokenCount; i++) {
            uint256 tokenid = tokenOfOwnerByIndex(msg.sender, i);
            if (tokenid <= 100) {
                uint256 adoptions = tokenAdoption[tokenid];
                if (adoptions > 0) {
                    tokenAdoption[tokenid] -= adoptions;
                    _mintWithoutValidation(msg.sender, adoptions);
                }
            }
        }
    }

    function _mintWithoutValidation(address to, uint256 amount) internal {
        require(totalSupply() < maxToken,"Mint: Surpasses cap");
        for (uint256 i = 0; i < amount; i++) {
            stotalSupply += 1;
            genesisAddress[stotalSupply] = to;
            _safeMint(to, stotalSupply);
            tokenRound[stotalSupply] = 0;
            // _mint(to, totalSupply);
            giraffes[stotalSupply] = Giraffe(block.timestamp);
            emit Mint(to, stotalSupply);
        }
    }

    function publicSale() external payable {
        require(mainSaleStatus, "publicMint: Paused");
        require(msg.sender == tx.origin, "Not Allowed");
        uint256 remainder = msg.value % mintPrice;
        uint256 amount = msg.value / mintPrice;
        require(remainder == 0, "publicMint: Send a divisible amount of eth");
        require(msg.value > 0, "publicMint: Invalid Value");
        require(amount <= maxItemsPerTx, "publicMint: Max 5 per tx");

        require(
            OgsCount + adoptionsCount + preSaleCount + publicSaleCount + amount <= maxToken,
            "publicMint: Surpasses cap"
        );
        publicSaleCount += amount;
        _mintWithoutValidation(msg.sender, amount);
    }

    function _baseURI() internal view virtual override returns (string memory) {
        return _currentBaseURI;
    }

    function _gatewayURI() internal view virtual returns (string memory) {
        return _currentGatewayURI;
    }

    function tokenURI(uint256 tokenId)
        public
        view
        virtual
        override
        returns (string memory)
    {
        require(
            _exists(tokenId),
            "ERC721Metadata: URI query for nonexistent token"
        );

        // string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = _baseURI();
        string memory gateway = _gatewayURI();

        return
            string(
                abi.encodePacked(
                    gateway,
                    base,
                    Strings.toString(tokenId),
                    ".json"
                )
            );
    }

    // ADMIN FUNCTIONALITY
    function setGateway(string memory gatewayURI) public ownerOnly {
        _currentGatewayURI = gatewayURI;
    }

    /**
     * @dev Transfers ownership
     * @param _newOwner The new owner
     */
    function transferOwnership(address _newOwner) public ownerOnly {
        ownerAddress = _newOwner;
    }

    function setPresaleStatus(bool ps) public ownerOnly {
        preSaleStatus = ps;
    }

    function setMainsaleStatus(bool ms) public ownerOnly {
        mainSaleStatus = ms;
    }

    function setMintPrice(uint256 mp) public ownerOnly {
        mintPrice = mp;
    }

    function setMaxItemsPerTx(uint256 _maxItemsPerTx) external ownerOnly {
        maxItemsPerTx = _maxItemsPerTx;
    }

    function setMaxItemsPerPreSale(uint256 _maxItemsPerPreSale)
        external
        ownerOnly
    {
        maxItemsPerPreSale = _maxItemsPerPreSale;
    }

    function addToWhitelist(address[] memory toAdd) external ownerOnly {
        for (uint256 i = 0; i < toAdd.length; i++) {
            preMints[toAdd[i]] = maxItemsPerPreSale;
        }
    }

    function setAdoptions(uint256[] memory adoptions) external ownerOnly {
        for (uint256 i = 0; i < adoptions.length; i++) {
            tokenAdoption[i + 1] = adoptions[i];
            staticTokenAdoption[i + 1] = adoptions[i];
        }
    }

    function setBaseURI(string memory baseURI) external ownerOnly {
        _currentBaseURI = baseURI;
    }

    function addToOg(address[] memory toAdd, uint256[] memory pick)
        external
        ownerOnly
    {
        for (uint256 i = 0; i < toAdd.length; i++) {
            Ogs[pick[i]] = toAdd[i];
            addressExist[pick[i]] = true;
            // preMints[toAdd[i]] = maxItemsPerPreMint;
        }
    }

    function ogbulkMint(uint256[] memory pick) external {
        for (uint256 i = 0; i < pick.length; i++) {
            require(
                pick[i] <= 100 && pick[i] > 0,
                "Error: Maximum number of tokens have been minted"
            );
            _ogmintToken(pick[i]);
        }
    }

    function ogsingleMint(uint256 pick) external {
        require(
            pick <= 100 && pick > 0,
            "Error: Maximum number of tokens have been minted"
        );
        _ogmintToken(pick);
    }

    modifier ownerOnly() {
        require(msg.sender == ownerAddress, "Error: Action Not Allowed");
        _;
    }

    //Internal

    function _ogmintToken(uint256 pick) private returns (uint256) {
        //Check if token has been minted
        require(!_exists(pick), "Mint for existing tokenId");
        require(
            pick <= 100 && pick > 0,
            "Error: Maximum number of tokens have been minted"
        );
        //check if address exist
        require(addressExist[pick], "No address available for token");
        address recipient = Ogs[pick];
        // Mint token to PickOwner
        genesisAddress[pick] = recipient;
        _safeMint(recipient, pick);
        giraffes[pick] = Giraffe(block.timestamp);
        tokenRound[pick] = 0;
        return pick;
    }

    function getOgs() public view returns (address[] memory) {
        address[] memory ogs = new address[](101);
        for (uint256 i = 0; i <= 100; i++) {
            ogs[i] = Ogs[i];
        }
        return ogs;
    }

    function getGenesisAddresses() public view returns (address[] memory) {
        address[] memory ga = new address[](10001);
        for (uint256 i = 0; i <= 10000; i++) {
            ga[i] = genesisAddress[i];
        }
        return ga;
    }

    function getGenesisAddress(uint256 token_id) public view returns (address) {
        return genesisAddress[token_id];
    }

    function walletOfOwner(address _owner)
        public
        view
        returns (uint256[] memory)
    {
        uint256 tokenCount = balanceOf(_owner);

        uint256[] memory tokensId = new uint256[](tokenCount);
        for (uint256 i; i < tokenCount; i++) {
            tokensId[i] = tokenOfOwnerByIndex(_owner, i);
        }
        return tokensId;
    }

    function rewardBalance(uint256 tokenId) public view returns (uint256) {
        //    require(ownerOf(tokenId) == msg.sender && tokenId < 100 , "WR:Invalid");
        uint256 total = (totalDividends - tokenRound[tokenId]) / OgsCount;
        return total;
    }

    function adoptionsOfOwner(address _owner)
        public
        view
        returns (uint256[] memory)
    {
        uint256 tokenCount = balanceOf(_owner);

        uint256[] memory tokensId = new uint256[](tokenCount);
        for (uint256 i; i < tokenCount; i++) {
            tokensId[i] = tokenAdoption[tokenOfOwnerByIndex(_owner, i)];
        }
        return tokensId;
    }

    function withdrawFunds(uint256 amount) public ownerOnly {
        sendEth(ownerAddress, amount);
    }

    function sendEth(address to, uint256 amount) internal {
        (bool success, ) = to.call{value: amount}("");
        require(success, "Failed to send ether");
    }

    function withdrawToken(
        IERC20 token,
        address recipient,
        uint256 amount
    ) public ownerOnly {
        require(
            token.balanceOf(address(this)) >= amount,
            "You do not have sufficient Balance"
        );
        token.transfer(recipient, amount);
    }
}
Address.sol 216 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
Context.sol 23 lines
// SPDX-License-Identifier: MIT

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;
    }
}
Strings.sol 66 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}
Counters.sol 42 lines
// SPDX-License-Identifier: MIT

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;
    }
}
Pausable.sol 90 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
IERC20.sol 81 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}
ERC721.sol 411 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_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 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 {}
}
AccessControl.sol 210 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
IERC721.sol 142 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;
}
IAccessControl.sol 87 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}
ERC165.sol 28 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
IERC165.sol 24 lines
// SPDX-License-Identifier: MIT

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);
}
EnumerableSet.sol 356 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}
IERC721Receiver.sol 26 lines
// SPDX-License-Identifier: MIT

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);
}
AccessControlEnumerable.sol 79 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {grantRole} to track enumerable memberships
     */
    function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        super.grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {revokeRole} to track enumerable memberships
     */
    function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        super.revokeRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {renounceRole} to track enumerable memberships
     */
    function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        super.renounceRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {_setupRole} to track enumerable memberships
     */
    function _setupRole(bytes32 role, address account) internal virtual override {
        super._setupRole(role, account);
        _roleMembers[role].add(account);
    }
}
IAccessControlEnumerable.sol 30 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
ERC721Burnable.sol 25 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "../../../utils/Context.sol";

/**
 * @title ERC721 Burnable Token
 * @dev ERC721 Token that can be irreversibly burned (destroyed).
 */
abstract contract ERC721Burnable is Context, ERC721 {
    /**
     * @dev Burns `tokenId`. See {ERC721-_burn}.
     *
     * Requirements:
     *
     * - The caller must own `tokenId` or be an approved operator.
     */
    function burn(uint256 tokenId) public virtual {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved");
        _burn(tokenId);
    }
}
ERC721Pausable.sol 32 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "../../../security/Pausable.sol";

/**
 * @dev ERC721 token with pausable token transfers, minting and burning.
 *
 * Useful for scenarios such as preventing trades until the end of an evaluation
 * period, or having an emergency switch for freezing all token transfers in the
 * event of a large bug.
 */
abstract contract ERC721Pausable is ERC721, Pausable {
    /**
     * @dev See {ERC721-_beforeTokenTransfer}.
     *
     * Requirements:
     *
     * - the contract must not be paused.
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, tokenId);

        require(!paused(), "ERC721Pausable: token transfer while paused");
    }
}
IERC721Metadata.sol 26 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}
ERC721Enumerable.sol 162 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @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` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * 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 override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}
IERC721Enumerable.sol 28 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}
ERC721PresetMinterPauserAutoId.sol 136 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "../extensions/ERC721Enumerable.sol";
import "../extensions/ERC721Burnable.sol";
import "../extensions/ERC721Pausable.sol";
import "../../../access/AccessControlEnumerable.sol";
import "../../../utils/Context.sol";
import "../../../utils/Counters.sol";

/**
 * @dev {ERC721} token, including:
 *
 *  - ability for holders to burn (destroy) their tokens
 *  - a minter role that allows for token minting (creation)
 *  - a pauser role that allows to stop all token transfers
 *  - token ID and URI autogeneration
 *
 * This contract uses {AccessControl} to lock permissioned functions using the
 * different roles - head to its documentation for details.
 *
 * The account that deploys the contract will be granted the minter and pauser
 * roles, as well as the default admin role, which will let it grant both minter
 * and pauser roles to other accounts.
 */
contract ERC721PresetMinterPauserAutoId is
    Context,
    AccessControlEnumerable,
    ERC721Enumerable,
    ERC721Burnable,
    ERC721Pausable
{
    using Counters for Counters.Counter;

    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

    Counters.Counter private _tokenIdTracker;

    string private _baseTokenURI;

    /**
     * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the
     * account that deploys the contract.
     *
     * Token URIs will be autogenerated based on `baseURI` and their token IDs.
     * See {ERC721-tokenURI}.
     */
    constructor(
        string memory name,
        string memory symbol,
        string memory baseTokenURI
    ) ERC721(name, symbol) {
        _baseTokenURI = baseTokenURI;

        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());

        _setupRole(MINTER_ROLE, _msgSender());
        _setupRole(PAUSER_ROLE, _msgSender());
    }

    function _baseURI() internal view virtual override returns (string memory) {
        return _baseTokenURI;
    }

    /**
     * @dev Creates a new token for `to`. Its token ID will be automatically
     * assigned (and available on the emitted {IERC721-Transfer} event), and the token
     * URI autogenerated based on the base URI passed at construction.
     *
     * See {ERC721-_mint}.
     *
     * Requirements:
     *
     * - the caller must have the `MINTER_ROLE`.
     */
    function mint(address to) public virtual {
        require(hasRole(MINTER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have minter role to mint");

        // We cannot just use balanceOf to create the new tokenId because tokens
        // can be burned (destroyed), so we need a separate counter.
        _mint(to, _tokenIdTracker.current());
        _tokenIdTracker.increment();
    }

    /**
     * @dev Pauses all token transfers.
     *
     * See {ERC721Pausable} and {Pausable-_pause}.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function pause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have pauser role to pause");
        _pause();
    }

    /**
     * @dev Unpauses all token transfers.
     *
     * See {ERC721Pausable} and {Pausable-_unpause}.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function unpause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have pauser role to unpause");
        _unpause();
    }

    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
        super._beforeTokenTransfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(AccessControlEnumerable, ERC721, ERC721Enumerable)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}

Read Contract

DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MINTER_ROLE 0xd5391393 → bytes32
Ogs 0x833ef823 → address
OgsCount 0xc986cb30 → uint256
PAUSER_ROLE 0xe63ab1e9 → bytes32
_ownerRoyalty 0x8bac9ff3 → uint256
addressExist 0x6824a704 → bool
adoptionsCount 0x687de78d → uint256
adoptionsOfOwner 0x4213c7b3 → uint256[]
balanceOf 0x70a08231 → uint256
genesisAddress 0x457621f6 → address
getApproved 0x081812fc → address
getGenesisAddress 0x5328302f → address
getGenesisAddresses 0x48b0ccf4 → address[]
getOgs 0xd42457cb → address[]
getRoleAdmin 0x248a9ca3 → bytes32
getRoleMember 0x9010d07c → address
getRoleMemberCount 0xca15c873 → uint256
giraffes 0xe4dc70ff → uint256
hasRole 0x91d14854 → bool
isApprovedForAll 0xe985e9c5 → bool
mainSaleStatus 0x9c0abd69 → bool
maxItemsPerPreSale 0xe7e98724 → uint256
maxItemsPerTx 0x30666a4d → uint256
mintPrice 0x6817c76c → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
preMints 0x1365b277 → uint256
preSaleCount 0xde0ec164 → uint256
preSaleMaxItems 0xe53f2fb1 → uint256
preSaleStatus 0x464bd640 → bool
publicSaleCount 0x6a2b477f → uint256
rewardBalance 0x86e3ff75 → uint256
round 0x146ca531 → uint256
stotalSupply 0x22d8882c → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
walletOfOwner 0x438b6300 → uint256[]

Write Contract 33 functions

These functions modify contract state and require a wallet transaction to execute.

addToOg 0xad225a9f
address[] toAdd
uint256[] pick
addToWhitelist 0x7f649783
address[] toAdd
adoptionMint 0x50372e72
No parameters
approve 0x095ea7b3
address to
uint256 tokenId
burn 0x42966c68
uint256 tokenId
grantRole 0x2f2ff15d
bytes32 role
address account
mint 0x6a627842
address to
ogbulkMint 0x3b3a7f62
uint256[] pick
ogsingleMint 0x3ddb3cfb
uint256 pick
pause 0x8456cb59
No parameters
preSale 0x5a7adf7f
No parameters
publicSale 0x33bc1c5c
No parameters
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setAdoptions 0xa9101952
uint256[] adoptions
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string baseURI
setGateway 0xe44a2d70
string gatewayURI
setMainsaleStatus 0x21f4697d
bool ms
setMaxItemsPerPreSale 0x07008490
uint256 _maxItemsPerPreSale
setMaxItemsPerTx 0x7a4e5715
uint256 _maxItemsPerTx
setMintPrice 0xf4a0a528
uint256 mp
setPresaleStatus 0x8895283f
bool ps
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address _newOwner
unpause 0x3f4ba83a
No parameters
withdrawAllReward 0x6b37fbaa
No parameters
withdrawFunds 0x155dd5ee
uint256 amount
withdrawReward 0x523a3f08
uint256 tokenId
withdrawRoyalty 0xf1147bae
No parameters
withdrawToken 0x01e33667
address token
address recipient
uint256 amount

Recent Transactions

No transactions found for this address