Address Contract Verified
Address
0xD4c3c23349348FA67f6D044F1357c54d8e6a661B
Balance
0 ETH
Nonce
1
Code Size
11517 bytes
Creator
0xb63f1425...9869 at tx 0xd3be4ea6...245da8
Indexed Transactions
0
Contract Bytecode
11517 bytes
0x608060405234801561001057600080fd5b50600436106102745760003560e01c80636c0360eb11610151578063c6ec6909116100c3578063d5abeb0111610087578063d5abeb0114610580578063db4bec4414610589578063e8a3d485146105ac578063e985e9c5146105b4578063f053d370146105f0578063f2fde38b146105fd57600080fd5b8063c6ec69091461051b578063c839fe9414610524578063c87b56dd14610537578063c971e4281461054a578063cd6a33791461055d57600080fd5b8063938e3d7b11610115578063938e3d7b146104a757806395d89b41146104ba578063a22cb465146104c2578063aa332533146104d5578063afc3cb49146104f5578063b88d4fde1461050857600080fd5b80636c0360eb1461046057806370a0823114610468578063715018a61461047b5780637ef2750e146104835780638da5cb5b1461049657600080fd5b80632a55205a116101ea5780634d155561116101ae5780634d1555611461040957806355f804b3146104125780635c975abb1461042557806360b02f70146104325780636352211e14610445578063639d7e111461045857600080fd5b80632a55205a1461039c5780633009c083146103ce57806337c3fdbc146103e65780633a367a67146103ee57806342842e0e146103f657600080fd5b806310fd332b1161023c57806310fd332b1461030957806318160ddd1461031c5780631dfcaa481461032e5780631f0a8fa714610363578063238ac9331461037657806323b872dd1461038957600080fd5b806301ffc9a71461027957806302329a29146102a157806306fdde03146102b6578063081812fc146102cb578063095ea7b3146102f6575b600080fd5b61028c610287366004612761565b610610565b60405190151581526020015b60405180910390f35b6102b46102af366004612746565b610656565b005b6102be61069c565b60405161029891906129d5565b6102de6102d93660046127e4565b61072e565b6040516001600160a01b039091168152602001610298565b6102b461030436600461256d565b6107c3565b6102b461031736600461256d565b6108d9565b600c545b604051908152602001610298565b61035161033c3660046123c8565b60116020526000908152604090205460ff1681565b60405160ff9091168152602001610298565b61028c61037136600461251d565b61092f565b600f546102de906001600160a01b031681565b6102b461039736600461243b565b61099f565b6103af6103aa36600461283b565b6109d0565b604080516001600160a01b039093168352602083019190915201610298565b6013546102de9061010090046001600160a01b031681565b6102b4610a10565b6102be610a49565b6102b461040436600461243b565b610ad7565b610320600e5481565b6102b461042036600461279b565b610af2565b60135461028c9060ff1681565b6102b4610440366004612816565b610b43565b6102de6104533660046127e4565b610c18565b6102be610c8f565b6102be610c9c565b6103206104763660046123c8565b610ca9565b6102b4610d30565b61028c6104913660046125ce565b610d66565b6006546001600160a01b03166102de565b6102b46104b536600461279b565b610dcd565b6102be610e0a565b6102b46104d03660046124e8565b610e19565b6104e86104e33660046123c8565b610ede565b6040516102989190612991565b6102b46105033660046127e4565b6110a3565b6102b461051636600461247c565b6110d2565b61032060145481565b6104e8610532366004612599565b611104565b6102be6105453660046127e4565b6111f9565b6102b461055836600461262e565b61134e565b61035161056b3660046127e4565b60106020526000908152604090205460ff1681565b610320600d5481565b6103516105973660046123c8565b60126020526000908152604090205460ff1681565b6102be6116e3565b61028c6105c2366004612402565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600b5461028c9060ff1681565b6102b461060b3660046123c8565b61170b565b600063e8a3d48560e01b6001600160e01b031983161480610641575063152a902d60e11b6001600160e01b03198316145b806106505750610650826117a6565b92915050565b6006546001600160a01b031633146106895760405162461bcd60e51b815260040161068090612a3a565b60405180910390fd5b6013805460ff1916911515919091179055565b6060600080546106ab90612ba4565b80601f01602080910402602001604051908101604052809291908181526020018280546106d790612ba4565b80156107245780601f106106f957610100808354040283529160200191610724565b820191906000526020600020905b81548152906001019060200180831161070757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107a75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610680565b506000908152600460205260409020546001600160a01b031690565b60006107ce82610c18565b9050806001600160a01b0316836001600160a01b0316141561083c5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610680565b336001600160a01b0382161480610858575061085881336105c2565b6108ca5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610680565b6108d483836117f6565b505050565b6006546001600160a01b031633146109035760405162461bcd60e51b815260040161068090612a3a565b601380546001600160a01b0390931661010002610100600160a81b031990931692909217909155601455565b6040516115d360f21b60208201526bffffffffffffffffffffffff19606084901b1660228201526000906109879083906036015b6040516020818303038152906040528051906020012061186490919063ffffffff16565b600f546001600160a01b039182169116149392505050565b6109a93382611888565b6109c55760405162461bcd60e51b815260040161068090612a6f565b6108d483838361197f565b600080601360019054906101000a90046001600160a01b0316612710601454856109fa9190612b42565b610a049190612b2e565b915091505b9250929050565b6006546001600160a01b03163314610a3a5760405162461bcd60e51b815260040161068090612a3a565b600b805460ff19166001179055565b60098054610a5690612ba4565b80601f0160208091040260200160405190810160405280929190818152602001828054610a8290612ba4565b8015610acf5780601f10610aa457610100808354040283529160200191610acf565b820191906000526020600020905b815481529060010190602001808311610ab257829003601f168201915b505050505081565b6108d4838383604051806020016040528060008152506110d2565b6006546001600160a01b03163314610b1c5760405162461bcd60e51b815260040161068090612a3a565b600b5460ff1615610b2c57600080fd5b8051610b3f906008906020840190612291565b5050565b6006546001600160a01b03163314610b6d5760405162461bcd60e51b815260040161068090612a3a565b6000610b78600c5490565b600d54909150610b888483612af1565b1115610bcb5760405162461bcd60e51b81526020600482015260126024820152711b585e081cdd5c1c1b1e481c995858da195960721b6044820152606401610680565b82600c6000828254610bdd9190612af1565b90915550600190505b838111610c1257610c0083610bfb8385612af1565b611b1f565b80610c0a81612bdf565b915050610be6565b50505050565b6000818152600260205260408120546001600160a01b0316806106505760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610680565b600a8054610a5690612ba4565b60088054610a5690612ba4565b60006001600160a01b038216610d145760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610680565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610d5a5760405162461bcd60e51b815260040161068090612a3a565b610d646000611b39565b565b604051614f4760f01b60208201526bffffffffffffffffffffffff19606085901b1660228201526001600160f81b031960f884901b166036820152600090610db2908390603701610963565b600f546001600160a01b0390811691161490505b9392505050565b6006546001600160a01b03163314610df75760405162461bcd60e51b815260040161068090612a3a565b8051610b3f90600a906020840190612291565b6060600180546106ab90612ba4565b6001600160a01b038216331415610e725760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610680565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6007546040516370a0823160e01b81526001600160a01b0383811660048301526060926000929116906370a082319060240160206040518083038186803b158015610f2857600080fd5b505afa158015610f3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6091906127fd565b905060008167ffffffffffffffff811115610f7d57610f7d612c86565b604051908082528060200260200182016040528015610fa6578160200160208202803683370190505b5090506000805b8381101561109957600754604051632f745c5960e01b81526001600160a01b038881166004830152602482018490526000921690632f745c599060440160206040518083038186803b15801561100257600080fd5b505afa158015611016573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103a91906127fd565b600e5460008281526010602052604090205491925060ff9091161015611086578084848151811061106d5761106d612c70565b60209081029190910101528261108281612bdf565b9350505b508061109181612bdf565b915050610fad565b5090949350505050565b6006546001600160a01b031633146110cd5760405162461bcd60e51b815260040161068090612a3a565b600e55565b6110dc3383611888565b6110f85760405162461bcd60e51b815260040161068090612a6f565b610c1284848484611b8b565b6060600061111185610ca9565b90508061112e575050604080516000815260208101909152610dc6565b60008167ffffffffffffffff81111561114957611149612c86565b604051908082528060200260200182016040528015611172578160200160208202803683370190505b5090506000855b8581116111ed578382141561118d576111ed565b876001600160a01b03166111a082610c18565b6001600160a01b031614156111db57808383815181106111c2576111c2612c70565b6020908102919091010152816111d781612bdf565b9250505b806111e581612bdf565b915050611179565b50819350505050610dc6565b6000818152600260205260409020546060906001600160a01b03166112785760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610680565b6000611282611bbe565b9050600081511161131d576009805461129a90612ba4565b80601f01602080910402602001604051908101604052809291908181526020018280546112c690612ba4565b80156113135780601f106112e857610100808354040283529160200191611313565b820191906000526020600020905b8154815290600101906020018083116112f657829003601f168201915b5050505050610dc6565b8061132784611bcd565b604051602001611338929190612889565b6040516020818303038152906040529392505050565b60135460ff161561135e57600080fd5b6000611369600c5490565b90506000805b87518110156114e957600088828151811061138c5761138c612c70565b60209081029190910101516007546040516331a9108f60e11b81526004810183905291925033916001600160a01b0390911690636352211e9060240160206040518083038186803b1580156113e057600080fd5b505afa1580156113f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061141891906123e5565b6001600160a01b03161480156114405750600e5460008281526010602052604090205460ff16105b1561148e576000818152601060205260408120805460ff169161146283612bfa565b91906101000a81548160ff021916908360ff16021790555050828061148690612bdf565b9350506114d6565b60405162461bcd60e51b815260206004820152601960248201527f696420646f65736e742062656c6f6e6720746f206f776e6572000000000000006044820152606401610680565b50806114e181612bdf565b91505061136f565b50600084511180156115015750611501338686610d66565b80156115205750600e543360009081526011602052604090205460ff16105b156115705761153260ff861682612af1565b336000908152601160205260408120805492935060ff909216919061155683612bfa565b91906101000a81548160ff021916908360ff160217905550505b600083511180156115865750611586338461092f565b80156115b4575033600090815260126020526040902054600e546115ad9160ff1690612b61565b8660ff1611155b156116055733600090815260126020526040812080548892906115db90849060ff16612b09565b92506101000a81548160ff021916908360ff1602179055508560ff16816116029190612af1565b90505b600081116116475760405162461bcd60e51b815260206004820152600f60248201526e185d081b19585cdd080c481b5a5b9d608a1b6044820152606401610680565b600d546116548284612af1565b11156116975760405162461bcd60e51b81526020600482015260126024820152711b585e081cdd5c1c1b1e481c995858da195960721b6044820152606401610680565b80600c60008282546116a99190612af1565b90915550600190505b8181116116d9576116c733610bfb8386612af1565b806116d181612bdf565b9150506116b2565b5050505050505050565b6060600a6040516020016116f791906128b8565b604051602081830303815290604052905090565b6006546001600160a01b031633146117355760405162461bcd60e51b815260040161068090612a3a565b6001600160a01b03811661179a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610680565b6117a381611b39565b50565b60006001600160e01b031982166380ac58cd60e01b14806117d757506001600160e01b03198216635b5e139f60e01b145b8061065057506301ffc9a760e01b6001600160e01b0319831614610650565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061182b82610c18565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008060006118738585611ccb565b9150915061188081611d38565b509392505050565b6000818152600260205260408120546001600160a01b03166119015760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610680565b600061190c83610c18565b9050806001600160a01b0316846001600160a01b031614806119475750836001600160a01b031661193c8461072e565b6001600160a01b0316145b8061197757506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661199282610c18565b6001600160a01b0316146119fa5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610680565b6001600160a01b038216611a5c5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610680565b611a676000826117f6565b6001600160a01b0383166000908152600360205260408120805460019290611a90908490612b61565b90915550506001600160a01b0382166000908152600360205260408120805460019290611abe908490612af1565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b610b3f828260405180602001604052806000815250611ef3565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611b9684848461197f565b611ba284848484611f26565b610c125760405162461bcd60e51b8152600401610680906129e8565b6060600880546106ab90612ba4565b606081611bf15750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611c1b5780611c0581612bdf565b9150611c149050600a83612b2e565b9150611bf5565b60008167ffffffffffffffff811115611c3657611c36612c86565b6040519080825280601f01601f191660200182016040528015611c60576020820181803683370190505b5090505b841561197757611c75600183612b61565b9150611c82600a86612c1a565b611c8d906030612af1565b60f81b818381518110611ca257611ca2612c70565b60200101906001600160f81b031916908160001a905350611cc4600a86612b2e565b9450611c64565b600080825160411415611d025760208301516040840151606085015160001a611cf687828585612033565b94509450505050610a09565b825160401415611d2c5760208301516040840151611d21868383612120565b935093505050610a09565b50600090506002610a09565b6000816004811115611d4c57611d4c612c5a565b1415611d555750565b6001816004811115611d6957611d69612c5a565b1415611db75760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610680565b6002816004811115611dcb57611dcb612c5a565b1415611e195760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610680565b6003816004811115611e2d57611e2d612c5a565b1415611e865760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610680565b6004816004811115611e9a57611e9a612c5a565b14156117a35760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610680565b611efd838361214f565b611f0a6000848484611f26565b6108d45760405162461bcd60e51b8152600401610680906129e8565b60006001600160a01b0384163b1561202857604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611f6a903390899088908890600401612954565b602060405180830381600087803b158015611f8457600080fd5b505af1925050508015611fb4575060408051601f3d908101601f19168201909252611fb19181019061277e565b60015b61200e573d808015611fe2576040519150601f19603f3d011682016040523d82523d6000602084013e611fe7565b606091505b5080516120065760405162461bcd60e51b8152600401610680906129e8565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611977565b506001949350505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561206a5750600090506003612117565b8460ff16601b1415801561208257508460ff16601c14155b156120935750600090506004612117565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156120e7573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661211057600060019250925050612117565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b0161214187828885612033565b935093505050935093915050565b6001600160a01b0382166121a55760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610680565b6000818152600260205260409020546001600160a01b03161561220a5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610680565b6001600160a01b0382166000908152600360205260408120805460019290612233908490612af1565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461229d90612ba4565b90600052602060002090601f0160209004810192826122bf5760008555612305565b82601f106122d857805160ff1916838001178555612305565b82800160010185558215612305579182015b828111156123055782518255916020019190600101906122ea565b50612311929150612315565b5090565b5b808211156123115760008155600101612316565b600067ffffffffffffffff83111561234457612344612c86565b612357601f8401601f1916602001612ac0565b905082815283838301111561236b57600080fd5b828260208301376000602084830101529392505050565b8035801515811461239257600080fd5b919050565b600082601f8301126123a857600080fd5b610dc68383356020850161232a565b803560ff8116811461239257600080fd5b6000602082840312156123da57600080fd5b8135610dc681612c9c565b6000602082840312156123f757600080fd5b8151610dc681612c9c565b6000806040838503121561241557600080fd5b823561242081612c9c565b9150602083013561243081612c9c565b809150509250929050565b60008060006060848603121561245057600080fd5b833561245b81612c9c565b9250602084013561246b81612c9c565b929592945050506040919091013590565b6000806000806080858703121561249257600080fd5b843561249d81612c9c565b935060208501356124ad81612c9c565b925060408501359150606085013567ffffffffffffffff8111156124d057600080fd5b6124dc87828801612397565b91505092959194509250565b600080604083850312156124fb57600080fd5b823561250681612c9c565b915061251460208401612382565b90509250929050565b6000806040838503121561253057600080fd5b823561253b81612c9c565b9150602083013567ffffffffffffffff81111561255757600080fd5b61256385828601612397565b9150509250929050565b6000806040838503121561258057600080fd5b823561258b81612c9c565b946020939093013593505050565b6000806000606084860312156125ae57600080fd5b83356125b981612c9c565b95602085013595506040909401359392505050565b6000806000606084860312156125e357600080fd5b83356125ee81612c9c565b92506125fc602085016123b7565b9150604084013567ffffffffffffffff81111561261857600080fd5b61262486828701612397565b9150509250925092565b600080600080600060a0868803121561264657600080fd5b853567ffffffffffffffff8082111561265e57600080fd5b818801915088601f83011261267257600080fd5b813560208282111561268657612686612c86565b8160051b612695828201612ac0565b8381528281019086840183880185018f10156126b057600080fd5b600097505b858810156126d35780358352600197909701969184019184016126b5565b509a506126e49150508a82016123b7565b975050506126f4604089016123b7565b9450606088013591508082111561270a57600080fd5b61271689838a01612397565b9350608088013591508082111561272c57600080fd5b5061273988828901612397565b9150509295509295909350565b60006020828403121561275857600080fd5b610dc682612382565b60006020828403121561277357600080fd5b8135610dc681612cb1565b60006020828403121561279057600080fd5b8151610dc681612cb1565b6000602082840312156127ad57600080fd5b813567ffffffffffffffff8111156127c457600080fd5b8201601f810184136127d557600080fd5b6119778482356020840161232a565b6000602082840312156127f657600080fd5b5035919050565b60006020828403121561280f57600080fd5b5051919050565b6000806040838503121561282957600080fd5b82359150602083013561243081612c9c565b6000806040838503121561284e57600080fd5b50508035926020909101359150565b60008151808452612875816020860160208601612b78565b601f01601f19169290920160200192915050565b6000835161289b818460208801612b78565b8351908301906128af818360208801612b78565b01949350505050565b600080835481600182811c9150808316806128d457607f831692505b60208084108214156128f457634e487b7160e01b86526022600452602486fd5b818015612908576001811461291957612946565b60ff19861689528489019650612946565b60008a81526020902060005b8681101561293e5781548b820152908501908301612925565b505084890196505b509498975050505050505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906129879083018461285d565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156129c9578351835292840192918401916001016129ad565b50909695505050505050565b602081526000610dc6602083018461285d565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff81118282101715612ae957612ae9612c86565b604052919050565b60008219821115612b0457612b04612c2e565b500190565b600060ff821660ff84168060ff03821115612b2657612b26612c2e565b019392505050565b600082612b3d57612b3d612c44565b500490565b6000816000190483118215151615612b5c57612b5c612c2e565b500290565b600082821015612b7357612b73612c2e565b500390565b60005b83811015612b93578181015183820152602001612b7b565b83811115610c125750506000910152565b600181811c90821680612bb857607f821691505b60208210811415612bd957634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612bf357612bf3612c2e565b5060010190565b600060ff821660ff811415612c1157612c11612c2e565b60010192915050565b600082612c2957612c29612c44565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146117a357600080fd5b6001600160e01b0319811681146117a357600080fdfea26469706673582212205b02cfbcaa3631f5b1802ff7fa184f4f34cfe09ad2082c0d314ae6a469c2709f64736f6c63430008070033
Verified Source Code Full Match
Compiler: v0.8.7+commit.e28d00a7
EVM: london
Optimization: Yes (200 runs)
ApeKidsPets_flat_v3.sol 1315 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.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;
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.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);
}
// File: @openzeppelin/contracts/utils/Address.sol
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/utils/Context.sol
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: @openzeppelin/contracts/utils/Strings.sol
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: @openzeppelin/contracts/utils/introspection/ERC165.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;
}
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.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 {}
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.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);
}
// File: @openzeppelin/contracts/access/Ownable.sol
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File: @openzeppelin/contracts/utils/cryptography/ECDSA.sol
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
// File: contracts/ApeKidsPets.sol
contract ApeKidsPets is ERC721, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
//AKC contract
IERC721Enumerable akcContract;
//NFT params
string public baseURI;
string public defaultURI;
string public mycontractURI;
bool public finalizeBaseUri = false;
uint256 private currentSupply;
uint256 public maxSupply; //11999
uint256 public mintMax = 1;
address public signer;
mapping(uint256 => uint8) public akcClaimed;
mapping(address => uint8) public OGClaimed;
mapping(address => uint8) public whitelistClaimed;
//state
bool public paused = true;
//royalty
address public royaltyAddr;
uint256 public royaltyBasis;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _defaultURI,
address _akc,
uint256 _maxSupply,
address _signer,
address _royaltyAddr,
uint256 _royaltyBasis
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
defaultURI = _defaultURI;
akcContract = IERC721Enumerable(_akc);
maxSupply = _maxSupply;
signer = _signer;
royaltyAddr = _royaltyAddr;
royaltyBasis = _royaltyBasis;
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function supportsInterface(bytes4 interfaceId) public view override(ERC721) returns (bool) {
return interfaceId == 0xe8a3d485 /* contractURI() */ ||
interfaceId == 0x2a55205a /* ERC-2981 royaltyInfo() */ ||
super.supportsInterface(interfaceId);
}
function claimablePets(address _addr) public view returns (uint256[] memory) {
uint256 ownerTokenCount = akcContract.balanceOf(_addr);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
uint256 j;
for (uint256 i; i < ownerTokenCount; i++) {
uint256 tid = akcContract.tokenOfOwnerByIndex(_addr, i);
if(akcClaimed[tid] < mintMax){
tokenIds[j] = tid;
j++;
}
}
return tokenIds;
}
function mint(uint256[] memory _tokenIdsToClaim, uint8 WLnums, uint8 OGcnt, bytes memory OGsignature, bytes memory WLsignature) public {
require(!paused);
uint256 supply = totalSupply();
uint256 mintCount;
for(uint256 i=0;i<_tokenIdsToClaim.length;i++){
uint256 tid = _tokenIdsToClaim[i];
if((akcContract.ownerOf(tid) == msg.sender) && (akcClaimed[tid] < mintMax)){
akcClaimed[tid]++;
mintCount++;
}else{
revert("id doesnt belong to owner");
}
}
if((OGsignature.length > 0) && isOGed(msg.sender, OGcnt, OGsignature) && (OGClaimed[msg.sender] < mintMax)){
mintCount+=OGcnt;
OGClaimed[msg.sender]++;
}
if((WLsignature.length > 0) && isWhitelisted(msg.sender, WLsignature) && (WLnums <= (mintMax - whitelistClaimed[msg.sender]))){
whitelistClaimed[msg.sender] += WLnums;
mintCount += WLnums;
}
require(mintCount > 0,"at least 1 mint");
require(supply + mintCount <= maxSupply, "max supply reached");
currentSupply += mintCount;
for (uint256 i = 1; i <= mintCount; i++) {
_safeMint(msg.sender, supply + i);
}
}
function isOGed(address _addr, uint8 cnt, bytes memory signature) public view returns(bool){
return signer == keccak256(abi.encodePacked('OG', _addr, cnt)).recover(signature);
}
function isWhitelisted(address _addr, bytes memory signature) public view returns(bool){
return signer == keccak256(abi.encodePacked('WL', _addr)).recover(signature);
}
function tokensOfOwner(address _owner, uint startId, uint endId) external view returns(uint256[] memory ) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 index = 0;
for (uint256 tokenId = startId; tokenId <= endId; tokenId++) {
if (index == tokenCount) break;
if (ownerOf(tokenId) == _owner) {
result[index] = tokenId;
index++;
}
}
return result;
}
}
function totalSupply() public view returns (uint256) {
return currentSupply;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString()))
: defaultURI;
}
function contractURI() public view returns (string memory) {
return string(abi.encodePacked(mycontractURI));
}
//ERC-2981
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view
returns (address receiver, uint256 royaltyAmount){
return (royaltyAddr, _salePrice * royaltyBasis / 10000);
}
//only owner functions ---
function setMintMax(uint256 _mintMax) public onlyOwner {
mintMax = _mintMax;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
require(!finalizeBaseUri);
baseURI = _newBaseURI;
}
function finalizeBaseURI() public onlyOwner {
finalizeBaseUri = true;
}
function setContractURI(string memory _contractURI) public onlyOwner {
mycontractURI = _contractURI;
//return format based on https://docs.opensea.io/docs/contract-level-metadata
}
function setRoyalty(address _royaltyAddr, uint256 _royaltyBasis) public onlyOwner {
royaltyAddr = _royaltyAddr;
royaltyBasis = _royaltyBasis;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function reserveMint(uint256 _mintAmount, address _to) public onlyOwner {
uint256 supply = totalSupply();
require(supply + _mintAmount <= maxSupply, "max supply reached");
currentSupply += _mintAmount;
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, supply + i);
}
}
}
Read Contract
OGClaimed 0x1dfcaa48 → uint8
akcClaimed 0xcd6a3379 → uint8
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
claimablePets 0xaa332533 → uint256[]
contractURI 0xe8a3d485 → string
defaultURI 0x3a367a67 → string
finalizeBaseUri 0xf053d370 → bool
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
isOGed 0x7ef2750e → bool
isWhitelisted 0x1f0a8fa7 → bool
maxSupply 0xd5abeb01 → uint256
mintMax 0x4d155561 → uint256
mycontractURI 0x639d7e11 → string
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
royaltyAddr 0x3009c083 → address
royaltyBasis 0xc6ec6909 → uint256
royaltyInfo 0x2a55205a → address, uint256
signer 0x238ac933 → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
tokensOfOwner 0xc839fe94 → uint256[]
totalSupply 0x18160ddd → uint256
whitelistClaimed 0xdb4bec44 → uint8
Write Contract 15 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
finalizeBaseURI 0x37c3fdbc
No parameters
mint 0xc971e428
uint256[] _tokenIdsToClaim
uint8 WLnums
uint8 OGcnt
bytes OGsignature
bytes WLsignature
pause 0x02329a29
bool _state
renounceOwnership 0x715018a6
No parameters
reserveMint 0x60b02f70
uint256 _mintAmount
address _to
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string _newBaseURI
setContractURI 0x938e3d7b
string _contractURI
setMintMax 0xafc3cb49
uint256 _mintMax
setRoyalty 0x10fd332b
address _royaltyAddr
uint256 _royaltyBasis
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address