Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x819327e005A3ed85F7b634e195b8F25D4a2a45f8
Balance 0 ETH
Nonce 1
Code Size 16494 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

16494 bytes
0x6080604052600436106102305760003560e01c80637c13774b1161012e578063b4b27a56116100ab578063c87b56dd1161006f578063c87b56dd146106a6578063e8a3d485146106c6578063e985e9c5146106db578063f2fde38b14610724578063faff50a81461074457600080fd5b8063b4b27a56146105f1578063b88d4fde14610621578063b917ade514610641578063bf71ece714610656578063c4c3262e1461067657600080fd5b806395d89b41116100f257806395d89b4114610573578063a035b1fe14610588578063a22cb4651461059e578063a2b40d19146105be578063ab5df1ca146105de57600080fd5b80637c13774b146104c35780637d73b231146104f2578063845a6e33146105155780638da5cb5b146105355780638f742d161461055357600080fd5b80632f745c59116101bc5780634f6ccce7116101805780634f6ccce7146104395780636352211e1461045957806370a0823114610479578063715018a61461049957806374f82e30146104ae57600080fd5b80632f745c591461039157806342842e0e146103b1578063458955b8146103d15780634c92c6a5146103f95780634e3b515d1461041957600080fd5b806311d1e1bb1161020357806311d1e1bb146102e6578063172195221461030657806317c2f94d1461033257806318160ddd1461035257806323b872dd1461037157600080fd5b806301ffc9a71461023557806306fdde031461026a578063081812fc1461028c578063095ea7b3146102c4575b600080fd5b34801561024157600080fd5b506102556102503660046133e1565b610766565b60405190151581526020015b60405180910390f35b34801561027657600080fd5b5061027f610791565b6040516102619190613c21565b34801561029857600080fd5b506102ac6102a73660046133b1565b610823565b6040516001600160a01b039091168152602001610261565b3480156102d057600080fd5b506102e46102df3660046132df565b6108bd565b005b3480156102f257600080fd5b5061027f6103013660046133b1565b6109d3565b34801561031257600080fd5b50600c546103209060ff1681565b60405160ff9091168152602001610261565b34801561033e57600080fd5b506102e461034d366004613308565b610a6d565b34801561035e57600080fd5b506008545b604051908152602001610261565b34801561037d57600080fd5b506102e461038c366004613195565b610b45565b34801561039d57600080fd5b506103636103ac3660046132df565b610b76565b3480156103bd57600080fd5b506102e46103cc366004613195565b610c0c565b3480156103dd57600080fd5b506102ac734976fb03c32e5b8cfe2b6ccb31c09ba78ebaba4181565b34801561040557600080fd5b506102e4610414366004613308565b610c27565b34801561042557600080fd5b506102e4610434366004613419565b610cf3565b34801561044557600080fd5b506103636104543660046133b1565b610d5a565b34801561046557600080fd5b506102ac6104743660046133b1565b610dfb565b34801561048557600080fd5b50610363610494366004613149565b610e72565b3480156104a557600080fd5b506102e4610ef9565b3480156104ba57600080fd5b5061027f610f2f565b3480156104cf57600080fd5b506104e36104de3660046133b1565b610f3c565b60405161026193929190613c34565b3480156104fe57600080fd5b506102ac6e0c2e074ec69a0dfb2997ba6c7d2e1e81565b34801561052157600080fd5b506102e4610530366004613308565b611071565b34801561054157600080fd5b50600a546001600160a01b03166102ac565b34801561055f57600080fd5b5061027f61056e3660046133b1565b6113b0565b34801561057f57600080fd5b5061027f6114e0565b34801561059457600080fd5b50610363600b5481565b3480156105aa57600080fd5b506102e46105b93660046132a5565b6114ef565b3480156105ca57600080fd5b506102e46105d93660046133b1565b6115b4565b6102e46105ec366004613348565b611619565b3480156105fd57600080fd5b5061025561060c3660046133b1565b60106020526000908152604090205460ff1681565b34801561062d57600080fd5b506102e461063c3660046131d0565b611a25565b34801561064d57600080fd5b506102e4611a57565b34801561066257600080fd5b506102e461067136600461344d565b611ae8565b34801561068257600080fd5b506102556106913660046133b1565b600f6020526000908152604090205460ff1681565b3480156106b257600080fd5b5061027f6106c13660046133b1565b611bae565b3480156106d257600080fd5b5061027f611e3e565b3480156106e757600080fd5b506102556106f6366004613163565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561073057600080fd5b506102e461073f366004613149565b611f93565b34801561075057600080fd5b5061036360008051602061401983398151915281565b60006001600160e01b0319821663780e9d6360e01b148061078b575061078b8261202e565b92915050565b6060600080546107a090613ef6565b80601f01602080910402602001604051908101604052809291908181526020018280546107cc90613ef6565b80156108195780601f106107ee57610100808354040283529160200191610819565b820191906000526020600020905b8154815290600101906020018083116107fc57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108a15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006108c882610dfb565b9050806001600160a01b0316836001600160a01b031614156109365760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610898565b336001600160a01b0382161480610952575061095281336106f6565b6109c45760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610898565b6109ce838361207e565b505050565b600e60205260009081526040902080546109ec90613ef6565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1890613ef6565b8015610a655780601f10610a3a57610100808354040283529160200191610a65565b820191906000526020600020905b815481529060010190602001808311610a4857829003601f168201915b505050505081565b600a546001600160a01b03163314610a975760405162461bcd60e51b815260040161089890613d3e565b60005b81811015610b07576001600f6000858585818110610ac857634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610aff90613f31565b915050610a9a565b507fe4c20759217cc1054b87a97ded2060d6a8dafaec59cc4a3e42236f2ef845fd1e8282604051610b39929190613b96565b60405180910390a15050565b610b4f33826120ec565b610b6b5760405162461bcd60e51b815260040161089890613d73565b6109ce8383836121e3565b6000610b8183610e72565b8210610be35760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610898565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6109ce83838360405180602001604052806000815250611a25565b600a546001600160a01b03163314610c515760405162461bcd60e51b815260040161089890613d3e565b60005b81811015610cc157600160106000858585818110610c8257634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610cb990613f31565b915050610c54565b507fc36d383aac1e57aec57fd9c934c49084577198580ff0b7f57ae4c5ba704a45218282604051610b39929190613b96565b600a546001600160a01b03163314610d1d5760405162461bcd60e51b815260040161089890613d3e565b610d29600d838361300f565b507f67d297958535dc5b50105c6c4a79b5e66f7fabdc2169a7fc5c3283adda657777600d604051610b399190613c6d565b6000610d6560085490565b8210610dc85760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610898565b60088281548110610de957634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b03168061078b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610898565b60006001600160a01b038216610edd5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610898565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610f235760405162461bcd60e51b815260040161089890613d3e565b610f2d600061238e565b565b600d80546109ec90613ef6565b601160205260009081526040902080548190610f5790613ef6565b80601f0160208091040260200160405190810160405280929190818152602001828054610f8390613ef6565b8015610fd05780601f10610fa557610100808354040283529160200191610fd0565b820191906000526020600020905b815481529060010190602001808311610fb357829003601f168201915b505050505090806001018054610fe590613ef6565b80601f016020809104026020016040519081016040528092919081815260200182805461101190613ef6565b801561105e5780601f106110335761010080835404028352916020019161105e565b820191906000526020600020905b81548152906001019060200180831161104157829003601f168201915b5050506002909301549192505060ff1683565b60005b818110156109ce576110ab83838381811061109f57634e487b7160e01b600052603260045260246000fd5b90506020020135610dfb565b6001600160a01b0316336001600160a01b0316146110fa5760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610898565b60006011600085858581811061112057634e487b7160e01b600052603260045260246000fd5b905060200201358152602001908152602001600020905060008160000182600101604051602001611152929190613a99565b60408051808303601f190181529082905280516020909101206305ef2c7f60e41b8252600080516020614019833981519152600483015260248201819052306044830152734976fb03c32e5b8cfe2b6ccb31c09ba78ebaba4160648301526000608483015291506e0c2e074ec69a0dfb2997ba6c7d2e1e90635ef2c7f09060a401600060405180830381600087803b1580156111ed57600080fd5b505af1158015611201573d6000803e3d6000fd5b5050604080516000805160206140198339815191526020820152908101849052734976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41925063d5fa2b00915060600160408051601f198184030181529082905280516020909101206001600160e01b031960e084901b1682526004820152336024820152604401600060405180830381600087803b15801561129457600080fd5b505af11580156112a8573d6000803e3d6000fd5b50506040516306ab592360e01b81526000805160206140198339815191526004820152602481018490523360448201526e0c2e074ec69a0dfb2997ba6c7d2e1e92506306ab59239150606401602060405180830381600087803b15801561130e57600080fd5b505af1158015611322573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134691906133c9565b503385858581811061136857634e487b7160e01b600052603260045260246000fd5b905060200201357fcceadda399b33d22e2a02112c0f97d793613321a82d1e3a8cc064cae1576399760405160405180910390a3505080806113a890613f31565b915050611074565b6000818152600260205260409020546060906001600160a01b031661140a5760405162461bcd60e51b815260206004820152601060248201526f24b732bc34b9ba32b73a103a37b5b2b760811b6044820152606401610898565b6000828152600e60205260409020805461142390613ef6565b80601f016020809104026020016040519081016040528092919081815260200182805461144f90613ef6565b801561149c5780601f106114715761010080835404028352916020019161149c565b820191906000526020600020905b81548152906001019060200180831161147f57829003601f168201915b505050505090508051600014156114db57600d6114b8836123e0565b6040516020016114c9929190613a74565b60405160208183030381529060405290505b919050565b6060600180546107a090613ef6565b6001600160a01b0382163314156115485760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610898565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b031633146115de5760405162461bcd60e51b815260040161089890613d3e565b600b8190556040518181527fa6dc15bdb68da224c66db4b3838d9a2b205138e8cff6774e57d0af91e196d6229060200160405180910390a150565b8281146116585760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b6044820152606401610898565b600b54611666908490613e5a565b34146116a75760405162461bcd60e51b815260206004820152601060248201526f125b98dbdc9c9958dd08185b5bdd5b9d60821b6044820152606401610898565b60005b838110156119f957600f60008686848181106116d657634e487b7160e01b600052603260045260246000fd5b90506020028101906116e89190613dc4565b6040516116f692919061355b565b604080519182900390912082526020820192909252016000205460ff166117515760405162461bcd60e51b815260206004820152600f60248201526e10dbdb1bdc881b9bdd081859191959608a1b6044820152606401610898565b6010600084848481811061177557634e487b7160e01b600052603260045260246000fd5b90506020028101906117879190613dc4565b60405161179592919061355b565b604080519182900390912082526020820192909252016000205460ff166117f15760405162461bcd60e51b815260206004820152601060248201526f13d89a9958dd081b9bdd08185919195960821b6044820152606401610898565b600085858381811061181357634e487b7160e01b600052603260045260246000fd5b90506020028101906118259190613dc4565b85858581811061184557634e487b7160e01b600052603260045260246000fd5b90506020028101906118579190613dc4565b60405160200161186a949392919061356b565b60408051601f1981840301815291815281516020928301206000818152601190935291209091508686848181106118b157634e487b7160e01b600052603260045260246000fd5b90506020028101906118c39190613dc4565b6118ce91839161300f565b508484848181106118ef57634e487b7160e01b600052603260045260246000fd5b90506020028101906119019190613dc4565b61190f91600184019161300f565b50600c5460ff161561193457600c5460028201805460ff191660ff9092169190911790555b61193e33836124fa565b33827f8f9ee9af8ade7fef0bf48991d7cbdd1593ca9fb2920c2b01f90b2dd84c513d6889898781811061198157634e487b7160e01b600052603260045260246000fd5b90506020028101906119939190613dc4565b8989898181106119b357634e487b7160e01b600052603260045260246000fd5b90506020028101906119c59190613dc4565b600c546040516119dc959493929160ff1690613be4565b60405180910390a3505080806119f190613f31565b9150506116aa565b50611a1f34611a10600a546001600160a01b031690565b6001600160a01b031690612518565b50505050565b611a2f33836120ec565b611a4b5760405162461bcd60e51b815260040161089890613d73565b611a1f84848484612631565b600a546001600160a01b03163314611a815760405162461bcd60e51b815260040161089890613d3e565b600c805460ff16906000611a9483613f4c565b82546101009290920a60ff818102199093169183160217909155600c54604051911681527ffa7df6876fbcf0666000276873af058033b0923064c1489e1b98f59eb8253db3915060200160405180910390a1565b611af183610dfb565b6001600160a01b0316336001600160a01b03161480611b1a5750600a546001600160a01b031633145b611b555760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610898565b6000838152600e60205260409020611b6e90838361300f565b50827f95a4e2c8fb8945446945dd643ab087654610d2e384303e17978b751c0d80a78b8383604051611ba1929190613bd0565b60405180910390a2505050565b6000818152600260205260409020546060906001600160a01b0316611c085760405162461bcd60e51b815260206004820152601060248201526f24b732bc34b9ba32b73a103a37b5b2b760811b6044820152606401610898565b60008281526011602052604081208054909190611cad908390611c2a90613ef6565b80601f0160208091040260200160405190810160405280929190818152602001828054611c5690613ef6565b8015611ca35780601f10611c7857610100808354040283529160200191611ca3565b820191906000526020600020905b815481529060010190602001808311611c8657829003601f168201915b5050505050612664565b90506000611cc3836001018054611c2a90613ef6565b6002840154909150600090611cdc9060ff166001613e21565b60ff1690508282604051602001611cf4929190613aae565b604051602081830303815290604052945084604051602001611d1691906138b7565b604051602081830303815290604052945084611d31876113b0565b604051602001611d4292919061380d565b604051602081830303815290604052945084604051602001611d64919061371e565b60405160208183030381529060405294508483604051602001611d88929190613754565b60405160208183030381529060405294508482604051602001611dac929190613984565b604051602081830303815290604052945084611dc7826123e0565b604051602001611dd892919061365c565b604051602081830303815290604052945084604051602001611dfa9190613589565b6040516020818303038152906040529450611e148561275c565b604051602001611e249190613b14565b604051602081830303815290604052945050505050919050565b604080517f7b0a2020226e616d65223a20224865786f20436f646573222c0a00000000000060208201528151601a818303018152603a8201909252611e87908290605a016138b7565b604051602081830303815290604052905080604051602001611ea99190613a19565b604051602081830303815290604052905080604051602001611ecb9190613864565b604051602081830303815290604052905080604051602001611eed91906135b2565b604051602081830303815290604052905080611f22611f14600a546001600160a01b031690565b6001600160a01b03166128d2565b604051602001611f339291906135fe565b604051602081830303815290604052905080604051602001611f5591906137e8565b6040516020818303038152906040529050611f6f8161275c565b604051602001611f7f9190613b14565b604051602081830303815290604052905090565b600a546001600160a01b03163314611fbd5760405162461bcd60e51b815260040161089890613d3e565b6001600160a01b0381166120225760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610898565b61202b8161238e565b50565b60006001600160e01b031982166380ac58cd60e01b148061205f57506001600160e01b03198216635b5e139f60e01b145b8061078b57506301ffc9a760e01b6001600160e01b031983161461078b565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906120b382610dfb565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166121655760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610898565b600061217083610dfb565b9050806001600160a01b0316846001600160a01b031614806121ab5750836001600160a01b03166121a084610823565b6001600160a01b0316145b806121db57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166121f682610dfb565b6001600160a01b03161461225e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610898565b6001600160a01b0382166122c05760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610898565b6122cb838383612926565b6122d660008261207e565b6001600160a01b03831660009081526003602052604081208054600192906122ff908490613e79565b90915550506001600160a01b038216600090815260036020526040812080546001929061232d908490613e09565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6060816124045750506040805180820190915260018152600360fc1b602082015290565b8160005b811561242e578061241881613f31565b91506124279050600a83613e46565b9150612408565b60008167ffffffffffffffff81111561245757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612481576020820181803683370190505b5090505b84156121db57612496600183613e79565b91506124a3600a86613f6c565b6124ae906030613e09565b60f81b8183815181106124d157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506124f3600a86613e46565b9450612485565b6125148282604051806020016040528060008152506129de565b5050565b804710156125685760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610898565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146125b5576040519150601f19603f3d011682016040523d82523d6000602084013e6125ba565b606091505b50509050806109ce5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610898565b61263c8484846121e3565b61264884848484612a11565b611a1f5760405162461bcd60e51b815260040161089890613cec565b60606000829050606160f81b8160008151811061269157634e487b7160e01b600052603260045260246000fd5b01602001516001600160f81b031916108015906126e15750607a60f81b816000815181106126cf57634e487b7160e01b600052603260045260246000fd5b01602001516001600160f81b03191611155b1561078b5760208160008151811061270957634e487b7160e01b600052603260045260246000fd5b016020015161271b919060f81c613e90565b60f81b8160008151811061273f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535092915050565b606081516000141561277c57505060408051602081019091526000815290565b6000604051806060016040528060408152602001613fd960409139905060006003845160026127ab9190613e09565b6127b59190613e46565b6127c0906004613e5a565b905060006127cf826020613e09565b67ffffffffffffffff8111156127f557634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561281f576020820181803683370190505b509050818152600183018586518101602084015b8183101561288d5760039283018051603f601282901c811687015160f890811b8552600c83901c8216880151811b6001860152600683901c8216880151811b60028601529116860151901b93820193909352600401612833565b6003895106600181146128a757600281146128b8576128c4565b613d3d60f01b6001198301526128c4565b603d60f81b6000198301525b509398975050505050505050565b6060816128f95750506040805180820190915260048152630307830360e41b602082015290565b8160005b811561291c578061290d81613f31565b915050600882901c91506128fd565b6121db8482612b1e565b6001600160a01b0383166129815761297c81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6129a4565b816001600160a01b0316836001600160a01b0316146129a4576129a48382612d07565b6001600160a01b0382166129bb576109ce81612da4565b826001600160a01b0316826001600160a01b0316146109ce576109ce8282612e7d565b6129e88383612ec1565b6129f56000848484612a11565b6109ce5760405162461bcd60e51b815260040161089890613cec565b60006001600160a01b0384163b15612b1357604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612a55903390899088908890600401613b59565b602060405180830381600087803b158015612a6f57600080fd5b505af1925050508015612a9f575060408051601f3d908101601f19168201909252612a9c918101906133fd565b60015b612af9573d808015612acd576040519150601f19603f3d011682016040523d82523d6000602084013e612ad2565b606091505b508051612af15760405162461bcd60e51b815260040161089890613cec565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506121db565b506001949350505050565b60606000612b2d836002613e5a565b612b38906002613e09565b67ffffffffffffffff811115612b5e57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612b88576020820181803683370190505b509050600360fc1b81600081518110612bb157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612bee57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000612c12846002613e5a565b612c1d906001613e09565b90505b6001811115612cb1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612c5f57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110612c8357634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93612caa81613edf565b9050612c20565b508315612d005760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610898565b9392505050565b60006001612d1484610e72565b612d1e9190613e79565b600083815260076020526040902054909150808214612d71576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612db690600190613e79565b60008381526009602052604081205460088054939450909284908110612dec57634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060088381548110612e1b57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480612e6157634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612e8883610e72565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216612f175760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610898565b6000818152600260205260409020546001600160a01b031615612f7c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610898565b612f8860008383612926565b6001600160a01b0382166000908152600360205260408120805460019290612fb1908490613e09565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461301b90613ef6565b90600052602060002090601f01602090048101928261303d5760008555613083565b82601f106130565782800160ff19823516178555613083565b82800160010185558215613083579182015b82811115613083578235825591602001919060010190613068565b5061308f929150613093565b5090565b5b8082111561308f5760008155600101613094565b80356001600160a01b03811681146114db57600080fd5b60008083601f8401126130d0578081fd5b50813567ffffffffffffffff8111156130e7578182fd5b6020830191508360208260051b850101111561310257600080fd5b9250929050565b60008083601f84011261311a578182fd5b50813567ffffffffffffffff811115613131578182fd5b60208301915083602082850101111561310257600080fd5b60006020828403121561315a578081fd5b612d00826130a8565b60008060408385031215613175578081fd5b61317e836130a8565b915061318c602084016130a8565b90509250929050565b6000806000606084860312156131a9578081fd5b6131b2846130a8565b92506131c0602085016130a8565b9150604084013590509250925092565b600080600080608085870312156131e5578081fd5b6131ee856130a8565b93506131fc602086016130a8565b925060408501359150606085013567ffffffffffffffff8082111561321f578283fd5b818701915087601f830112613232578283fd5b81358181111561324457613244613fac565b604051601f8201601f19908116603f0116810190838211818310171561326c5761326c613fac565b816040528281528a6020848701011115613284578586fd5b82602086016020830137918201602001949094529598949750929550505050565b600080604083850312156132b7578182fd5b6132c0836130a8565b9150602083013580151581146132d4578182fd5b809150509250929050565b600080604083850312156132f1578182fd5b6132fa836130a8565b946020939093013593505050565b6000806020838503121561331a578182fd5b823567ffffffffffffffff811115613330578283fd5b61333c858286016130bf565b90969095509350505050565b6000806000806040858703121561335d578384fd5b843567ffffffffffffffff80821115613374578586fd5b613380888389016130bf565b90965094506020870135915080821115613398578384fd5b506133a5878288016130bf565b95989497509550505050565b6000602082840312156133c2578081fd5b5035919050565b6000602082840312156133da578081fd5b5051919050565b6000602082840312156133f2578081fd5b8135612d0081613fc2565b60006020828403121561340e578081fd5b8151612d0081613fc2565b6000806020838503121561342b578182fd5b823567ffffffffffffffff811115613441578283fd5b61333c85828601613109565b600080600060408486031215613461578081fd5b83359250602084013567ffffffffffffffff81111561347e578182fd5b61348a86828701613109565b9497909650939450505050565b600081518084526134af816020860160208601613eb3565b601f01601f19169290920160200192915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600081546134f981613ef6565b60018281168015613511576001811461352257613551565b60ff19841687528287019450613551565b8560005260208060002060005b858110156135485781548a82015290840190820161352f565b50505082870194505b5050505092915050565b8183823760009101908152919050565b83858237600084820181815283858237909201918252509392505050565b6000825161359b818460208701613eb3565b6420205d0a7d60d81b920191825250600501919050565b600082516135c4818460208701613eb3565b7f20202273656c6c65725f6665655f62617369735f706f696e7473223a2033333392019182525061160560f11b6020820152602201919050565b60008351613610818460208801613eb3565b731010113332b2afb932b1b4b834b2b73a111d101160611b9083019081528351613641816014840160208801613eb3565b61110560f11b60149290910191820152601601949350505050565b6000835161366e818460208801613eb3565b80830190507f202020207b0a20202020202022646973706c61795f74797065223a20226e756d81527f626572222c0a2020202020202274726169745f74797065223a202247656e657260208201527f6174696f6e222c0a2020202020202276616c7565223a20000000000000000000604082015283516136f5816057840160208801613eb3565b600560f91b6057929091019182015265101010103e8560d11b6058820152605e01949350505050565b60008251613730818460208701613eb3565b7110101130ba3a3934b13aba32b9911d102d8560711b920191825250601201919050565b60008351613766818460208801613eb3565b80830190507f202020207b0a2020202020202274726169745f74797065223a2022436f6c6f72815272111605101010101010113b30b63ab2911d101160691b602082015283516137bd816033840160208801613eb3565b61110560f11b6033929091019182015266101010103e960560c91b6035820152603c01949350505050565b600082516137fa818460208701613eb3565b607d60f81b920191825250600101919050565b6000835161381f818460208801613eb3565b6b10101134b6b0b3b2911d101160a11b908301908152835161384881600c840160208801613eb3565b6211160560e91b600c9290910191820152600f01949350505050565b60008251613876818460208701613eb3565b7f20202265787465726e616c5f6c696e6b223a202268747470733a2f2f6865786f920191825250681731b7b232b991160560b91b6020820152602901919050565b600082516138c9818460208701613eb3565b7f2020226465736372697074696f6e223a2022556e6971756520636f6d626f73209201918252507f6f6620626173696320636f6c6f727320616e64206f626a65637473207468617460208201527f20666f726d20756e6976657273616c6c79207265636f676e697a61626c65204e60408201527f4654206964656e7469746965732e205669736974206865786f2e636f646573206060820152703a37903632b0b9371036b7b9329711160560791b6080820152609101919050565b60008351613996818460208801613eb3565b80830190507f202020207b0a2020202020202274726169745f74797065223a20224f626a65638152733a111605101010101010113b30b63ab2911d101160611b602082015283516139ee816034840160208801613eb3565b61110560f11b6034929091019182015266101010103e960560c91b6036820152603d01949350505050565b60008251613a2b818460208701613eb3565b7f202022696d616765223a202268747470733a2f2f6865786f2e636f6465732f699201918252507036b0b3b2b997b637b3b79739bb3391160560791b6020820152603101919050565b6000613a8082856134ec565b8351613a90818360208801613eb3565b01949350505050565b60006121db613aa883866134ec565b846134ec565b6c3d851010113730b6b2911d101160991b81528251600090613ad781600d850160208801613eb3565b600160fd1b600d918401918201528351613af881600e840160208801613eb3565b6211160560e91b600e9290910191820152601101949350505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000815260008251613b4c81601d850160208701613eb3565b91909101601d0192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613b8c90830184613497565b9695505050505050565b6020808252810182905260006001600160fb1b03831115613bb5578081fd5b8260051b808560408501379190910160400190815292915050565b6020815260006121db6020830184866134c3565b606081526000613bf86060830187896134c3565b8281036020840152613c0b8186886134c3565b91505060ff831660408301529695505050505050565b602081526000612d006020830184613497565b606081526000613c476060830186613497565b8281036020840152613c598186613497565b91505060ff83166040830152949350505050565b60006020808352818454613c8081613ef6565b80848701526040600180841660008114613ca15760018114613cb5576128c4565b60ff198516898401526060890195506128c4565b898852868820885b85811015613cd85781548b8201860152908301908801613cbd565b909901929092019998505050505050505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000808335601e19843603018112613dda578283fd5b83018035915067ffffffffffffffff821115613df4578283fd5b60200191503681900382131561310257600080fd5b60008219821115613e1c57613e1c613f80565b500190565b600060ff821660ff84168060ff03821115613e3e57613e3e613f80565b019392505050565b600082613e5557613e55613f96565b500490565b6000816000190483118215151615613e7457613e74613f80565b500290565b600082821015613e8b57613e8b613f80565b500390565b600060ff821660ff841680821015613eaa57613eaa613f80565b90039392505050565b60005b83811015613ece578181015183820152602001613eb6565b83811115611a1f5750506000910152565b600081613eee57613eee613f80565b506000190190565b600181811c90821680613f0a57607f821691505b60208210811415613f2b57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613f4557613f45613f80565b5060010190565b600060ff821660ff811415613f6357613f63613f80565b60010192915050565b600082613f7b57613f7b613f96565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461202b57600080fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2ff55a38be8aab2a9e033746f5d0c4af6122e4dc9e896858445fa8e2e46abce36ca2646970667358221220d9d71ba7d3ff49755f8fbfc6929d182007dd9863aa4948b120dd9dc8f6eec71964736f6c63430008040033

Verified Source Code Full Match

Compiler: v0.8.4+commit.c7e474f2 EVM: istanbul Optimization: Yes (200 runs)
Hexo.sol 365 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "base64-sol/base64.sol";

import "./interfaces/IPublicResolver.sol";
import "./interfaces/IENS.sol";

contract Hexo is ERC721Enumerable, Ownable {
    using Address for address payable;
    using Strings for uint256;

    /// Structs

    struct TokenInfo {
        string color;
        string object;
        uint8 generation;
    }

    /// Fields

    uint256 public price;
    // For gas efficiency, first generation is 0
    uint8 public generation;

    string public baseImageURI;
    // Mapping from token id to custom image URI (if any)
    mapping(uint256 => string) public customImageURIs;

    // Keep track of available colors and objects
    mapping(bytes32 => bool) public colors;
    mapping(bytes32 => bool) public objects;

    // Mapping from token id to token info (eg. color, object, generation)
    mapping(uint256 => TokenInfo) public tokenInfos;

    /// Constants

    address public constant ensRegistry =
        address(0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e);
    address public constant ensPublicResolver =
        address(0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41);

    // namehash("hexo.eth")
    bytes32 public constant rootNode =
        0xf55a38be8aab2a9e033746f5d0c4af6122e4dc9e896858445fa8e2e46abce36c;

    /// Events

    event PriceChanged(uint256 price);
    event GenerationIncremented(uint256 generation);
    event BaseImageURIChanged(string baseImageURI);
    event ColorsAdded(bytes32[] colorHashes);
    event ObjectsAdded(bytes32[] objectHashes);

    event ItemMinted(
        uint256 indexed tokenId,
        string color,
        string object,
        uint8 generation,
        address indexed buyer
    );
    event SubdomainClaimed(uint256 indexed tokenId, address indexed claimer);
    event CustomImageURISet(uint256 indexed tokenId, string customImageURI);

    /// Constructor

    constructor(uint256 price_, string memory baseImageURI_)
        ERC721("Hexo Codes", "HEXO")
    {
        price = price_;
        baseImageURI = baseImageURI_;
    }

    /// Owner actions

    function changePrice(uint256 price_) external onlyOwner {
        price = price_;
        emit PriceChanged(price);
    }

    function incrementGeneration() external onlyOwner {
        generation++;
        emit GenerationIncremented(generation);
    }

    function changeBaseImageURI(string calldata baseImageURI_)
        external
        onlyOwner
    {
        baseImageURI = baseImageURI_;
        emit BaseImageURIChanged(baseImageURI);
    }

    function addColors(bytes32[] calldata _colorHashes) external onlyOwner {
        for (uint256 i = 0; i < _colorHashes.length; i++) {
            colors[_colorHashes[i]] = true;
        }
        emit ColorsAdded(_colorHashes);
    }

    function addObjects(bytes32[] calldata _objectHashes) external onlyOwner {
        for (uint256 i = 0; i < _objectHashes.length; i++) {
            objects[_objectHashes[i]] = true;
        }
        emit ObjectsAdded(_objectHashes);
    }

    /// User actions

    function mintItems(string[] calldata _colors, string[] calldata _objects)
        external
        payable
    {
        require(_colors.length == _objects.length, "Invalid input");
        require(msg.value == price * _colors.length, "Incorrect amount");

        for (uint256 i = 0; i < _colors.length; i++) {
            require(colors[keccak256(bytes(_colors[i]))], "Color not added");
            require(objects[keccak256(bytes(_objects[i]))], "Object not added");

            uint256 tokenId = uint256(
                keccak256(
                    bytes(string(abi.encodePacked(_colors[i], _objects[i])))
                )
            );

            TokenInfo storage tokenInfo = tokenInfos[tokenId];
            tokenInfo.color = _colors[i];
            tokenInfo.object = _objects[i];
            if (generation != 0) {
                tokenInfo.generation = generation;
            }

            _safeMint(msg.sender, tokenId);

            emit ItemMinted(
                tokenId,
                _colors[i],
                _objects[i],
                generation,
                msg.sender
            );
        }

        // Relay the funds to the contract owner
        payable(owner()).sendValue(msg.value);
    }

    function claimSubdomains(uint256[] calldata _tokenIds) external {
        for (uint256 i = 0; i < _tokenIds.length; i++) {
            require(msg.sender == ownerOf(_tokenIds[i]), "Unauthorized");

            TokenInfo storage tokenInfo = tokenInfos[_tokenIds[i]];
            bytes32 label = keccak256(
                abi.encodePacked(tokenInfo.color, tokenInfo.object)
            );

            // Temporarily set this contract as the owner of the ENS subdomain,
            // giving it permission to set up ENS forward resolution
            IENS(ensRegistry).setSubnodeRecord(
                rootNode,
                label,
                address(this),
                ensPublicResolver,
                0
            );

            // Set up ENS forward resolution to point to the owner
            IPublicResolver(ensPublicResolver).setAddr(
                keccak256(abi.encodePacked(rootNode, label)),
                msg.sender
            );

            // Give ownership back to the proper owner
            IENS(ensRegistry).setSubnodeOwner(rootNode, label, msg.sender);

            emit SubdomainClaimed(_tokenIds[i], msg.sender);
        }
    }

    function setCustomImageURI(
        uint256 _tokenId,
        string calldata _customImageURI
    ) external {
        require(
            msg.sender == ownerOf(_tokenId) || msg.sender == owner(),
            "Unauthorized"
        );
        customImageURIs[_tokenId] = _customImageURI;
        emit CustomImageURISet(_tokenId, _customImageURI);
    }

    /// Views

    function tokenURI(uint256 _tokenId)
        public
        view
        override
        returns (string memory metadata)
    {
        require(_exists(_tokenId), "Inexistent token");

        TokenInfo storage tokenInfo = tokenInfos[_tokenId];
        string memory tokenColor = _capitalize(tokenInfo.color);
        string memory tokenObject = _capitalize(tokenInfo.object);
        uint256 tokenGeneration = tokenInfo.generation + 1;

        // Name
        metadata = string(
            abi.encodePacked(
                '{\n  "name": "',
                tokenColor,
                " ",
                tokenObject,
                '",\n'
            )
        );

        // Description
        metadata = string(
            abi.encodePacked(
                metadata,
                '  "description": "Unique combos of basic colors and objects that form universally recognizable NFT identities. Visit hexo.codes to learn more.",\n'
            )
        );

        // Image
        metadata = string(
            abi.encodePacked(
                metadata,
                '  "image": "',
                imageURI(_tokenId),
                '",\n'
            )
        );

        // Attributes
        metadata = string(abi.encodePacked(metadata, '  "attributes": [\n'));
        metadata = string(
            abi.encodePacked(
                metadata,
                '    {\n      "trait_type": "Color",\n      "value": "',
                tokenColor,
                '"\n',
                "    },\n"
            )
        );
        metadata = string(
            abi.encodePacked(
                metadata,
                '    {\n      "trait_type": "Object",\n      "value": "',
                tokenObject,
                '"\n',
                "    },\n"
            )
        );
        metadata = string(
            abi.encodePacked(
                metadata,
                '    {\n      "display_type": "number",\n      "trait_type": "Generation",\n      "value": ',
                tokenGeneration.toString(),
                "\n",
                "    }\n"
            )
        );
        metadata = string(abi.encodePacked(metadata, "  ]\n}"));

        // Return a data URI of the metadata
        metadata = string(
            abi.encodePacked(
                "data:application/json;base64,",
                Base64.encode(bytes(metadata))
            )
        );
    }

    function contractURI() external view returns (string memory metadata) {
        // Name
        metadata = string(abi.encodePacked('{\n  "name": "Hexo Codes",\n'));

        // Description
        metadata = string(
            abi.encodePacked(
                metadata,
                '  "description": "Unique combos of basic colors and objects that form universally recognizable NFT identities. Visit hexo.codes to learn more.",\n'
            )
        );

        // Image
        metadata = string(
            abi.encodePacked(
                metadata,
                '  "image": "https://hexo.codes/images/logo.svg",\n'
            )
        );

        // External link
        metadata = string(
            abi.encodePacked(
                metadata,
                '  "external_link": "https://hexo.codes",\n'
            )
        );

        // Resell fee
        metadata = string(
            abi.encodePacked(metadata, '  "seller_fee_basis_points": 333,\n')
        );

        // Fee recipient
        metadata = string(
            abi.encodePacked(
                metadata,
                '  "fee_recipient": "',
                uint256(uint160(owner())).toHexString(),
                '"\n'
            )
        );

        metadata = string(abi.encodePacked(metadata, "}"));

        // Return a data URI of the metadata
        metadata = string(
            abi.encodePacked(
                "data:application/json;base64,",
                Base64.encode(bytes(metadata))
            )
        );
    }

    function imageURI(uint256 _tokenId)
        public
        view
        returns (string memory uri)
    {
        require(_exists(_tokenId), "Inexistent token");

        uri = customImageURIs[_tokenId];
        if (bytes(uri).length == 0) {
            // If a custom image URI is not set, use the default
            uri = string(abi.encodePacked(baseImageURI, _tokenId.toString()));
        }
    }

    /// Internals

    function _capitalize(string memory _string)
        internal
        pure
        returns (string memory)
    {
        bytes memory _bytes = bytes(_string);
        if (_bytes[0] >= 0x61 && _bytes[0] <= 0x7A) {
            _bytes[0] = bytes1(uint8(_bytes[0]) - 32);
        }
        return string(_bytes);
    }
}
base64.sol 62 lines
// SPDX-License-Identifier: MIT

/// @title Base64
/// @author Brecht Devos - <[email protected]>
/// @notice Provides a function for encoding some bytes in base64
library Base64 {
    string internal constant TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

    function encode(bytes memory data) internal pure returns (string memory) {
        if (data.length == 0) return '';
        
        // load the table into memory
        string memory table = TABLE;

        // multiply by 4/3 rounded up
        uint256 encodedLen = 4 * ((data.length + 2) / 3);

        // add some extra buffer at the end required for the writing
        string memory result = new string(encodedLen + 32);

        assembly {
            // set the actual output length
            mstore(result, encodedLen)
            
            // prepare the lookup table
            let tablePtr := add(table, 1)
            
            // input ptr
            let dataPtr := data
            let endPtr := add(dataPtr, mload(data))
            
            // result ptr, jump over length
            let resultPtr := add(result, 32)
            
            // run over the input, 3 bytes at a time
            for {} lt(dataPtr, endPtr) {}
            {
               dataPtr := add(dataPtr, 3)
               
               // read 3 bytes
               let input := mload(dataPtr)
               
               // write 4 characters
               mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F)))))
               resultPtr := add(resultPtr, 1)
               mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F)))))
               resultPtr := add(resultPtr, 1)
               mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr( 6, input), 0x3F)))))
               resultPtr := add(resultPtr, 1)
               mstore(resultPtr, shl(248, mload(add(tablePtr, and(        input,  0x3F)))))
               resultPtr := add(resultPtr, 1)
            }
            
            // padding with '='
            switch mod(mload(data), 3)
            case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) }
            case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) }
        }
        
        return result;
    }
}
IENS.sol 27 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IENS {
    function setOwner(bytes32 _node, address _owner) external;

    function setResolver(bytes32 _node, address _resolver) external;

    function setSubnodeRecord(
        bytes32 _node,
        bytes32 _label,
        address _owner,
        address _resolver,
        uint64 _ttl
    ) external;

    function setSubnodeOwner(
        bytes32 _node,
        bytes32 _label,
        address _owner
    ) external returns (bytes32);

    function owner(bytes32 _node) external view returns (address);

    function resolver(bytes32 _node) external view returns (address);
}
IPublicResolver.sol 20 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IPublicResolver {
    function setAddr(bytes32 _node, address _address) external;

    function addr(bytes32 _node) external view returns (address);

    function setText(
        bytes32 _node,
        string calldata _key,
        string calldata _value
    ) external;

    function text(bytes32 _node, string calldata _key)
        external
        view
        returns (string memory);
}
Address.sol 210 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);
    }

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private 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);
    }
}
Ownable.sol 71 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _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);
    }
}
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(to).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 {}
}
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;
}
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);
}
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);
}
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);
}

Read Contract

balanceOf 0x70a08231 → uint256
baseImageURI 0x74f82e30 → string
colors 0xc4c3262e → bool
contractURI 0xe8a3d485 → string
customImageURIs 0x11d1e1bb → string
ensPublicResolver 0x458955b8 → address
ensRegistry 0x7d73b231 → address
generation 0x17219522 → uint8
getApproved 0x081812fc → address
imageURI 0x8f742d16 → string
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
objects 0xb4b27a56 → bool
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
price 0xa035b1fe → uint256
rootNode 0xfaff50a8 → bytes32
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenInfos 0x7c13774b → string, string, uint8
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256

Write Contract 15 functions

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

addColors 0x17c2f94d
bytes32[] _colorHashes
addObjects 0x4c92c6a5
bytes32[] _objectHashes
approve 0x095ea7b3
address to
uint256 tokenId
changeBaseImageURI 0x4e3b515d
string baseImageURI_
changePrice 0xa2b40d19
uint256 price_
claimSubdomains 0x845a6e33
uint256[] _tokenIds
incrementGeneration 0xb917ade5
No parameters
mintItems 0xab5df1ca
string[] _colors
string[] _objects
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setCustomImageURI 0xbf71ece7
uint256 _tokenId
string _customImageURI
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address