Address Contract Partially Verified
Address
0x3113A3c04aEBEC2B77eB38Eabf6a2257B580c54B
Balance
0 ETH
Nonce
1
Code Size
15090 bytes
Creator
0xb487ac0c...637B at tx 0xa22553c6...102391
Indexed Transactions
0
Contract Bytecode
15090 bytes
0x6080604052600436106102ae5760003560e01c80636e1bd32311610175578063a2309ff8116100dc578063c87b56dd11610095578063e985e9c51161006f578063e985e9c51461084c578063f2fde38b14610895578063f95b496c146108b5578063ffe630b5146108d557600080fd5b8063c87b56dd14610804578063d0e30db014610824578063def601261461082c57600080fd5b8063a2309ff81461074d578063b45c768e14610763578063b650163714610783578063b80f55c9146107a4578063b88d4fde146107c4578063be6d8d58146107e457600080fd5b80638da5cb5b1161012e5780638da5cb5b1461069a57806395d89b41146106bd5780639d6dc791146106d25780639e08920b146106f25780639fbc82881461070d578063a22cb4651461072d57600080fd5b80636e1bd323146105fa57806370a082311461061057806371423c7814610630578063715018a6146106505780638746475a1461066557806387cda6b81461067a57600080fd5b80633ccfd60b1161021957806351858e27116101d257806351858e27146105585780635c975abb1461056d57806361acdaaf146105855780636352211e146105a557806363e34987146105c557806368bd580e146105e557600080fd5b80633ccfd60b146104ab5780633f4ba83a146104c057806340c10f19146104d557806342842e0e146105035780634a9a7864146105235780634b9557781461053857600080fd5b806323765cd51161026b57806323765cd51461039957806323b872dd146103d6578063278ecde1146103f657806328d39d4d146104165780632e1dfd10146104365780633b94f67c1461048b57600080fd5b806301ffc9a7146102b357806306fdde03146102e8578063081812fc1461030a578063095ea7b3146103425780630f7309e8146103645780631a2e971f14610379575b600080fd5b3480156102bf57600080fd5b506102d36102ce3660046133f8565b6108f5565b60405190151581526020015b60405180910390f35b3480156102f457600080fd5b506102fd610947565b6040516102df9190613582565b34801561031657600080fd5b5061032a6103253660046133df565b6109d9565b6040516001600160a01b0390911681526020016102df565b34801561034e57600080fd5b5061036261035d366004613296565b610a66565b005b34801561037057600080fd5b506102fd610b7c565b34801561038557600080fd5b506103626103943660046134c8565b610c0a565b3480156103a557600080fd5b506103b96103b43660046133df565b610cb6565b6040805193151584526020840192909252908201526060016102df565b3480156103e257600080fd5b506103626103f13660046131b4565b610d7f565b34801561040257600080fd5b506103626104113660046133df565b610db0565b34801561042257600080fd5b5061036261043136600461315e565b610f91565b34801561044257600080fd5b50600c54600d54600e54600f54610462939291906001600160a01b031684565b604080519485526020850193909352918301526001600160a01b031660608201526080016102df565b34801561049757600080fd5b50600b5461032a906001600160a01b031681565b3480156104b757600080fd5b5061036261100b565b3480156104cc57600080fd5b506103626110d0565b3480156104e157600080fd5b506104f56104f0366004613296565b611156565b6040519081526020016102df565b34801561050f57600080fd5b5061036261051e3660046131b4565b611287565b34801561052f57600080fd5b506102fd6112a2565b34801561054457600080fd5b50600a5461032a906001600160a01b031681565b34801561056457600080fd5b506103626112af565b34801561057957600080fd5b5060065460ff166102d3565b34801561059157600080fd5b506102fd6105a0366004613432565b611333565b3480156105b157600080fd5b5061032a6105c03660046133df565b611669565b3480156105d157600080fd5b506103626105e03660046131b4565b6116e0565b3480156105f157600080fd5b506103626117cd565b34801561060657600080fd5b506104f561138881565b34801561061c57600080fd5b506104f561062b36600461315e565b61183b565b34801561063c57600080fd5b5061036261064b3660046133c4565b6118c2565b34801561065c57600080fd5b50610362611941565b34801561067157600080fd5b506102d361197b565b34801561068657600080fd5b506102fd6106953660046133df565b6119d5565b3480156106a657600080fd5b5060065461010090046001600160a01b031661032a565b3480156106c957600080fd5b506102fd611acf565b3480156106de57600080fd5b506103626106ed3660046132c2565b611ade565b3480156106fe57600080fd5b5061139a546102d39060ff1681565b34801561071957600080fd5b50610362610728366004613370565b611c8c565b34801561073957600080fd5b50610362610748366004613261565b611e23565b34801561075957600080fd5b50611398546104f5565b34801561076f57600080fd5b5061036261077e3660046134b0565b611e32565b34801561078f57600080fd5b50600b546102d390600160a01b900460ff1681565b3480156107b057600080fd5b506103626107bf3660046132c2565b611f0a565b3480156107d057600080fd5b506103626107df3660046131f5565b611fe5565b3480156107f057600080fd5b506103626107ff36600461315e565b61201d565b34801561081057600080fd5b506102fd61081f3660046133df565b612097565b6103626121c6565b34801561083857600080fd5b50610362610847366004613467565b61225a565b34801561085857600080fd5b506102d361086736600461317b565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156108a157600080fd5b506103626108b036600461315e565b6122ce565b3480156108c157600080fd5b506103626108d0366004613304565b61236f565b3480156108e157600080fd5b506103626108f0366004613467565b6124c3565b60006001600160e01b031982166380ac58cd60e01b148061092657506001600160e01b03198216635b5e139f60e01b145b8061094157506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606000805461095690613943565b80601f016020809104026020016040519081016040528092919081815260200182805461098290613943565b80156109cf5780601f106109a4576101008083540402835291602001916109cf565b820191906000526020600020905b8154815290600101906020018083116109b257829003601f168201915b5050505050905090565b60006109e482612537565b610a4a5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610a7182611669565b9050806001600160a01b0316836001600160a01b03161415610adf5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610a41565b336001600160a01b0382161480610afb5750610afb8133610867565b610b6d5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610a41565b610b778383612554565b505050565b60088054610b8990613943565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb590613943565b8015610c025780601f10610bd757610100808354040283529160200191610c02565b820191906000526020600020905b815481529060010190602001808311610be557829003601f168201915b505050505081565b6006546001600160a01b0361010090910416331480610c485750600b546001600160a01b031615801590610c485750600b546001600160a01b031633145b610c645760405162461bcd60e51b8152600401610a41906136bc565b60008281526113996020526040908190208290555182907f600275bc3a309792283115dfb884cfc262977806bbf86a0cd92afdada40c960f90610caa9084815260200190565b60405180910390a25050565b6000806000610cc484612537565b610d105760405162461bcd60e51b815260206004820152601b60248201527f717565727920666f72206e6f6e6578697374656e7420746f6b656e00000000006044820152606401610a41565b600084815261139b60209081526040918290208251606081018452815480825260018301549382019390935260029091015460ff1615159281019290925215610d6657805160019450610d6390426138e2565b92505b828160200151610d7691906137e3565b93959294505050565b610d8933826125c2565b610da55760405162461bcd60e51b8152600401610a4190613719565b610b778383836126ac565b323314610dff5760405162461bcd60e51b815260206004820152601e60248201527f7468652063616c6c657220697320616e6f7468657220636f6e747261637400006044820152606401610a41565b60026007541415610e225760405162461bcd60e51b8152600401610a419061376a565b6002600755610e2f61197b565b610e745760405162461bcd60e51b81526020600482015260166024820152751c99599d5b99081a185cc81b9bdd08195b98589b195960521b6044820152606401610a41565b600e544711610ec55760405162461bcd60e51b815260206004820152601b60248201527f696e73756666696369656e7420636f6e74726163742066756e647300000000006044820152606401610a41565b600f5433906001600160a01b031681610edd84611669565b6001600160a01b031614610f035760405162461bcd60e51b8152600401610a419061368f565b610f0e828285611287565b600e546040516001600160a01b0384169180156108fc02916000818181858888f19350505050158015610f45573d6000803e3d6000fd5b5082816001600160a01b0316836001600160a01b03167fec1e5ed733e00f1a00915d56caef57b4f52312dde4f9b3165f213319a0da156b60405160405180910390a45050600160075550565b6006546001600160a01b03610100909104163314610fc15760405162461bcd60e51b8152600401610a41906136e4565b600a80546001600160a01b0319166001600160a01b0383169081179091556040517f1d29b414288888299889d5d99d65197ca6ea1126eb9da8ec68d4b6262eecf92290600090a250565b6006546001600160a01b0361010090910416331461103b5760405162461bcd60e51b8152600401610a41906136e4565b6002600754141561105e5760405162461bcd60e51b8152600401610a419061376a565b60026007556040514790339082156108fc029083906000818181858888f19350505050158015611092573d6000803e3d6000fd5b5060405181815233907f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243649060200160405180910390a2506001600755565b6006546001600160a01b036101009091041633146111005760405162461bcd60e51b8152600401610a41906136e4565b600b54600160a01b900460ff161561114c5760405162461bcd60e51b815260206004820152600f60248201526e18dbdb9d1c9858dd081cd9585b1959608a1b6044820152606401610a41565b611154612853565b565b600a546000906001600160a01b0316336001600160a01b03161461118c5760405162461bcd60e51b8152600401610a41906136bc565b61138861139854600161119f91906137e3565b11156111ed5760405162461bcd60e51b815260206004820152601c60248201527f6d696e7420776f756c6420657863656564206d617820737570706c79000000006044820152606401610a41565b61138882106112335760405162461bcd60e51b81526020600482015260126024820152711d1bdad95b9259081a5cc81a5b9d985b1a5960721b6044820152606401610a41565b600061123d6128e6565b90506112498482612a02565b61139880546001019055604051819084907f7d47a5e2d62ba81f792fcb4208de058d8a2282b8f934b7dddd48dce81c45952790600090a39392505050565b610b7783838360405180602001604052806000815250611fe5565b60098054610b8990613943565b6006546001600160a01b036101009091041633146112df5760405162461bcd60e51b8152600401610a41906136e4565b600b54600160a01b900460ff161561132b5760405162461bcd60e51b815260206004820152600f60248201526e18dbdb9d1c9858dd081cd9585b1959608a1b6044820152606401610a41565b611154612a1c565b805160609060005b81811080156113685750838181518110611357576113576139e2565b01602001516001600160f81b031916155b1561137f578061137781613978565b91505061133b565b6117e361138c82846138e2565b6113989061209f613884565b6113a29190613823565b6113ac90826137e3565b6113b79060016137e3565b915060008267ffffffffffffffff8111156113d4576113d46139f8565b6040519080825280601f01601f1916602001820160405280156113fe576020820181803683370190505b509050600080806114106001876138a3565b905060005b8851811015611501576114296001886138e2565b925088818151811061143d5761143d6139e2565b016020015160f81c93505b8183138061145b575063ffffffff841615155b156114ec57848381518110611472576114726139e2565b01602001516114869060f81c61010061385a565b6114949061ffff16856137fb565b93506114a1603a85613993565b60f81b8584815181106114b6576114b66139e2565b60200101906001600160f81b031916908160001a9053506114d8603a85613837565b9350826114e481613925565b935050611448565b829150806114f981613978565b915050611415565b50845b86811080156115315750848181518110611520576115206139e2565b01602001516001600160f81b031916155b15611548578061154081613978565b915050611504565b61155286826138e2565b855161155e91906138e2565b965060008767ffffffffffffffff81111561157b5761157b6139f8565b6040519080825280601f01601f1916602001820160405280156115a5576020820181803683370190505b50905060005b8881101561165b576000886115c085846137e3565b6115ca91906138e2565b90506040518060600160405280603a8152602001613a83603a91398882815181106115f7576115f76139e2565b0160200151815160f89190911c908110611613576116136139e2565b602001015160f81c60f81b838381518110611630576116306139e2565b60200101906001600160f81b031916908160001a90535050808061165390613978565b9150506115ab565b509998505050505050505050565b6000818152600260205260408120546001600160a01b0316806109415760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610a41565b600260075414156117035760405162461bcd60e51b8152600401610a419061376a565b60026007553361171282611669565b6001600160a01b0316146117385760405162461bcd60e51b8152600401610a419061368f565b600081815261139b60205260409020600201805460ff19166001179055611760838383611287565b600081815261139b6020526040902060028101805460ff1916905554156117c35780826001600160a01b0316846001600160a01b03167f61c64217eba467750103bed82b0fd9b233a82982d7c2b92890a533c3bdeea9d060405160405180910390a45b5050600160075550565b6006546001600160a01b036101009091041633146117fd5760405162461bcd60e51b8152600401610a41906136e4565b600b805460ff60a01b1916600160a01b1790556040517fa0058887862c892ade184993a48c672897bca2e36ebf7fa2b4703d4805fc3a0190600090a1565b60006001600160a01b0382166118a65760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610a41565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b036101009091041633146118f25760405162461bcd60e51b8152600401610a41906136e4565b61139a805460ff191682151590811790915560405160ff909116151581527f32789a86aec7270567b3c09721a2fc80b6184b286f59ddcee39fac6d005ff6a8906020015b60405180910390a150565b6006546001600160a01b036101009091041633146119715760405162461bcd60e51b8152600401610a41906136e4565b6111546000612a97565b600d54600090158015906119905750600d5442115b1561199b5750600090565b600c54158015906119ad5750600c5442115b80156119ba5750600e5415155b80156119d05750600f546001600160a01b031615155b905090565b604080516022808252606082810190935260009190602082018180368337019050509050601260f81b81600081518110611a1157611a116139e2565b60200101906001600160f81b031916908160001a905350602060f81b81600181518110611a4057611a406139e2565b60200101906001600160f81b031916908160001a90535060005b6020811015611abe57838160208110611a7557611a756139e2565b1a60f81b82611a858360026137e3565b81518110611a9557611a956139e2565b60200101906001600160f81b031916908160001a90535080611ab681613978565b915050611a5a565b50611ac881611333565b9392505050565b60606001805461095690613943565b6006546001600160a01b0361010090910416331480611b1c5750600b546001600160a01b031615801590611b1c5750600b546001600160a01b031633145b611b385760405162461bcd60e51b8152600401610a41906136bc565b60005b81811015610b77576000838383818110611b5757611b576139e2565b905060200201359050611b6981612537565b611bb55760405162461bcd60e51b815260206004820152601d60248201527f6f70657261746520666f72206e6f6e6578697374656e7420746f6b656e0000006044820152606401610a41565b600081815261139b602052604090208054611c0b5760405162461bcd60e51b8152602060048201526016602482015275189c995dda5b99c81a5cc81b9bdd081cdd185c9d195960521b6044820152606401610a41565b8054600182018054429290920390910190556000808255604051339184917ef25bb85d4ee0049e27f26caf7cfdf51c09e265de39eca999ea916e53d5b7229190a360405182907f5103d8f4f6c8d8204928ccb8ad539733e261cf64f4ddbd44370250e6bbdeec4990600090a250508080611c8490613978565b915050611b3b565b60026007541415611caf5760405162461bcd60e51b8152600401610a419061376a565b600260075560005b82811015611e18576000848483818110611cd357611cd36139e2565b905060200201359050611ce33390565b6001600160a01b0316611cf582611669565b6001600160a01b031614611d1b5760405162461bcd60e51b8152600401610a419061368f565b600081815261139b602052604090208054848015611d37575080155b15611dbd5761139a5460ff16611d885760405162461bcd60e51b8152602060048201526016602482015275189c995dda5b99c81a5cc81b9bdd08185b1b1bddd95960521b6044820152606401610a41565b428255604051339084907f9ea18c395203d5b46e55fc17be0e20d9c82d60586a1bbc30522ea292003453bf90600090a3611e0d565b84158015611dcb5750600081115b15611e0d57600182018054428390030190556000808355604051339185917ef25bb85d4ee0049e27f26caf7cfdf51c09e265de39eca999ea916e53d5b7229190a35b505050600101611cb7565b505060016007555050565b611e2e338383612af1565b5050565b6006546001600160a01b03610100909104163314611e625760405162461bcd60e51b8152600401610a41906136e4565b6000611e74608083016060840161315e565b6001600160a01b03161415611ecb5760405162461bcd60e51b815260206004820152601760248201527f62656e65666963696172792069732072657175697265640000000000000000006044820152606401610a41565b80600c611ed88282613a0e565b9050507f0c73d714b0713a4e0f7586a279e2910a7bb42754cd803092c43734493bda1d498160405161193691906137a1565b6006546001600160a01b03610100909104163314611f3a5760405162461bcd60e51b8152600401610a41906136e4565b60026007541415611f5d5760405162461bcd60e51b8152600401610a419061376a565b600260075560005b818110156117c3576000838383818110611f8157611f816139e2565b905060200201359050611f913390565b6001600160a01b0316611fa382611669565b6001600160a01b031614611fc95760405162461bcd60e51b8152600401610a419061368f565b611fd281612bc0565b5080611fdd81613978565b915050611f65565b611fef33836125c2565b61200b5760405162461bcd60e51b8152600401610a4190613719565b61201784848484612c67565b50505050565b6006546001600160a01b0361010090910416331461204d5760405162461bcd60e51b8152600401610a41906136e4565b600b80546001600160a01b0319166001600160a01b0383169081179091556040517f5f000c8ffdab0f90a947ce0e76033315e60bd358a0995d362e157f587f1a0a2390600090a250565b60606120a282612537565b6120ee5760405162461bcd60e51b815260206004820152601b60248201527f717565727920666f72206e6f6e6578697374656e7420746f6b656e00000000006044820152606401610a41565b6000828152611399602052604090205480612196576009805461211090613943565b80601f016020809104026020016040519081016040528092919081815260200182805461213c90613943565b80156121895780601f1061215e57610100808354040283529160200191612189565b820191906000526020600020905b81548152906001019060200180831161216c57829003601f168201915b5050505050915050919050565b61219f816119d5565b6040516020016121af9190613516565b604051602081830303815290604052915050919050565b6006546001600160a01b036101009091041633146121f65760405162461bcd60e51b8152600401610a41906136e4565b600260075414156122195760405162461bcd60e51b8152600401610a419061376a565b600260075560405134815233907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200160405180910390a26001600755565b6006546001600160a01b0361010090910416331461228a5760405162461bcd60e51b8152600401610a41906136e4565b805161229d906009906020840190612fce565b507f912509518a3aad94b6defb989c176d5c3e8dfde19dc0d77cad24d6cd8a06bc8060096040516119369190613595565b6006546001600160a01b036101009091041633146122fe5760405162461bcd60e51b8152600401610a41906136e4565b6001600160a01b0381166123635760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a41565b61236c81612a97565b50565b6006546001600160a01b03610100909104163314806123ad5750600b546001600160a01b0316158015906123ad5750600b546001600160a01b031633145b6123c95760405162461bcd60e51b8152600401610a41906136bc565b82811461242b5760405162461bcd60e51b815260206004820152602a60248201527f746f6b656e4964735f20616e6420746f6b656e4861736865735f206c656e67746044820152690d040dad2e6dac2e8c6d60b31b6064820152608401610a41565b826124655760405162461bcd60e51b815260206004820152600a6024820152691b9bc81d1bdad95b925960b21b6044820152606401610a41565b60005b838110156124bc576124aa858583818110612485576124856139e2565b9050602002013584848481811061249e5761249e6139e2565b90506020020135610c0a565b806124b481613978565b915050612468565b5050505050565b6006546001600160a01b036101009091041633146124f35760405162461bcd60e51b8152600401610a41906136e4565b8051612506906008906020840190612fce565b507f638b2296aed59fe9e4f72c7536065ba3e36cb7690c2d130f66334da9cc2406cf60086040516119369190613595565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061258982611669565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006125cd82612537565b61262e5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a41565b600061263983611669565b9050806001600160a01b0316846001600160a01b031614806126745750836001600160a01b0316612669846109d9565b6001600160a01b0316145b806126a457506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166126bf82611669565b6001600160a01b0316146127235760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610a41565b6001600160a01b0382166127855760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a41565b612790838383612c9a565b61279b600082612554565b6001600160a01b03831660009081526003602052604081208054600192906127c49084906138e2565b90915550506001600160a01b03821660009081526003602052604081208054600192906127f29084906137e3565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60065460ff1661289c5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610a41565b6006805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b61139854604080516000194301406020808301919091524482840152426060808401919091526bffffffffffffffffffffffff1941821b81166080850152609484018690523290911b1660b4830152825180830360a801815260c8909201909252805191012060009161138803908290829081612965576129656139cc565b0690506000601082611388811061297e5761297e6139e2565b0154156129a0576010826113888110612999576129996139e2565b01546129a2565b815b905060106001840361138881106129bb576129bb6139e2565b0154156129e05760106001840361138881106129d9576129d96139e2565b01546129e5565b600183035b60108361138881106129f9576129f96139e2565b01559392505050565b611e2e828260405180602001604052806000815250612d4f565b60065460ff1615612a625760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a41565b6006805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586128c93390565b600680546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03161415612b535760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a41565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6000612bcb82611669565b9050612bd981600084612c9a565b612be4600083612554565b6001600160a01b0381166000908152600360205260408120805460019290612c0d9084906138e2565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b612c728484846126ac565b612c7e84848484612d82565b6120175760405162461bcd60e51b8152600401610a419061363d565b60065460ff1615612ce55760405162461bcd60e51b81526020600482015260156024820152741d1bdad95b881d1c985b9cd9995c881c185d5cd959605a1b6044820152606401610a41565b600081815261139b602052604090206002015460ff16610b7757600081815261139b602052604090205415610b775760405162461bcd60e51b815260206004820152601060248201526f746f6b656e2069732062726577696e6760801b6044820152606401610a41565b612d598383612e8f565b612d666000848484612d82565b610b775760405162461bcd60e51b8152600401610a419061363d565b60006001600160a01b0384163b15612e8457604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612dc6903390899088908890600401613545565b602060405180830381600087803b158015612de057600080fd5b505af1925050508015612e10575060408051601f3d908101601f19168201909252612e0d91810190613415565b60015b612e6a573d808015612e3e576040519150601f19603f3d011682016040523d82523d6000602084013e612e43565b606091505b508051612e625760405162461bcd60e51b8152600401610a419061363d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506126a4565b506001949350505050565b6001600160a01b038216612ee55760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a41565b612eee81612537565b15612f3b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a41565b612f4760008383612c9a565b6001600160a01b0382166000908152600360205260408120805460019290612f709084906137e3565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054612fda90613943565b90600052602060002090601f016020900481019282612ffc5760008555613042565b82601f1061301557805160ff1916838001178555613042565b82800160010185558215613042579182015b82811115613042578251825591602001919060010190613027565b5061304e929150613052565b5090565b5b8082111561304e5760008155600101613053565b600067ffffffffffffffff80841115613082576130826139f8565b604051601f8501601f19908116603f011681019082821181831017156130aa576130aa6139f8565b816040528093508581528686860111156130c357600080fd5b858560208301376000602087830101525050509392505050565b60008083601f8401126130ef57600080fd5b50813567ffffffffffffffff81111561310757600080fd5b6020830191508360208260051b850101111561312257600080fd5b9250929050565b8035801515811461313957600080fd5b919050565b600082601f83011261314f57600080fd5b611ac883833560208501613067565b60006020828403121561317057600080fd5b8135611ac881613a57565b6000806040838503121561318e57600080fd5b823561319981613a57565b915060208301356131a981613a57565b809150509250929050565b6000806000606084860312156131c957600080fd5b83356131d481613a57565b925060208401356131e481613a57565b929592945050506040919091013590565b6000806000806080858703121561320b57600080fd5b843561321681613a57565b9350602085013561322681613a57565b925060408501359150606085013567ffffffffffffffff81111561324957600080fd5b6132558782880161313e565b91505092959194509250565b6000806040838503121561327457600080fd5b823561327f81613a57565b915061328d60208401613129565b90509250929050565b600080604083850312156132a957600080fd5b82356132b481613a57565b946020939093013593505050565b600080602083850312156132d557600080fd5b823567ffffffffffffffff8111156132ec57600080fd5b6132f8858286016130dd565b90969095509350505050565b6000806000806040858703121561331a57600080fd5b843567ffffffffffffffff8082111561333257600080fd5b61333e888389016130dd565b9096509450602087013591508082111561335757600080fd5b50613364878288016130dd565b95989497509550505050565b60008060006040848603121561338557600080fd5b833567ffffffffffffffff81111561339c57600080fd5b6133a8868287016130dd565b90945092506133bb905060208501613129565b90509250925092565b6000602082840312156133d657600080fd5b611ac882613129565b6000602082840312156133f157600080fd5b5035919050565b60006020828403121561340a57600080fd5b8135611ac881613a6c565b60006020828403121561342757600080fd5b8151611ac881613a6c565b60006020828403121561344457600080fd5b813567ffffffffffffffff81111561345b57600080fd5b6126a48482850161313e565b60006020828403121561347957600080fd5b813567ffffffffffffffff81111561349057600080fd5b8201601f810184136134a157600080fd5b6126a484823560208401613067565b6000608082840312156134c257600080fd5b50919050565b600080604083850312156134db57600080fd5b50508035926020909101359150565b600081518084526135028160208601602086016138f9565b601f01601f19169290920160200192915050565b66697066733a2f2f60c81b8152600082516135388160078501602087016138f9565b9190910160070192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613578908301846134ea565b9695505050505050565b602081526000611ac860208301846134ea565b600060208083526000845481600182811c9150808316806135b757607f831692505b8583108114156135d557634e487b7160e01b85526022600452602485fd5b8786018381526020018180156135f257600181146136035761362e565b60ff1986168252878201965061362e565b60008b81526020902060005b868110156136285781548482015290850190890161360f565b83019750505b50949998505050505050505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526013908201527231b0b63632b91034b9903737ba1037bbb732b960691b604082015260600190565b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b8135815260208083013590820152604080830135908201526080810160608301356137cb81613a57565b6001600160a01b031660609290920191909152919050565b600082198211156137f6576137f66139b6565b500190565b600063ffffffff80831681851680830382111561381a5761381a6139b6565b01949350505050565b600082613832576138326139cc565b500490565b600063ffffffff8084168061384e5761384e6139cc565b92169190910492915050565b600061ffff8083168185168183048111821515161561387b5761387b6139b6565b02949350505050565b600081600019048311821515161561389e5761389e6139b6565b500290565b60008083128015600160ff1b8501841216156138c1576138c16139b6565b6001600160ff1b03840183138116156138dc576138dc6139b6565b50500390565b6000828210156138f4576138f46139b6565b500390565b60005b838110156139145781810151838201526020016138fc565b838111156120175750506000910152565b6000600160ff1b82141561393b5761393b6139b6565b506000190190565b600181811c9082168061395757607f821691505b602082108114156134c257634e487b7160e01b600052602260045260246000fd5b600060001982141561398c5761398c6139b6565b5060010190565b600063ffffffff808416806139aa576139aa6139cc565b92169190910692915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b813581556020820135600182015560408201356002820155600381016060830135613a3881613a57565b81546001600160a01b0319166001600160a01b03919091161790555050565b6001600160a01b038116811461236c57600080fd5b6001600160e01b03198116811461236c57600080fdfe31323334353637383941424344454647484a4b4c4d4e505152535455565758595a6162636465666768696a6b6d6e6f707172737475767778797aa26469706673582212205284f4a8bf8a7b2d6c28332deb1bdf7db28a27c78fcdc62fbc73fa5138cfd7f064736f6c63430008070033
Verified Source Code Partial Match
Compiler: v0.8.7+commit.e28d00a7
EVM: london
Optimization: Yes (200 runs)
CheersUp.sol 526 lines
// SPDX-License-Identifier: MIT
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
/*
____ _ _
| _ \ | | | |
| |_) | __ _ ___ ___ | | __ _| |__ ___
| _ < / _` / __|/ _ \ | | / _` | '_ \/ __|
| |_) | (_| \__ \ __/ | |___| (_| | |_) \__ \
|____/ \__,_|___/\___| |______\__,_|_.__/|___/
*/
pragma solidity ^0.8.7;
/**
* @title Crypto
* @author BaseLabs
*/
contract Crypto {
bytes constant ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
/**
* @notice base58 is used to calculate the base58 encoded value of given bytes.
* This algorithm was migrated from github.com/mr-tron/base58 to solidity by our developers.
* Note that it is not yet optimized for gas, so please use it only in read-only scenarios.
* @param data_ bytes.
* @return base58 encoded results.
*/
function base58(bytes memory data_) public pure returns (bytes memory){
uint256 size = data_.length;
uint256 zeroCount;
while (zeroCount < size && data_[zeroCount] == 0) {
zeroCount++;
}
size = zeroCount + (size - zeroCount)*8351/6115+1;
bytes memory slot = new bytes(size);
uint32 carry;
int256 m;
int256 high = int256(size) - 1;
for (uint256 i = 0; i < data_.length; i++) {
m = int256(size - 1);
for (carry = uint8(data_[i]); m > high || carry != 0; m--) {
carry = carry + 256 * uint8(slot[uint256(m)]);
slot[uint256(m)] = bytes1(uint8(carry % 58));
carry /= 58;
}
high = m;
}
uint256 n;
for (n = zeroCount; n < size && slot[n] == 0; n++) {}
size = slot.length - (n - zeroCount);
bytes memory out = new bytes(size);
for (uint256 i = 0; i < size; i++) {
uint256 j = i + n - zeroCount;
out[i] = ALPHABET[uint8(slot[j])];
}
return out;
}
/**
* @notice cidv0 is used to convert sha256 hash to cid(v0) used by IPFS.
* @param sha256Hash_ sha256 hash generated by anything.
* @return IPFS cid that meets the version0 specification.
*/
function cidv0(bytes32 sha256Hash_) public pure returns (string memory) {
bytes memory hashString = new bytes(34);
hashString[0] = 0x12;
hashString[1] = 0x20;
for (uint256 i = 0; i < sha256Hash_.length; i++) {
hashString[i+2] = sha256Hash_[i];
}
return string(base58(hashString));
}
}
/**
* @title CheersUp
* @author BaseLabs
*/
contract CheersUp is ERC721, Pausable, Ownable, ReentrancyGuard, Crypto {
event RevealingURIChanged(string uri);
event Refunded(address indexed from, address indexed to, uint256 indexed tokenId);
event CheersUpRevealed(uint256 indexed cucpTokenId, uint256 indexed cheersUpTokenId);
event TokenHashSet(uint256 indexed tokenId, bytes32 tokenHash);
event ProvenanceUpdated(string procenance);
event Withdraw(address indexed account, uint256 amount);
event Deposit(address indexed account, uint256 amount);
event CUCPContractAddressChanged(address indexed contractAddress);
event MaintainerAddressChanged(address indexed maintainer);
event RefundConfigChanged(RefundConfig config);
event ContractSealed();
struct RefundConfig {
uint256 startTime;
uint256 endTime;
uint256 price;
address beneficiary;
}
uint256 public constant MAX_TOKEN = 5000;
string public provenance;
string public revealingURI;
address public cucpContractAddress;
address public maintainerAddress;
bool public contractSealed;
RefundConfig public refundConfig;
uint256[MAX_TOKEN] internal _randIndices;
uint256 private _numberMinted;
mapping(uint256 => bytes32) private _tokenHashes;
constructor(
string memory revealingURI_,
address cucpContractAddress_,
address maintainerAddress_,
string memory provenance_
) ERC721("Cheers UP", "CUP") {
revealingURI = revealingURI_;
cucpContractAddress = cucpContractAddress_;
maintainerAddress = maintainerAddress_;
provenance = provenance_;
}
/***********************************|
| Core |
|__________________________________*/
/**
* @notice mint is used to randomly generate a token for address_.
* It can only be called by the CheersUpPeriod contract.
* @param address_ specify which address will get the token.
* @param cucpTokenId_ defines which tokenId in the CheersUpPeriod contract this call originates from.
* @return randomly generated TokenId
*/
function mint(address address_, uint256 cucpTokenId_) public returns(uint256) {
require(_msgSender() == cucpContractAddress, "not authorized");
require(_numberMinted + 1 <= MAX_TOKEN, "mint would exceed max supply");
require(cucpTokenId_ < MAX_TOKEN, "tokenId is invalid");
uint256 tokenId = getRandomTokenId();
_safeMint(address_, tokenId);
unchecked {
_numberMinted += 1;
}
emit CheersUpRevealed(cucpTokenId_, tokenId);
return tokenId;
}
/**
* @notice getRandomTokenId is used to randomly select an unused tokenId.
* @return randomly selected tokenId.
*/
function getRandomTokenId() internal returns (uint256) {
unchecked {
uint256 remain = MAX_TOKEN - _numberMinted;
uint256 pos = unsafeRandom() % remain;
uint256 val = _randIndices[pos] == 0 ? pos : _randIndices[pos];
_randIndices[pos] = _randIndices[remain - 1] == 0 ? remain - 1 : _randIndices[remain - 1];
return val;
}
}
/**
* @notice unsafeRandom is used to generate a random number by on-chain randomness.
* Please note that on-chain random is potentially manipulated by miners, and most scenarios suggest using VRF.
* @return randomly generated number.
*/
function unsafeRandom() internal view returns (uint256) {
unchecked {
return uint256(keccak256(abi.encodePacked(
blockhash(block.number-1),
block.difficulty,
block.timestamp,
block.coinbase,
_numberMinted,
tx.origin
)));
}
}
/**
* @notice The NFT holder can use this method to perform refund token
* and a certain amount of ETH will be sent to the caller.
* @param tokenId_ which token to refund
*/
function refund(uint256 tokenId_) external callerIsUser nonReentrant {
require(isRefundEnabled(), "refund has not enabled");
require(address(this).balance > refundConfig.price, "insufficient contract funds");
address from = _msgSender();
address to = refundConfig.beneficiary;
require(ownerOf(tokenId_) == from, "caller is not owner");
safeTransferFrom(from, to, tokenId_);
payable(from).transfer(refundConfig.price);
emit Refunded(from, to, tokenId_);
}
/**
* @notice issuer have permission to burn token.
* @param tokenIds_ list of tokenId
*/
function burn(uint256[] calldata tokenIds_) external onlyOwner nonReentrant {
for (uint256 i = 0; i < tokenIds_.length; i++) {
uint256 tokenId = tokenIds_[i];
require(ownerOf(tokenId) == _msgSender(), "caller is not owner");
_burn(tokenId);
}
}
/**
* @notice issuer have permission to deposit ETH into the contract, which is used to support the refund logic.
*/
function deposit() external payable onlyOwner nonReentrant {
emit Deposit(_msgSender(), msg.value);
}
/**
* @notice issuer withdraws the ETH temporarily stored in the contract through this method.
*/
function withdraw() external onlyOwner nonReentrant {
uint256 balance = address(this).balance;
payable(_msgSender()).transfer(balance);
emit Withdraw(_msgSender(), balance);
}
/***********************************|
| Brewing |
|__________________________________*/
event BrewingStarted(uint256 indexed tokenId, address indexed account);
event BrewingStopped(uint256 indexed tokenId, address indexed account);
event BrewingInterrupted(uint256 indexed tokenId);
event BrewingTokenTransfered(address indexed from, address indexed to, uint256 indexed tokenId);
event BrewingAllowedFlagChanged(bool isBrewingAllowed);
struct BrewingStatus {
uint256 lastStartTime;
uint256 total;
bool brewingTransferLockTempRelease;
}
bool public isBrewingAllowed;
mapping(uint256 => BrewingStatus) private _brewingStatuses;
/**
* @notice safeTransferWhileBrewing is used to safely transfer tokens without changing the brewing state.
* @param from_ cannot be the zero address.
* @param to_ cannot be the zero address.
* @param tokenId_ token must exist and be owned by `from`.
*/
function safeTransferWhileBrewing(address from_, address to_, uint256 tokenId_) external nonReentrant {
require(ownerOf(tokenId_) == _msgSender(), "caller is not owner");
_brewingStatuses[tokenId_].brewingTransferLockTempRelease = true;
safeTransferFrom(from_, to_, tokenId_);
_brewingStatuses[tokenId_].brewingTransferLockTempRelease = false;
if (_brewingStatuses[tokenId_].lastStartTime != 0) {
emit BrewingTokenTransfered(from_, to_, tokenId_);
}
}
/**
* @notice setIsBrewingAllowed is used to set the global switch to control whether users are allowed to brew.
* @param isBrewingAllowed_ set to true to allow
*/
function setIsBrewingAllowed(bool isBrewingAllowed_) external onlyOwner {
isBrewingAllowed = isBrewingAllowed_;
emit BrewingAllowedFlagChanged(isBrewingAllowed);
}
/**
* @notice getTokenBrewingStatus is used to get the detailed brewing status of a specific token.
* @param tokenId_ token id
* @return isBrewing_ whether the current token is brewing.
* @return current_ how long the token has been brewing in the hands of the current hodler.
* @return total_ total amount of brewing since the token minted.
*/
function getTokenBrewingStatus(uint256 tokenId_) external view returns (bool isBrewing_, uint256 current_, uint256 total_) {
require(_exists(tokenId_), "query for nonexistent token");
BrewingStatus memory status = _brewingStatuses[tokenId_];
if (status.lastStartTime != 0) {
isBrewing_ = true;
current_ = block.timestamp - status.lastStartTime;
}
total_ = status.total + current_;
}
/**
* @notice setTokenBrewingState is used to modify the Brewing state of the Token,
* only the Owner of the Token has this permission.
* @param tokenIds_ list of tokenId
* @param state_ If true, brew will be started. If false, brew will be stopped.
*/
function setTokenBrewingState(uint256[] calldata tokenIds_, bool state_) external nonReentrant {
unchecked {
for (uint256 i = 0; i < tokenIds_.length; i++) {
uint256 tokenId = tokenIds_[i];
require(ownerOf(tokenId) == _msgSender(), "caller is not owner");
BrewingStatus storage status = _brewingStatuses[tokenId];
uint256 lastStartTime = status.lastStartTime;
if (state_ && lastStartTime == 0) {
require(isBrewingAllowed, "brewing is not allowed");
status.lastStartTime = block.timestamp;
emit BrewingStarted(tokenId, _msgSender());
} else if (!state_ && lastStartTime > 0) {
status.total += block.timestamp - lastStartTime;
status.lastStartTime = 0;
emit BrewingStopped(tokenId, _msgSender());
}
}
}
}
/**
* @notice interruptTokenBrewing gives the issuer the right to forcibly interrupt the brewing state of the token.
* One scenario of using it is: someone may maliciously place low-priced brewing tokens on
* the secondary market (because brewing tokens cannot be traded).
* @param tokenIds_ the tokenId list to operate
*/
function interruptTokenBrewing(uint256[] calldata tokenIds_) external atLeastMaintainer {
for (uint256 i = 0; i < tokenIds_.length; i++) {
uint256 tokenId = tokenIds_[i];
require(_exists(tokenId), "operate for nonexistent token");
BrewingStatus storage status = _brewingStatuses[tokenId];
require(status.lastStartTime != 0, "brewing is not started");
unchecked {
status.total += block.timestamp - status.lastStartTime;
status.lastStartTime = 0;
}
emit BrewingStopped(tokenId, _msgSender());
emit BrewingInterrupted(tokenId);
}
}
/***********************************|
| Getter |
|__________________________________*/
/**
* @notice totalMinted is used to return the total number of tokens minted.
* Note that it does not decrease as the token is burnt.
*/
function totalMinted() public view returns (uint256) {
return _numberMinted;
}
/**
* @notice isRevealEnabled is used to return whether the refund has been enabled
*/
function isRefundEnabled() public view returns (bool) {
if (refundConfig.endTime > 0 && block.timestamp > refundConfig.endTime) {
return false;
}
return refundConfig.startTime > 0 &&
block.timestamp > refundConfig.startTime &&
refundConfig.price > 0 &&
refundConfig.beneficiary != address(0);
}
/**
* @notice tokenURI will return the URI of the metadata of the token,
* if the Token has not completed reveal, then it will return the revealingURI.
* @return metadata uri
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "query for nonexistent token");
bytes32 hash = _tokenHashes[tokenId];
if (hash == "") {
return revealingURI;
}
return string(abi.encodePacked("ipfs://", cidv0(hash)));
}
/***********************************|
| Setter |
|__________________________________*/
/**
* @notice setProvenance is used to allow the issuer to modify the provenance in special cases.
* This process is under the supervision of the community.
*/
function setProvenance(string memory provenance_) external onlyOwner {
provenance = provenance_;
emit ProvenanceUpdated(provenance);
}
/**
* @notice setRevealingURI is used to allow the issuer to modify the revealingURI in special cases.
* This process is under the supervision of the community.
*/
function setRevealingURI(string memory revealingURI_) external onlyOwner {
revealingURI = revealingURI_;
emit RevealingURIChanged(revealingURI);
}
/**
* @notice setCUCPContractAddress is used to allow the issuer to modify the cucpContractAddress in special cases.
* This process is under the supervision of the community.
*/
function setCUCPContractAddress(address address_) external onlyOwner {
cucpContractAddress = address_;
emit CUCPContractAddressChanged(address_);
}
/**
* @notice setMaintainerAddress is used to allow the issuer to modify the maintainerAddress
*/
function setMaintainerAddress(address maintainerAddress_) external onlyOwner {
maintainerAddress = maintainerAddress_;
emit MaintainerAddressChanged(maintainerAddress_);
}
/**
* @notice setRefundConfig allows issuer to set refundConfig
*/
function setRefundConfig(RefundConfig calldata config_) external onlyOwner {
require(config_.beneficiary != address(0), "beneficiary is required");
refundConfig = config_;
emit RefundConfigChanged(config_);
}
/**
* @notice setTokenHash is used to set the ipfs hash of the token
* This process is under the supervision of the community.
*/
function setTokenHash(uint256 tokenId_, bytes32 tokenHash_) public atLeastMaintainer {
_tokenHashes[tokenId_] = tokenHash_;
emit TokenHashSet(tokenId_, tokenHash_);
}
/**
* @notice similar to setTokenHash, but in bulk
*/
function batchSetTokenHash(uint256[] calldata tokenIds_, bytes32[] calldata tokenHashes_) external atLeastMaintainer {
require(tokenIds_.length == tokenHashes_.length, "tokenIds_ and tokenHashes_ length mismatch");
require(tokenIds_.length > 0, "no tokenId");
for (uint256 i = 0; i < tokenIds_.length; i++) {
setTokenHash(tokenIds_[i], tokenHashes_[i]);
}
}
/***********************************|
| Pause & Hooks |
|__________________________________*/
/**
* @notice hook function, used to intercept the transfer of token.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
require(!paused(), "token transfer paused");
if (!_brewingStatuses[tokenId].brewingTransferLockTempRelease) {
require(_brewingStatuses[tokenId].lastStartTime == 0, "token is brewing");
}
super._beforeTokenTransfer(from, to, tokenId);
}
/**
* @notice for the purpose of protecting user assets, under extreme conditions,
* the circulation of all tokens in the contract needs to be frozen.
* This process is under the supervision of the community.
*/
function emergencyPause() external onlyOwner notSealed {
_pause();
}
/**
* @notice unpause the contract
*/
function unpause() external onlyOwner notSealed {
_unpause();
}
/**
* @notice when the project is stable enough, the issuer will call sealContract
* to give up the permission to call emergencyPause and unpause.
*/
function sealContract() external onlyOwner {
contractSealed = true;
emit ContractSealed();
}
/***********************************|
| Modifier |
|__________________________________*/
/**
* @notice for security reasons, CA is not allowed to call sensitive methods.
*/
modifier callerIsUser() {
require(tx.origin == _msgSender(), "the caller is another contract");
_;
}
/**
* @notice function call is only allowed when the contract has not been sealed
*/
modifier notSealed() {
require(!contractSealed, "contract sealed");
_;
}
/**
* @notice only owner or maintainer has the permission to call this method
*/
modifier atLeastMaintainer() {
require(owner() == _msgSender() ||
(maintainerAddress != address(0) && maintainerAddress == _msgSender()),
"not authorized");
_;
}
}
// QmWYifytzWVJdoaacoKJWBbe7BVJ4pR47VBmB6FSMFa4dB
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @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
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
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() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Pausable.sol 91 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
ERC721.sol 447 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol)
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 {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(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);
_afterTokenTransfer(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 from incorrect owner");
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);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
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;
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
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 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
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);
}
Read Contract
MAX_TOKEN 0x6e1bd323 → uint256
balanceOf 0x70a08231 → uint256
base58 0x61acdaaf → bytes
cidv0 0x87cda6b8 → string
contractSealed 0xb6501637 → bool
cucpContractAddress 0x4b955778 → address
getApproved 0x081812fc → address
getTokenBrewingStatus 0x23765cd5 → bool, uint256, uint256
isApprovedForAll 0xe985e9c5 → bool
isBrewingAllowed 0x9e08920b → bool
isRefundEnabled 0x8746475a → bool
maintainerAddress 0x3b94f67c → address
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
provenance 0x0f7309e8 → string
refundConfig 0x2e1dfd10 → uint256, uint256, uint256, address
revealingURI 0x4a9a7864 → string
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalMinted 0xa2309ff8 → uint256
Write Contract 26 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
batchSetTokenHash 0xf95b496c
uint256[] tokenIds_
bytes32[] tokenHashes_
burn 0xb80f55c9
uint256[] tokenIds_
deposit 0xd0e30db0
No parameters
emergencyPause 0x51858e27
No parameters
interruptTokenBrewing 0x9d6dc791
uint256[] tokenIds_
mint 0x40c10f19
address address_
uint256 cucpTokenId_
returns: uint256
refund 0x278ecde1
uint256 tokenId_
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
safeTransferWhileBrewing 0x63e34987
address from_
address to_
uint256 tokenId_
sealContract 0x68bd580e
No parameters
setApprovalForAll 0xa22cb465
address operator
bool approved
setCUCPContractAddress 0x28d39d4d
address address_
setIsBrewingAllowed 0x71423c78
bool isBrewingAllowed_
setMaintainerAddress 0xbe6d8d58
address maintainerAddress_
setProvenance 0xffe630b5
string provenance_
setRefundConfig 0x81c9151e
tuple config_
setRevealingURI 0xdef60126
string revealingURI_
setTokenBrewingState 0x9fbc8288
uint256[] tokenIds_
bool state_
setTokenHash 0x1a2e971f
uint256 tokenId_
bytes32 tokenHash_
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address