Address Contract Verified
Address
0x519fB7eE9C0B6B1c4EBAc7a5B480337a9A0976b7
Balance
0 ETH
Nonce
1
Code Size
10479 bytes
Creator
0xBECcA544...0317 at tx 0x1f8b91e4...110c0c
Indexed Transactions
0
Contract Bytecode
10479 bytes
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c80636352211e11610104578063b88d4fde116100a2578063e6b11e4c11610071578063e6b11e4c146103b9578063e6fe95ba146103c1578063e985e9c5146103e3578063f2fde38b146103f6576101cf565b8063b88d4fde14610378578063c87b56dd1461038b578063d68756381461039e578063d8258d95146103b1576101cf565b80638da5cb5b116100de5780638da5cb5b1461033557806395d89b411461033d578063a22cb46514610345578063a654ae0714610358576101cf565b80636352211e1461030757806370a082311461031a578063715018a61461032d576101cf565b80632f745c59116101715780634f6ccce71161014b5780634f6ccce7146102bb57806355f804b3146102ce57806356bcf28c146102e1578063628cefb3146102f4576101cf565b80632f745c5914610282578063301779c81461029557806342842e0e146102a8576101cf565b8063095ea7b3116101ad578063095ea7b31461023257806318160ddd146102475780631d62ebd91461025c57806323b872dd1461026f576101cf565b806301ffc9a7146101d457806306fdde03146101fd578063081812fc14610212575b600080fd5b6101e76101e2366004611ecd565b610409565b6040516101f49190612024565b60405180910390f35b61020561046c565b6040516101f49190612047565b610225610220366004611f60565b6104fe565b6040516101f49190611fd3565b610245610240366004611d28565b61054a565b005b61024f6105e3565b6040516101f4919061272a565b61024f61026a366004611bc0565b6105e9565b61024561027d366004611c0c565b61062d565b61024f610290366004611d28565b610638565b6102456102a3366004611d51565b61072f565b6102456102b6366004611c0c565b610780565b61024f6102c9366004611f60565b61079b565b6102456102dc366004611f05565b6107e1565b6102456102ef366004611dc0565b61082c565b610245610302366004611eb3565b610a64565b610225610315366004611f60565b610ab6565b61024f610328366004611bc0565b610ac1565b610245610b05565b610225610b50565b610205610b5f565b610245610353366004611cff565b610b6e565b61036b610366366004611d28565b610c3c565b6040516101f49190612711565b610245610386366004611c47565b610caf565b610205610399366004611f60565b610ce2565b6102456103ac366004611df3565b610d65565b61024f61108c565b6101e7611092565b6103d46103cf366004611f60565b61109b565b6040516101f49392919061202f565b6101e76103f1366004611bda565b6110e7565b610245610404366004611bc0565b611115565b60006001600160e01b031982166380ac58cd60e01b148061043a57506001600160e01b03198216635b5e139f60e01b145b8061045557506001600160e01b0319821663780e9d6360e01b145b80610464575061046482611186565b90505b919050565b60606002805461047b906127f7565b80601f01602080910402602001604051908101604052809291908181526020018280546104a7906127f7565b80156104f45780601f106104c9576101008083540402835291602001916104f4565b820191906000526020600020905b8154815290600101906020018083116104d757829003601f168201915b5050505050905090565b60006105098261119f565b61052e5760405162461bcd60e51b8152600401610525906126c4565b60405180910390fd5b506000908152600660205260409020546001600160a01b031690565b600061055582610ab6565b9050806001600160a01b0316836001600160a01b031614156105895760405162461bcd60e51b815260040161052590612579565b806001600160a01b031661059b6111bc565b6001600160a01b031614806105b757506105b7816103f16111bc565b6105d35760405162461bcd60e51b815260040161052590612310565b6105de8383836111c0565b505050565b60015490565b60006001600160a01b0382166106115760405162461bcd60e51b81526004016105259061219a565b506001600160a01b03166000908152600e602052604090205490565b6105de83838361121c565b6001600160a01b038216600090815260056020526040812054821061066f5760405162461bcd60e51b81526004016105259061205a565b60008060005b7f00000000000000000000000000000000000000000000000000000000000027108111610710576000818152600460205260409020546001600160a01b031680156106be578092505b866001600160a01b0316836001600160a01b031614156106fd57858414156106eb57509250610729915050565b836106f581612832565b945050600092505b508061070881612832565b915050610675565b5060405162461bcd60e51b815260040161052590612676565b92915050565b8060005b8181101561077a5761076a84848381811061075e57634e487b7160e01b600052603260045260246000fd5b905060200201356113da565b61077381612832565b9050610733565b50505050565b6105de83838360405180602001604052806000815250610caf565b60007f00000000000000000000000000000000000000000000000000000000000027108211156107dd5760405162461bcd60e51b81526004016105259061250b565b5090565b6107e96111bc565b6001600160a01b03166107fa610b50565b6001600160a01b0316146108205760405162461bcd60e51b8152600401610525906123fe565b6105de60088383611a81565b6000610837336105e9565b90506000825167ffffffffffffffff81111561086357634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561088c578160200160208202803683370190505b50905060005b8351811015610a5957336000908152600d6020526040812085519091908690849081106108cf57634e487b7160e01b600052603260045260246000fd5b60209081029190910181015182528101919091526040016000206001015460ff161561090d5760405162461bcd60e51b815260040161052590612288565b8284828151811061092e57634e487b7160e01b600052603260045260246000fd5b6020026020010151106109535760405162461bcd60e51b8152600401610525906121e5565b336000908152600d60205260408120855190919086908490811061098757634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020600001548282815181106109c157634e487b7160e01b600052603260045260246000fd5b6020026020010181815250506001600d6000336001600160a01b03166001600160a01b031681526020019081526020016000206000868481518110610a1657634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060010160006101000a81548160ff0219169083151502179055508080610a5190612832565b915050610892565b506105de33826114a7565b610a6c6111bc565b6001600160a01b0316610a7d610b50565b6001600160a01b031614610aa35760405162461bcd60e51b8152600401610525906123fe565b600a805460ff1916911515919091179055565b6000610464826114c1565b60006001600160a01b038216610ae95760405162461bcd60e51b81526004016105259061236d565b506001600160a01b031660009081526005602052604090205490565b610b0d6111bc565b6001600160a01b0316610b1e610b50565b6001600160a01b031614610b445760405162461bcd60e51b8152600401610525906123fe565b610b4e6000611504565b565b6000546001600160a01b031690565b60606003805461047b906127f7565b610b766111bc565b6001600160a01b0316826001600160a01b03161415610ba75760405162461bcd60e51b815260040161052590612482565b8060076000610bb46111bc565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610bf86111bc565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610c309190612024565b60405180910390a35050565b610c44611b01565b610c4d836105e9565b8210610c6b5760405162461bcd60e51b815260040161052590612542565b506001600160a01b0382166000908152600d602090815260408083208484528252918290208251808401909352805483526001015460ff1615159082015292915050565b610cba84848461121c565b610cc684848484611554565b61077a5760405162461bcd60e51b8152600401610525906125e2565b6060610ced8261119f565b610d095760405162461bcd60e51b815260040161052590612433565b6000610d13611670565b90506000815111610d335760405180602001604052806000815250610d5e565b80610d3d8461167f565b604051602001610d4e929190611fa4565b6040516020818303038152906040525b9392505050565b610d6d6111bc565b6001600160a01b0316610d7e610b50565b6001600160a01b031614610da45760405162461bcd60e51b8152600401610525906123fe565b60005b82518110156105de57610de0838281518110610dd357634e487b7160e01b600052603260045260246000fd5b602002602001015161179a565b15610dfd5760405162461bcd60e51b815260040161052590612163565b828181518110610e1d57634e487b7160e01b600052603260045260246000fd5b6020026020010151600014158015610e5e5750612710838281518110610e5357634e487b7160e01b600052603260045260246000fd5b602002602001015111155b610e7a5760405162461bcd60e51b8152600401610525906122e6565b6040518060400160405280838381518110610ea557634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b031681526020014267ffffffffffffffff16815250600c6000858481518110610eed57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151825281810192909252604001600090812083518154949093015167ffffffffffffffff16600160a01b0267ffffffffffffffff60a01b196001600160a01b039094166001600160a01b031990951694909417929092169290921790558251610f8890849084908110610f7b57634e487b7160e01b600052603260045260246000fd5b60200260200101516105e9565b9050838281518110610faa57634e487b7160e01b600052603260045260246000fd5b6020026020010151600d6000858581518110610fd657634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600083815260200190815260200160002060000181905550600e600084848151811061103a57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600081548092919061107390612832565b919050555050808061108490612832565b915050610da7565b61271081565b600a5460ff1681565b6000818152600960205260408120548190819080156110c557600193506110c281426127b4565b92505b6000858152600b60205260409020546110de9084612788565b93959294505050565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b61111d6111bc565b6001600160a01b031661112e610b50565b6001600160a01b0316146111545760405162461bcd60e51b8152600401610525906123fe565b6001600160a01b03811661117a5760405162461bcd60e51b81526004016105259061209c565b61118381611504565b50565b6001600160e01b031981166301ffc9a760e01b14919050565b6000908152600460205260409020546001600160a01b0316151590565b3390565b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000611227826114c1565b90506000816001600160a01b031661123d6111bc565b6001600160a01b0316148061127257506112556111bc565b6001600160a01b0316611267846104fe565b6001600160a01b0316145b806112845750611284826103f16111bc565b9050806112a35760405162461bcd60e51b8152600401610525906124b9565b846001600160a01b0316826001600160a01b0316146112d45760405162461bcd60e51b8152600401610525906123b8565b6001600160a01b0384166112fa5760405162461bcd60e51b815260040161052590612243565b61130785858560016117b7565b611313600084846111c0565b6001600160a01b038516600090815260056020526040812080546001929061133c9084906127b4565b90915550506001600160a01b038416600090815260056020526040812080546001929061136a908490612788565b909155505060008381526004602052604080822080546001600160a01b0319166001600160a01b0388811691821790925591518693918916917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a46113d3858585600161077a565b5050505050565b6113e26111bc565b6001600160a01b03166113f4826114c1565b6001600160a01b03161461141a5760405162461bcd60e51b81526004016105259061220c565b6000818152600960205260409020548061146657600a5460ff166114505760405162461bcd60e51b8152600401610525906122b8565b60008281526009602052604090204290556114a3565b61147081426127b4565b6000838152600b60205260408120805490919061148e908490612788565b90915550506000828152600960205260408120555b5050565b6114a3828260405180602001604052806000815250611813565b60006114cc8261119f565b6114e85760405162461bcd60e51b8152600401610525906120e2565b506000908152600460205260409020546001600160a01b031690565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611568846001600160a01b0316611a72565b1561166457836001600160a01b031663150b7a026115846111bc565b8786866040518563ffffffff1660e01b81526004016115a69493929190611fe7565b602060405180830381600087803b1580156115c057600080fd5b505af19250505080156115f0575060408051601f3d908101601f191682019092526115ed91810190611ee9565b60015b61164a573d80801561161e576040519150601f19603f3d011682016040523d82523d6000602084013e611623565b606091505b5080516116425760405162461bcd60e51b8152600401610525906125e2565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611668565b5060015b949350505050565b60606008805461047b906127f7565b6060816116a457506040805180820190915260018152600360fc1b6020820152610467565b8160005b81156116ce57806116b881612832565b91506116c79050600a836127a0565b91506116a8565b60008167ffffffffffffffff8111156116f757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611721576020820181803683370190505b5090505b8415611668576117366001836127b4565b9150611743600a8661284d565b61174e906030612788565b60f81b81838151811061177157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611793600a866127a0565b9450611725565b6000908152600c60205260409020546001600160a01b0316151590565b8160006117c48383612788565b90505b8082101561180b57600082815260096020526040902054156117fb5760405162461bcd60e51b8152600401610525906125bb565b61180482612832565b91506117c7565b505050505050565b8151600160008282546118269190612788565b90915550506001600160a01b0383166118515760405162461bcd60e51b815260040161052590612635565b6118876000848460008151811061187857634e487b7160e01b600052603260045260246000fd5b602002602001015185516117b7565b81516001600160a01b038416600090815260056020526040812080549091906118b1908490612788565b90915550600090505b8251811015611a3b578281815181106118e357634e487b7160e01b600052603260045260246000fd5b6020026020010151846001600160a01b031660006001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461196060008585848151811061195257634e487b7160e01b600052603260045260246000fd5b602002602001015185611554565b61197c5760405162461bcd60e51b8152600401610525906125e2565b6119ac83828151811061199f57634e487b7160e01b600052603260045260246000fd5b602002602001015161119f565b156119c95760405162461bcd60e51b81526004016105259061212c565b83600460008584815181106119ee57634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508080611a3390612832565b9150506118ba565b506105de60008484600081518110611a6357634e487b7160e01b600052603260045260246000fd5b6020026020010151855161077a565b6001600160a01b03163b151590565b828054611a8d906127f7565b90600052602060002090601f016020900481019282611aaf5760008555611af5565b82601f10611ac85782800160ff19823516178555611af5565b82800160010185558215611af5579182015b82811115611af5578235825591602001919060010190611ada565b506107dd929150611b18565b604080518082019091526000808252602082015290565b5b808211156107dd5760008155600101611b19565b80356001600160a01b038116811461046757600080fd5b600082601f830112611b54578081fd5b81356020611b69611b6483612764565b612733565b8281528181019085830183850287018401881015611b85578586fd5b855b85811015611ba357813584529284019290840190600101611b87565b5090979650505050505050565b8035801515811461046757600080fd5b600060208284031215611bd1578081fd5b610d5e82611b2d565b60008060408385031215611bec578081fd5b611bf583611b2d565b9150611c0360208401611b2d565b90509250929050565b600080600060608486031215611c20578081fd5b611c2984611b2d565b9250611c3760208501611b2d565b9150604084013590509250925092565b60008060008060808587031215611c5c578081fd5b611c6585611b2d565b93506020611c74818701611b2d565b935060408601359250606086013567ffffffffffffffff80821115611c97578384fd5b818801915088601f830112611caa578384fd5b813581811115611cbc57611cbc61288d565b611cce601f8201601f19168501612733565b91508082528984828501011115611ce3578485fd5b8084840185840137810190920192909252939692955090935050565b60008060408385031215611d11578182fd5b611d1a83611b2d565b9150611c0360208401611bb0565b60008060408385031215611d3a578182fd5b611d4383611b2d565b946020939093013593505050565b60008060208385031215611d63578182fd5b823567ffffffffffffffff80821115611d7a578384fd5b818501915085601f830112611d8d578384fd5b813581811115611d9b578485fd5b8660208083028501011115611dae578485fd5b60209290920196919550909350505050565b600060208284031215611dd1578081fd5b813567ffffffffffffffff811115611de7578182fd5b61166884828501611b44565b60008060408385031215611e05578182fd5b823567ffffffffffffffff80821115611e1c578384fd5b611e2886838701611b44565b9350602091508185013581811115611e3e578384fd5b85019050601f81018613611e50578283fd5b8035611e5e611b6482612764565b81815283810190838501858402850186018a1015611e7a578687fd5b8694505b83851015611ea357611e8f81611b2d565b835260019490940193918501918501611e7e565b5080955050505050509250929050565b600060208284031215611ec4578081fd5b610d5e82611bb0565b600060208284031215611ede578081fd5b8135610d5e816128a3565b600060208284031215611efa578081fd5b8151610d5e816128a3565b60008060208385031215611f17578182fd5b823567ffffffffffffffff80821115611f2e578384fd5b818501915085601f830112611f41578384fd5b813581811115611f4f578485fd5b866020828501011115611dae578485fd5b600060208284031215611f71578081fd5b5035919050565b60008151808452611f908160208601602086016127cb565b601f01601f19169290920160200192915050565b60008351611fb68184602088016127cb565b835190830190611fca8183602088016127cb565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061201a90830184611f78565b9695505050505050565b901515815260200190565b92151583526020830191909152604082015260600190565b600060208252610d5e6020830184611f78565b60208082526022908201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252602a908201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736040820152693a32b73a103a37b5b2b760b11b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526018908201527f546f6b656e496420416c72656164792052657761726465640000000000000000604082015260600190565b6020808252602b908201527f426561724e4654533a2061646472657373207a65726f206973206e6f7420612060408201526a3b30b634b21037bbb732b960a91b606082015260800190565b6020808252600d908201526c092dcecc2d8d2c840d2dcc8caf609b1b604082015260600190565b60208082526018908201527f45524337323141436f6d6d6f6e3a204e6f74206f776e65720000000000000000604082015260600190565b60208082526025908201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b602080825260169082015275105b1c9958591e4810db185a5b59590814995dd85c9960521b604082015260600190565b6020808252601490820152731099585c8e881c995cdd1a5b99c818db1bdcd95960621b604082015260600190565b60208082526010908201526f125b9d985b1a5908151bdad95b88125960821b604082015260600190565b60208082526039908201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60408201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000606082015260800190565b6020808252602b908201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60408201526a65726f206164647265737360a81b606082015260800190565b60208082526026908201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746040820152651037bbb732b960d11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b6020808252601a908201527f455243373231413a20617070726f766520746f2063616c6c6572000000000000604082015260600190565b60208082526032908201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206040820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b606082015260800190565b6020808252601a908201527f476c6f62616c20696e646578206f7574206f6620626f756e6473000000000000604082015260600190565b60208082526019908201527f6f776e657220696e646578206f7574206f6620626f756e647300000000000000604082015260600190565b60208082526022908201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60408201526132b960f11b606082015260800190565b6020808252600d908201526c426561723a2072657374696e6760981b604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b60208082526021908201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b6020808252602e908201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060408201526d0deeedccae440c4f240d2dcc8caf60931b606082015260800190565b6020808252602d908201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560408201526c3c34b9ba32b73a103a37b5b2b760991b606082015260800190565b8151815260209182015115159181019190915260400190565b90815260200190565b604051601f8201601f1916810167ffffffffffffffff8111828210171561275c5761275c61288d565b604052919050565b600067ffffffffffffffff82111561277e5761277e61288d565b5060209081020190565b6000821982111561279b5761279b612861565b500190565b6000826127af576127af612877565b500490565b6000828210156127c6576127c6612861565b500390565b60005b838110156127e65781810151838201526020016127ce565b8381111561077a5750506000910152565b60028104600182168061280b57607f821691505b6020821081141561282c57634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561284657612846612861565b5060010190565b60008261285c5761285c612877565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461118357600080fdfea26469706673582212209cb964af4b06eaefd22cfc28eac1a0cff45f51981e1a0a1b91d38fd8882020ae64736f6c63430008010033
Verified Source Code Full Match
Compiler: v0.8.1+commit.df193b15
EVM: istanbul
Optimization: Yes (200 runs)
ERC721A.sol 488 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints.
*
* Assumes Token Will be minted Randomly
*
* Assumes the number of issuable tokens (collection size) is capped and fits in a uint256.
*
* Does not support burning tokens to address(0).
*/
contract ERC721A is
Context,
ERC165,
IERC721,
IERC721Metadata,
IERC721Enumerable
{
using Address for address;
using Strings for uint256;
uint256 private currentIndex = 0;
uint256 internal immutable collectionSize;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
mapping(uint256 => address) private _ownerships;
// Mapping owner address to address data
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
* `collectionSize_` refers to how many tokens are in the collection.
*/
constructor(
string memory name_,
string memory symbol_,
uint256 collectionSize_
) {
require(
collectionSize_ > 0,
"ERC721A: collection must have a nonzero supply"
);
_name = name_;
_symbol = symbol_;
collectionSize = collectionSize_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() external view override returns (uint256) {
return currentIndex;
}
/**
* @dev This read function is to return index wrt tokenId. As we have same index
* with tokenId. We are limiting till collectionSize
*/
function tokenByIndex(uint256 index)
external
view
override
returns (uint256)
{
require(index <= collectionSize, "Global index out of bounds");
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(collectionSize). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index)
external
view
override
returns (uint256)
{
require(index < balances[owner], "ERC721A: owner index out of bounds");
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i <= collectionSize; i++) {
address ownership = _ownerships[i];
if (ownership != address(0)) {
currOwnershipAddr = ownership;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
currOwnershipAddr = address(0);
}
}
revert("ERC721A: unable to get token of owner by index");
}
/**
* @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 ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) external view override returns (uint256) {
require(
owner != address(0),
"ERC721A: balance query for the zero address"
);
return balances[owner];
}
function ownershipOf(uint256 tokenId)
internal
view
returns (address)
{
require(_exists(tokenId), "ERC721A: owner query for nonexistent token");
return _ownerships[tokenId];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId);
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() external view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() external view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId)
external
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) external override {
address owner = ERC721A.ownerOf(tokenId);
require(to != owner, "ERC721A: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721A: approve caller is not owner nor approved for all"
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId)
public
view
override
returns (address)
{
require(
_exists(tokenId),
"ERC721A: approved query for nonexistent token"
);
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved)
external
override
{
require(operator != _msgSender(), "ERC721A: 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 override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
"ERC721A: 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`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return _ownerships[tokenId] != address(0);
}
function _safeMint(address to, uint256[] memory tokenIds) internal {
_safeMint(to, tokenIds, "");
}
function _safeMint(
address to,
uint256[] memory tokenIds,
bytes memory _data
) internal {
currentIndex += tokenIds.length;
require(to != address(0), "ERC721A: mint to the zero address");
_beforeTokenTransfers(address(0), to, tokenIds[0], tokenIds.length);
balances[to] += tokenIds.length;
for (uint256 i = 0; i < tokenIds.length; i++) {
emit Transfer(address(0), to, tokenIds[i]);
require(
_checkOnERC721Received(address(0), to, tokenIds[i], _data),
"ERC721A: transfer to non ERC721Receiver implementer"
);
require(!_exists(tokenIds[i]), "ERC721: token already minted");
_ownerships[tokenIds[i]] = to;
}
_afterTokenTransfers(address(0), to, tokenIds[0], tokenIds.length);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* 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
) private {
address prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership, _msgSender()));
require(
isApprovedOrOwner,
"ERC721A: transfer caller is not owner nor approved"
);
require(
prevOwnership == from,
"ERC721A: transfer from incorrect owner"
);
require(to != address(0), "ERC721A: transfer to the zero address");
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership);
balances[from] -= 1;
balances[to] += 1;
_ownerships[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, 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(
"ERC721A: transfer to non ERC721Receiver implementer"
);
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* 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`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
}
BearNFTS.sol 172 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
import "@openzeppelin/contracts/access/Ownable.sol";
import "./ERC721A.sol";
struct Reward {
uint256 tokenId;
bool claimed;
}
struct RewardClaimer {
address addr;
uint64 startTimestamp;
}
contract BearNFTS is Ownable, ERC721A {
uint256 public constant COLLECTION_SIZE = 10000;
string private _baseTokenURI;
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
/**
@dev tokenId to hibernation start time (0 = not hibernation).
*/
mapping(uint256 => uint256) private hibernationStarted;
bool public hibernationStatus = false;
/**
@dev Cumulative per-token hibernation, excluding the current period.
*/
mapping(uint256 => uint256) private hibernationTotal;
// Mapping of tokenId with address to prevent duplicate assigning
mapping(uint256 => RewardClaimer) private _rewardClaimer;
// Mapping from owner to list of reward token IDs
mapping(address => mapping(uint256 => Reward)) private _rewardTokens;
// mapping owner address with reward count
mapping(address => uint256) private _rewards;
constructor() ERC721A("Barbearian", "BEAR", COLLECTION_SIZE) {}
function addWhitelist(uint256[] memory tokenIds, address[] memory accounts)
external
onlyOwner
{
for (uint256 index = 0; index < tokenIds.length; index++) {
require(!_rewardExits(tokenIds[index]), "TokenId Already Rewarded");
require(
tokenIds[index] != 0 && tokenIds[index] <= COLLECTION_SIZE,
"Invalid Token Id"
);
_rewardClaimer[tokenIds[index]] = RewardClaimer(
accounts[index],
uint64(block.timestamp)
);
uint256 length = rewardOf(accounts[index]);
_rewardTokens[accounts[index]][length].tokenId = tokenIds[index];
_rewards[accounts[index]]++;
}
}
function tokenOfRewardByIndex(address owner, uint256 index)
public
view
returns (Reward memory)
{
require(index < rewardOf(owner), "owner index out of bounds");
return _rewardTokens[owner][index];
}
function rewardOf(address owner) public view returns (uint256) {
require(
owner != address(0),
"BearNFTS: address zero is not a valid owner"
);
return _rewards[owner];
}
function claimBears(uint256[] memory rewardIndexes) external {
uint256 rewardBalance = rewardOf(msg.sender);
uint256[] memory tokenIds = new uint256[](rewardIndexes.length);
for (uint256 index = 0; index < rewardIndexes.length; index++) {
{
require(
!_rewardTokens[msg.sender][rewardIndexes[index]].claimed,
"Already Claimed Reward"
);
require(rewardIndexes[index] < rewardBalance, "Invalid index");
tokenIds[index] = _rewardTokens[msg.sender][
rewardIndexes[index]
].tokenId;
_rewardTokens[msg.sender][rewardIndexes[index]].claimed = true;
}
}
_safeMint(msg.sender, tokenIds);
}
function _rewardExits(uint256 tokenId) internal view returns (bool) {
return _rewardClaimer[tokenId].addr != address(0);
}
function changeHibernationStatus(bool status) public onlyOwner {
hibernationStatus = status;
}
/**
@dev Block transfers while resting.
*/
function _beforeTokenTransfers(
address,
address,
uint256 startTokenId,
uint256 quantity
) internal view override {
uint256 tokenId = startTokenId;
for (uint256 end = tokenId + quantity; tokenId < end; ++tokenId) {
require(hibernationStarted[tokenId] == 0, "Bear: resting");
}
}
function hibernationPeriod(uint256 tokenId)
external
view
returns (
bool resting,
uint256 current,
uint256 total
)
{
uint256 start = hibernationStarted[tokenId];
if (start != 0) {
resting = true;
current = block.timestamp - start;
}
total = current + hibernationTotal[tokenId];
}
function toggleHibernation(uint256 tokenId) internal {
require(
ownershipOf(tokenId) == _msgSender(),
"ERC721ACommon: Not owner"
);
uint256 start = hibernationStarted[tokenId];
if (start == 0) {
require(hibernationStatus, "Bear: resting closed");
hibernationStarted[tokenId] = block.timestamp;
} else {
hibernationTotal[tokenId] += block.timestamp - start;
hibernationStarted[tokenId] = 0;
}
}
function toggleHibernation(uint256[] calldata tokenIds) external {
uint256 n = tokenIds.length;
for (uint256 i = 0; i < n; ++i) {
toggleHibernation(tokenIds[i]);
}
}
}
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);
}
}
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;
}
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);
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
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);
/**
* @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
COLLECTION_SIZE 0xd8258d95 → uint256
balanceOf 0x70a08231 → uint256
getApproved 0x081812fc → address
hibernationPeriod 0xe6fe95ba → bool, uint256, uint256
hibernationStatus 0xe6b11e4c → bool
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
rewardOf 0x1d62ebd9 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenOfRewardByIndex 0xa654ae07 → tuple
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 12 functions
These functions modify contract state and require a wallet transaction to execute.
addWhitelist 0xd6875638
uint256[] tokenIds
address[] accounts
approve 0x095ea7b3
address to
uint256 tokenId
changeHibernationStatus 0x628cefb3
bool status
claimBears 0x56bcf28c
uint256[] rewardIndexes
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
setBaseURI 0x55f804b3
string baseURI
toggleHibernation 0x301779c8
uint256[] tokenIds
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address