Address Contract Verified
Address
0x08705F4dB62596bA6E2c374fDC3AEA9492B4F48A
Balance
0 ETH
Nonce
1
Code Size
19447 bytes
Creator
0xDaE19Acc...4DA7 at tx 0xcc744162...dcd8c0
Indexed Transactions
0
Contract Bytecode
19447 bytes
0x608060405234801561001057600080fd5b506004361061027d5760003560e01c806370a082311161015c578063a22cb465116100ce578063e58306f911610087578063e58306f914610781578063e985e9c51461079d578063ef3bc7f6146107cd578063f2fde38b146107e9578063f84ddf0b14610805578063feff1999146108235761027d565b8063a22cb465146106d5578063b88d4fde146106f1578063bc8893b41461070d578063c29ad3ff1461072b578063c87b56dd14610735578063db6242c3146107655761027d565b8063890621da11610120578063890621da146106155780638b2e9809146106455780638c7ea24b146106615780638da5cb5b1461067d57806395d89b411461069b5780639f6350e6146106b95761027d565b806370a0823114610571578063715018a6146105a1578063841bfb27146105ab5780638462151c146105c75780638838b5c3146105f75761027d565b806323b872dd116101f5578063507e094f116101b9578063507e094f146104af57806353135ca0146104cd57806355f804b3146104eb5780635afefc09146105075780636198e339146105255780636352211e146105415761027d565b806323b872dd146103fa578063282d3fdf146104165780632a55205a146104325780633b035df61461046357806342842e0e146104935761027d565b8063095ea7b311610247578063095ea7b314610326578063131f5d0514610342578063150b7a021461036057806318160ddd14610390578063195e8708146103ae5780632073447d146103de5761027d565b8062ea586b14610282578062f7a9521461029e57806301ffc9a7146102a857806306fdde03146102d8578063081812fc146102f6575b600080fd5b61029c60048036038101906102979190613309565b610853565b005b6102a661094c565b005b6102c260048036038101906102bd91906133a1565b610980565b6040516102cf91906133e9565b60405180910390f35b6102e06109a2565b6040516102ed919061349d565b60405180910390f35b610310600480360381019061030b91906134bf565b610a34565b60405161031d91906134fb565b60405180910390f35b610340600480360381019061033b9190613309565b610ab3565b005b61034a610b38565b60405161035791906133e9565b60405180910390f35b61037a6004803603810190610375919061357b565b610b4b565b6040516103879190613612565b60405180910390f35b610398610b79565b6040516103a5919061363c565b60405180910390f35b6103c860048036038101906103c3919061368d565b610b90565b6040516103d591906133e9565b60405180910390f35b6103f860048036038101906103f391906136ba565b610bb0565b005b610414600480360381019061040f91906136e7565b610bc4565b005b610430600480360381019061042b9190613309565b610ee9565b005b61044c6004803603810190610447919061373a565b611078565b60405161045a92919061377a565b60405180910390f35b61047d600480360381019061047891906134bf565b611138565b60405161048a91906134fb565b60405180910390f35b6104ad60048036038101906104a891906136e7565b6111bd565b005b6104b76111dd565b6040516104c4919061363c565b60405180910390f35b6104d56111e3565b6040516104e291906133e9565b60405180910390f35b610505600480360381019061050091906138d3565b6111f6565b005b61050f611218565b60405161051c919061363c565b60405180910390f35b61053f600480360381019061053a91906134bf565b611234565b005b61055b600480360381019061055691906134bf565b61132b565b60405161056891906134fb565b60405180910390f35b61058b600480360381019061058691906136ba565b61133d565b604051610598919061363c565b60405180910390f35b6105a96113f6565b005b6105c560048036038101906105c091906138d3565b61140a565b005b6105e160048036038101906105dc91906136ba565b61142c565b6040516105ee91906139da565b60405180910390f35b6105ff611576565b60405161060c91906134fb565b60405180910390f35b61062f600480360381019061062a9190613a9d565b6115a0565b60405161063c9190613b1b565b60405180910390f35b61065f600480360381019061065a9190613b62565b6115be565b005b61067b60048036038101906106769190613309565b6115e3565b005b6106856115f9565b60405161069291906134fb565b60405180910390f35b6106a3611623565b6040516106b0919061349d565b60405180910390f35b6106d360048036038101906106ce91906138d3565b6116b5565b005b6106ef60048036038101906106ea9190613b8f565b6116d7565b005b61070b60048036038101906107069190613bcf565b61184f565b005b6107156118c2565b60405161072291906133e9565b60405180910390f35b6107336118d5565b005b61074f600480360381019061074a91906134bf565b611909565b60405161075c919061349d565b60405180910390f35b61077f600480360381019061077a91906134bf565b611a30565b005b61079b60048036038101906107969190613309565b611a42565b005b6107b760048036038101906107b29190613c52565b611aaf565b6040516107c491906133e9565b60405180910390f35b6107e760048036038101906107e29190613a9d565b611b43565b005b61080360048036038101906107fe91906136ba565b611c1b565b005b61080d611c9f565b60405161081a919061363c565b60405180910390f35b61083d60048036038101906108389190613309565b611d03565b60405161084a9190613b1b565b60405180910390f35b601160009054906101000a900460ff166108a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161089990613cde565b60405180910390fd5b611a0a816108ae611d38565b6108b89190613d2d565b11156108f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f090613dcf565b60405180910390fd5b600d5481111561093e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093590613e3b565b60405180910390fd5b6109488282611d4b565b5050565b610954611d69565b601160009054906101000a900460ff1615601160006101000a81548160ff021916908315150217905550565b600061098b82611de7565b8061099b575061099a82611e61565b5b9050919050565b6060600280546109b190613e8a565b80601f01602080910402602001604051908101604052809291908181526020018280546109dd90613e8a565b8015610a2a5780601f106109ff57610100808354040283529160200191610a2a565b820191906000526020600020905b815481529060010190602001808311610a0d57829003601f168201915b5050505050905090565b6000610a3f82611ecb565b610a75576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600073ffffffffffffffffffffffffffffffffffffffff16610ad482611138565b73ffffffffffffffffffffffffffffffffffffffff1614610b2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2190613f08565b60405180910390fd5b610b348282611f2a565b5050565b601160029054906101000a900460ff1681565b60007f076da4d9c24844193769905d464af7887f9d147706fec0e494242596fc6c898f905095945050505050565b6000610b8361206e565b6001546000540303905090565b600a6020528060005260406000206000915054906101000a900460ff1681565b610bb8611d69565b610bc181612077565b50565b6000610bcf826120bb565b90508373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610c36576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610c4284612189565b91509150610c588187610c536121b0565b6121b8565b610ca457610c6d86610c686121b0565b611aaf565b610ca3576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415610d0b576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610d1886868660016121fc565b8015610d2357600082555b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081546001900391905081905550600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815460010191905081905550610df185610dcd8888876122ec565b7c020000000000000000000000000000000000000000000000000000000017612314565b600460008681526020019081526020016000208190555060007c020000000000000000000000000000000000000000000000000000000084161415610e79576000600185019050600060046000838152602001908152602001600020541415610e77576000548114610e76578360046000838152602001908152602001600020819055505b5b505b838573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4610ee1868686600161233f565b505050505050565b6000610ef48261132b565b90508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610f365750610f358133611aaf565b5b610f75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6c90613f74565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166008600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611017576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161100e90613fe0565b60405180910390fd5b826008600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506110738383611f2a565b505050565b6000806000600c6040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900462ffffff1662ffffff1662ffffff1681525050905080600001519250612710816020015162ffffff16856111249190614000565b61112e9190614089565b9150509250929050565b600061114382611ecb565b611182576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111799061412c565b60405180910390fd5b6008600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6111d88383836040518060200160405280600081525061184f565b505050565b600d5481565b601160019054906101000a900460ff1681565b6111fe611d69565b80600e908051906020019061121492919061316f565b5050565b6000611222610b79565b611a0a61122f919061414c565b905090565b6008600082815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146112d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112cc906141cc565b60405180910390fd5b60006008600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000611336826120bb565b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113a5576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054169050919050565b6113fe611d69565b61140860006123b0565b565b611412611d69565b80600f908051906020019061142892919061316f565b5050565b6060600080600061143c8561133d565b905060008167ffffffffffffffff81111561145a576114596137a8565b5b6040519080825280602002602001820160405280156114885781602001602082028036833780820191505090505b5090506114936131f5565b600061149d61206e565b90505b838614611568576114b081612476565b91508160400151156114c15761155d565b600073ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff161461150157816000015194505b8773ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561155c578083878060010198508151811061154f5761154e6141ec565b5b6020026020010181815250505b5b8060010190506114a0565b508195505050505050919050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006115b58484846115b0611576565b6124a1565b90509392505050565b6115c6611d69565b80601160026101000a81548160ff02191690831515021790555050565b6115eb611d69565b6115f582826125ab565b5050565b6000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606003805461163290613e8a565b80601f016020809104026020016040519081016040528092919081815260200182805461165e90613e8a565b80156116ab5780601f10611680576101008083540402835291602001916116ab565b820191906000526020600020905b81548152906001019060200180831161168e57829003601f168201915b5050505050905090565b6116bd611d69565b80601090805190602001906116d392919061316f565b5050565b6116df6121b0565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611744576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600760006117516121b0565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166117fe6121b0565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161184391906133e9565b60405180910390a35050565b61185a848484610bc4565b60008373ffffffffffffffffffffffffffffffffffffffff163b146118bc5761188584848484612695565b6118bb576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b50505050565b601160009054906101000a900460ff1681565b6118dd611d69565b601160019054906101000a900460ff1615601160016101000a81548160ff021916908315150217905550565b606061191482611ecb565b611953576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194a90614267565b60405180910390fd5b601160029054906101000a900460ff161561199d57600e611973836127e6565b601060405160200161198793929190614357565b6040516020818303038152906040529050611a2b565b600f80546119aa90613e8a565b80601f01602080910402602001604051908101604052809291908181526020018280546119d690613e8a565b8015611a235780601f106119f857610100808354040283529160200191611a23565b820191906000526020600020905b815481529060010190602001808311611a0657829003601f168201915b505050505090505b919050565b611a38611d69565b80600d8190555050565b611a4a611d69565b611a0a81611a56611d38565b611a609190613d2d565b1115611aa1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a9890613dcf565b60405180910390fd5b611aab8282611d4b565b5050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b601160019054906101000a900460ff16611b92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b89906143d4565b60405180910390fd5b6000826fffffffffffffffffffffffffffffffff169050611a0a81611bb5611d38565b611bbf9190613d2d565b1115611c00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bf790613dcf565b60405180910390fd5b611c0b848484612947565b611c158482611d4b565b50505050565b611c23611d69565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c93576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c8a90614466565b60405180910390fd5b611c9c816123b0565b50565b600080611caa611d38565b11611cea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ce1906144d2565b60405180910390fd5b6001611cf4612988565b611cfe919061414c565b905090565b6000828230604051602001611d1a939291906144f2565b60405160208183030381529060405280519060200120905092915050565b6000611d4261206e565b60005403905090565b611d65828260405180602001604052806000815250612991565b5050565b611d71612a2e565b73ffffffffffffffffffffffffffffffffffffffff16611d8f6115f9565b73ffffffffffffffffffffffffffffffffffffffff1614611de5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ddc90614575565b60405180910390fd5b565b60007f72b68110000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611e5a5750611e5982612a36565b5b9050919050565b60007f2a55205a000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600081611ed661206e565b11158015611ee5575060005482105b8015611f23575060007c0100000000000000000000000000000000000000000000000000000000600460008581526020019081526020016000205416145b9050919050565b6000611f358261132b565b90508073ffffffffffffffffffffffffffffffffffffffff16611f566121b0565b73ffffffffffffffffffffffffffffffffffffffff1614611fb957611f8281611f7d6121b0565b611aaf565b611fb8576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b826006600084815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b60006001905090565b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080829050806120ca61206e565b11612152576000548110156121515760006004600083815260200190815260200160002054905060007c01000000000000000000000000000000000000000000000000000000008216141561214f575b600081141561214557600460008360019003935083815260200190815260200160002054905061211a565b8092505050612184565b505b5b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60008060006006600085815260200190815260200160002090508092508254915050915091565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff8316925073ffffffffffffffffffffffffffffffffffffffff821691508382148383141790509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16146122e657600073ffffffffffffffffffffffffffffffffffffffff1661225183611138565b73ffffffffffffffffffffffffffffffffffffffff1614806122a6575061227782611138565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6122e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122dc906145e1565b60405180910390fd5b5b50505050565b60008060e883901c905060e8612303868684612ac8565b62ffffff16901b9150509392505050565b600073ffffffffffffffffffffffffffffffffffffffff83169250814260a01b178317905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16146123aa576008600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555b50505050565b6000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b61247e6131f5565b61249a6004600084815260200190815260200160002054612ad1565b9050919050565b6000806124b66124b18787611d03565b612b87565b90508273ffffffffffffffffffffffffffffffffffffffff166124e28583612bb790919063ffffffff16565b73ffffffffffffffffffffffffffffffffffffffff1614612538576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161252f9061464d565b60405180910390fd5b60001515600a600083815260200190815260200160002060009054906101000a900460ff1615151461259f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612596906146b9565b60405180910390fd5b80915050949350505050565b6127108111156125f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125e790614725565b60405180910390fd5b60405180604001604052808373ffffffffffffffffffffffffffffffffffffffff1681526020018262ffffff16815250600c60008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548162ffffff021916908362ffffff1602179055509050505050565b60008373ffffffffffffffffffffffffffffffffffffffff1663150b7a026126bb6121b0565b8786866040518563ffffffff1660e01b81526004016126dd949392919061479a565b6020604051808303816000875af192505050801561271957506040513d601f19601f8201168201806040525081019061271691906147fb565b60015b612793573d8060008114612749576040519150601f19603f3d011682016040523d82523d6000602084013e61274e565b606091505b5060008151141561278b576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050949350505050565b6060600082141561282e576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612942565b600082905060005b6000821461286057808061284990614828565b915050600a826128599190614089565b9150612836565b60008167ffffffffffffffff81111561287c5761287b6137a8565b5b6040519080825280601f01601f1916602001820160405280156128ae5781602001600182028036833780820191505090505b5090505b6000851461293b576001826128c7919061414c565b9150600a856128d69190614871565b60306128e29190613d2d565b60f81b8183815181106128f8576128f76141ec565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856129349190614089565b94506128b2565b8093505050505b919050565b60006129548484846115a0565b90506001600a600083815260200190815260200160002060006101000a81548160ff02191690831515021790555050505050565b60008054905090565b61299b8383612bde565b60008373ffffffffffffffffffffffffffffffffffffffff163b14612a2957600080549050600083820390505b6129db6000868380600101945086612695565b612a11576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8181106129c8578160005414612a2657600080fd5b50505b505050565b600033905090565b60006301ffc9a760e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612a9157506380ac58cd60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80612ac15750635b5e139f60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b60009392505050565b612ad96131f5565b81816000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505060a082901c816020019067ffffffffffffffff16908167ffffffffffffffff168152505060007c01000000000000000000000000000000000000000000000000000000008316141581604001901515908115158152505060e882901c816060019062ffffff16908162ffffff1681525050919050565b600081604051602001612b9a919061490f565b604051602081830303815290604052805190602001209050919050565b6000806000612bc68585612d9b565b91509150612bd381612e1e565b819250505092915050565b6000805490506000821415612c1f576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612c2c60008483856121fc565b600160406001901b178202600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550612ca383612c9460008660006122ec565b612c9d85612ff3565b17612314565b6004600083815260200190815260200160002081905550600080838301905073ffffffffffffffffffffffffffffffffffffffff85169150828260007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600183015b818114612d4457808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600181019050612d09565b506000821415612d80576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806000819055505050612d96600084838561233f565b505050565b600080604183511415612ddd5760008060006020860151925060408601519150606086015160001a9050612dd187828585613003565b94509450505050612e17565b604083511415612e0e576000806020850151915060408501519050612e03868383613110565b935093505050612e17565b60006002915091505b9250929050565b60006004811115612e3257612e31614935565b5b816004811115612e4557612e44614935565b5b1415612e5057612ff0565b60016004811115612e6457612e63614935565b5b816004811115612e7757612e76614935565b5b1415612eb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612eaf906149b0565b60405180910390fd5b60026004811115612ecc57612ecb614935565b5b816004811115612edf57612ede614935565b5b1415612f20576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f1790614a1c565b60405180910390fd5b60036004811115612f3457612f33614935565b5b816004811115612f4757612f46614935565b5b1415612f88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f7f90614aae565b60405180910390fd5b600480811115612f9b57612f9a614935565b5b816004811115612fae57612fad614935565b5b1415612fef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fe690614b40565b60405180910390fd5b5b50565b60006001821460e11b9050919050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c111561303e576000600391509150613107565b601b8560ff16141580156130565750601c8560ff1614155b15613068576000600491509150613107565b60006001878787876040516000815260200160405260405161308d9493929190614b7c565b6020604051602081039080840390855afa1580156130af573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156130fe57600060019250925050613107565b80600092509250505b94509492505050565b60008060007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60001b841690506000601b60ff8660001c901c6131539190613d2d565b905061316187828885613003565b935093505050935093915050565b82805461317b90613e8a565b90600052602060002090601f01602090048101928261319d57600085556131e4565b82601f106131b657805160ff19168380011785556131e4565b828001600101855582156131e4579182015b828111156131e35782518255916020019190600101906131c8565b5b5090506131f19190613244565b5090565b6040518060800160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff168152602001600015158152602001600062ffffff1681525090565b5b8082111561325d576000816000905550600101613245565b5090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006132a082613275565b9050919050565b6132b081613295565b81146132bb57600080fd5b50565b6000813590506132cd816132a7565b92915050565b6000819050919050565b6132e6816132d3565b81146132f157600080fd5b50565b600081359050613303816132dd565b92915050565b600080604083850312156133205761331f61326b565b5b600061332e858286016132be565b925050602061333f858286016132f4565b9150509250929050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61337e81613349565b811461338957600080fd5b50565b60008135905061339b81613375565b92915050565b6000602082840312156133b7576133b661326b565b5b60006133c58482850161338c565b91505092915050565b60008115159050919050565b6133e3816133ce565b82525050565b60006020820190506133fe60008301846133da565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561343e578082015181840152602081019050613423565b8381111561344d576000848401525b50505050565b6000601f19601f8301169050919050565b600061346f82613404565b613479818561340f565b9350613489818560208601613420565b61349281613453565b840191505092915050565b600060208201905081810360008301526134b78184613464565b905092915050565b6000602082840312156134d5576134d461326b565b5b60006134e3848285016132f4565b91505092915050565b6134f581613295565b82525050565b600060208201905061351060008301846134ec565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261353b5761353a613516565b5b8235905067ffffffffffffffff8111156135585761355761351b565b5b60208301915083600182028301111561357457613573613520565b5b9250929050565b6000806000806000608086880312156135975761359661326b565b5b60006135a5888289016132be565b95505060206135b6888289016132be565b94505060406135c7888289016132f4565b935050606086013567ffffffffffffffff8111156135e8576135e7613270565b5b6135f488828901613525565b92509250509295509295909350565b61360c81613349565b82525050565b60006020820190506136276000830184613603565b92915050565b613636816132d3565b82525050565b6000602082019050613651600083018461362d565b92915050565b6000819050919050565b61366a81613657565b811461367557600080fd5b50565b60008135905061368781613661565b92915050565b6000602082840312156136a3576136a261326b565b5b60006136b184828501613678565b91505092915050565b6000602082840312156136d0576136cf61326b565b5b60006136de848285016132be565b91505092915050565b600080600060608486031215613700576136ff61326b565b5b600061370e868287016132be565b935050602061371f868287016132be565b9250506040613730868287016132f4565b9150509250925092565b600080604083850312156137515761375061326b565b5b600061375f858286016132f4565b9250506020613770858286016132f4565b9150509250929050565b600060408201905061378f60008301856134ec565b61379c602083018461362d565b9392505050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6137e082613453565b810181811067ffffffffffffffff821117156137ff576137fe6137a8565b5b80604052505050565b6000613812613261565b905061381e82826137d7565b919050565b600067ffffffffffffffff82111561383e5761383d6137a8565b5b61384782613453565b9050602081019050919050565b82818337600083830152505050565b600061387661387184613823565b613808565b905082815260208101848484011115613892576138916137a3565b5b61389d848285613854565b509392505050565b600082601f8301126138ba576138b9613516565b5b81356138ca848260208601613863565b91505092915050565b6000602082840312156138e9576138e861326b565b5b600082013567ffffffffffffffff81111561390757613906613270565b5b613913848285016138a5565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b613951816132d3565b82525050565b60006139638383613948565b60208301905092915050565b6000602082019050919050565b60006139878261391c565b6139918185613927565b935061399c83613938565b8060005b838110156139cd5781516139b48882613957565b97506139bf8361396f565b9250506001810190506139a0565b5085935050505092915050565b600060208201905081810360008301526139f4818461397c565b905092915050565b600067ffffffffffffffff821115613a1757613a166137a8565b5b613a2082613453565b9050602081019050919050565b6000613a40613a3b846139fc565b613808565b905082815260208101848484011115613a5c57613a5b6137a3565b5b613a67848285613854565b509392505050565b600082601f830112613a8457613a83613516565b5b8135613a94848260208601613a2d565b91505092915050565b600080600060608486031215613ab657613ab561326b565b5b6000613ac4868287016132be565b9350506020613ad5868287016132f4565b925050604084013567ffffffffffffffff811115613af657613af5613270565b5b613b0286828701613a6f565b9150509250925092565b613b1581613657565b82525050565b6000602082019050613b306000830184613b0c565b92915050565b613b3f816133ce565b8114613b4a57600080fd5b50565b600081359050613b5c81613b36565b92915050565b600060208284031215613b7857613b7761326b565b5b6000613b8684828501613b4d565b91505092915050565b60008060408385031215613ba657613ba561326b565b5b6000613bb4858286016132be565b9250506020613bc585828601613b4d565b9150509250929050565b60008060008060808587031215613be957613be861326b565b5b6000613bf7878288016132be565b9450506020613c08878288016132be565b9350506040613c19878288016132f4565b925050606085013567ffffffffffffffff811115613c3a57613c39613270565b5b613c4687828801613a6f565b91505092959194509250565b60008060408385031215613c6957613c6861326b565b5b6000613c77858286016132be565b9250506020613c88858286016132be565b9150509250929050565b7f5075626c69632073616c65206e6f742061637469766500000000000000000000600082015250565b6000613cc860168361340f565b9150613cd382613c92565b602082019050919050565b60006020820190508181036000830152613cf781613cbb565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613d38826132d3565b9150613d43836132d3565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613d7857613d77613cfe565b5b828201905092915050565b7f3e4d6178537570706c7900000000000000000000000000000000000000000000600082015250565b6000613db9600a8361340f565b9150613dc482613d83565b602082019050919050565b60006020820190508181036000830152613de881613dac565b9050919050565b7f3e4d617820706572206d696e7400000000000000000000000000000000000000600082015250565b6000613e25600d8361340f565b9150613e3082613def565b602082019050919050565b60006020820190508181036000830152613e5481613e18565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680613ea257607f821691505b60208210811415613eb657613eb5613e5b565b5b50919050565b7f43616e206e6f7420617070726f7665206c6f636b656420746f6b656e00000000600082015250565b6000613ef2601c8361340f565b9150613efd82613ebc565b602082019050919050565b60006020820190508181036000830152613f2181613ee5565b9050919050565b7f4e4f545f415554484f52495a4544000000000000000000000000000000000000600082015250565b6000613f5e600e8361340f565b9150613f6982613f28565b602082019050919050565b60006020820190508181036000830152613f8d81613f51565b9050919050565b7f414c52454144595f4c4f434b4544000000000000000000000000000000000000600082015250565b6000613fca600e8361340f565b9150613fd582613f94565b602082019050919050565b60006020820190508181036000830152613ff981613fbd565b9050919050565b600061400b826132d3565b9150614016836132d3565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561404f5761404e613cfe565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000614094826132d3565b915061409f836132d3565b9250826140af576140ae61405a565b5b828204905092915050565b7f4c6f636b61626c653a206c6f636b696e6720717565727920666f72206e6f6e6560008201527f78697374656e7420746f6b656e00000000000000000000000000000000000000602082015250565b6000614116602d8361340f565b9150614121826140ba565b604082019050919050565b6000602082019050818103600083015261414581614109565b9050919050565b6000614157826132d3565b9150614162836132d3565b92508282101561417557614174613cfe565b5b828203905092915050565b7f4e4f545f554e4c4f434b45520000000000000000000000000000000000000000600082015250565b60006141b6600c8361340f565b91506141c182614180565b602082019050919050565b600060208201905081810360008301526141e5816141a9565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e4f545f45584953545300000000000000000000000000000000000000000000600082015250565b6000614251600a8361340f565b915061425c8261421b565b602082019050919050565b6000602082019050818103600083015261428081614244565b9050919050565b600081905092915050565b60008190508160005260206000209050919050565b600081546142b481613e8a565b6142be8186614287565b945060018216600081146142d957600181146142ea5761431d565b60ff1983168652818601935061431d565b6142f385614292565b60005b83811015614315578154818901526001820191506020810190506142f6565b838801955050505b50505092915050565b600061433182613404565b61433b8185614287565b935061434b818560208601613420565b80840191505092915050565b600061436382866142a7565b915061436f8285614326565b915061437b82846142a7565b9150819050949350505050565b7f50726573616c65206e6f74206163746976650000000000000000000000000000600082015250565b60006143be60128361340f565b91506143c982614388565b602082019050919050565b600060208201905081810360008301526143ed816143b1565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061445060268361340f565b915061445b826143f4565b604082019050919050565b6000602082019050818103600083015261447f81614443565b9050919050565b7f4e6f20746f6b656e73206d696e74656400000000000000000000000000000000600082015250565b60006144bc60108361340f565b91506144c782614486565b602082019050919050565b600060208201905081810360008301526144eb816144af565b9050919050565b600060608201905061450760008301866134ec565b614514602083018561362d565b61452160408301846134ec565b949350505050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061455f60208361340f565b915061456a82614529565b602082019050919050565b6000602082019050818103600083015261458e81614552565b9050919050565b7f4c4f434b45440000000000000000000000000000000000000000000000000000600082015250565b60006145cb60068361340f565b91506145d682614595565b602082019050919050565b600060208201905081810360008301526145fa816145be565b9050919050565b7f21494e56414c49445f5349474e41545552452100000000000000000000000000600082015250565b600061463760138361340f565b915061464282614601565b602082019050919050565b600060208201905081810360008301526146668161462a565b9050919050565b7f21414c52454144595f5553454421000000000000000000000000000000000000600082015250565b60006146a3600e8361340f565b91506146ae8261466d565b602082019050919050565b600060208201905081810360008301526146d281614696565b9050919050565b7f45524332393831526f79616c746965733a20546f6f2068696768000000000000600082015250565b600061470f601a8361340f565b915061471a826146d9565b602082019050919050565b6000602082019050818103600083015261473e81614702565b9050919050565b600081519050919050565b600082825260208201905092915050565b600061476c82614745565b6147768185614750565b9350614786818560208601613420565b61478f81613453565b840191505092915050565b60006080820190506147af60008301876134ec565b6147bc60208301866134ec565b6147c9604083018561362d565b81810360608301526147db8184614761565b905095945050505050565b6000815190506147f581613375565b92915050565b6000602082840312156148115761481061326b565b5b600061481f848285016147e6565b91505092915050565b6000614833826132d3565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561486657614865613cfe565b5b600182019050919050565b600061487c826132d3565b9150614887836132d3565b9250826148975761489661405a565b5b828206905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b60006148d8601c83614287565b91506148e3826148a2565b601c82019050919050565b6000819050919050565b61490961490482613657565b6148ee565b82525050565b600061491a826148cb565b915061492682846148f8565b60208201915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b600061499a60188361340f565b91506149a582614964565b602082019050919050565b600060208201905081810360008301526149c98161498d565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b6000614a06601f8361340f565b9150614a11826149d0565b602082019050919050565b60006020820190508181036000830152614a35816149f9565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b6000614a9860228361340f565b9150614aa382614a3c565b604082019050919050565b60006020820190508181036000830152614ac781614a8b565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b6000614b2a60228361340f565b9150614b3582614ace565b604082019050919050565b60006020820190508181036000830152614b5981614b1d565b9050919050565b600060ff82169050919050565b614b7681614b60565b82525050565b6000608082019050614b916000830187613b0c565b614b9e6020830186614b6d565b614bab6040830185613b0c565b614bb86060830184613b0c565b9594505050505056fea2646970667358221220bc7d111fdf3eed44f41eac3fc3494e52f4b8aa088351fc332bba5aa3be4059c164736f6c634300080b0033
Verified Source Code Full Match
Compiler: v0.8.11+commit.d7f03943
EVM: london
Optimization: No
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (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 Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
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);
}
}
SignedAllowance.sol 117 lines
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';
/// @title SignedAllowance
/// @author Simon Fremaux (@dievardump)
contract SignedAllowance {
using ECDSA for bytes32;
// list of already used allowances
mapping(bytes32 => bool) public usedAllowances;
// address used to sign the allowances
address private _allowancesSigner;
/// @notice Helper to know allowancesSigner address
/// @return the allowance signer address
function allowancesSigner() public view virtual returns (address) {
return _allowancesSigner;
}
/// @notice Helper that creates the message that signer needs to sign to allow a mint
/// this is usually also used when creating the allowances, to ensure "message"
/// is the same
/// @param account the account to allow
/// @param nonce the nonce
/// @return the message to sign
function createMessage(address account, uint256 nonce)
public
view
returns (bytes32)
{
return keccak256(abi.encode(account, nonce, address(this)));
}
/// @notice Helper that creates a list of messages that signer needs to sign to allow mintings
/// @param accounts the accounts to allow
/// @param nonces the corresponding nonces
/// @return messages the messages to sign
/*
// function is commented out to save space in the contract
// to batch create message will need to use for loop with the createMessage function
function createMessages(address[] memory accounts, uint256[] memory nonces)
external
view
returns (bytes32[] memory messages)
{
require(accounts.length == nonces.length, '!LENGTH_MISMATCH!');
messages = new bytes32[](accounts.length);
for (uint256 i; i < accounts.length; i++) {
messages[i] = createMessage(accounts[i], nonces[i]);
}
} */
/// @notice This function verifies that the current request is valid
/// @dev It ensures that _allowancesSigner signed a message containing (account, nonce, address(this))
/// and that this message was not already used
/// @param account the account the allowance is associated to
/// @param nonce the nonce associated to this allowance
/// @param signature the signature by the allowance signer wallet
/// @return the message to mark as used
function validateSignature(
address account,
uint256 nonce,
bytes memory signature
) public view returns (bytes32) {
return
_validateSignature(account, nonce, signature, allowancesSigner());
}
/// @dev It ensures that signer signed a message containing (account, nonce, address(this))
/// and that this message was not already used
/// @param account the account the allowance is associated to
/// @param nonce the nonce associated to this allowance
/// @param signature the signature by the allowance signer wallet
/// @param signer the signer
/// @return the message to mark as used
function _validateSignature(
address account,
uint256 nonce,
bytes memory signature,
address signer
) internal view returns (bytes32) {
bytes32 message = createMessage(account, nonce)
.toEthSignedMessageHash();
// verifies that the sha3(account, nonce, address(this)) has been signed by signer
require(message.recover(signature) == signer, '!INVALID_SIGNATURE!');
// verifies that the allowances was not already used
require(usedAllowances[message] == false, '!ALREADY_USED!');
return message;
}
/// @notice internal function that verifies an allowance and marks it as used
/// this function throws if signature is wrong or this nonce for this user has already been used
/// @param account the account the allowance is associated to
/// @param nonce the nonce
/// @param signature the signature by the allowance wallet
function _useAllowance(
address account,
uint256 nonce,
bytes memory signature
) internal {
bytes32 message = validateSignature(account, nonce, signature);
usedAllowances[message] = true;
}
/// @notice Allows to change the allowance signer. This can be used to revoke any signed allowance not already used
/// @param newSigner the new signer address
function _setAllowancesSigner(address newSigner) internal {
_allowancesSigner = newSigner;
}
}
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;
}
}
ERC721A.sol 1091 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import './IERC721A.sol';
/**
* @dev Interface of ERC721 token receiver.
*/
interface ERC721A__IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
/**
* @title ERC721A
*
* @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
* Non-Fungible Token Standard, including the Metadata extension.
* Optimized for lower gas during batch mints.
*
* Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
* starting from `_startTokenId()`.
*
* Assumptions:
*
* - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
* - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is IERC721A {
// Reference type for token approval.
struct TokenApprovalRef {
address value;
}
// =============================================================
// CONSTANTS
// =============================================================
// Mask of an entry in packed address data.
uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;
// The bit position of `numberMinted` in packed address data.
uint256 private constant _BITPOS_NUMBER_MINTED = 64;
// The bit position of `numberBurned` in packed address data.
uint256 private constant _BITPOS_NUMBER_BURNED = 128;
// The bit position of `aux` in packed address data.
uint256 private constant _BITPOS_AUX = 192;
// Mask of all 256 bits in packed address data except the 64 bits for `aux`.
uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;
// The bit position of `startTimestamp` in packed ownership.
uint256 private constant _BITPOS_START_TIMESTAMP = 160;
// The bit mask of the `burned` bit in packed ownership.
uint256 private constant _BITMASK_BURNED = 1 << 224;
// The bit position of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;
// The bit mask of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;
// The bit position of `extraData` in packed ownership.
uint256 private constant _BITPOS_EXTRA_DATA = 232;
// Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;
// The mask of the lower 160 bits for addresses.
uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;
// The maximum `quantity` that can be minted with {_mintERC2309}.
// This limit is to prevent overflows on the address data entries.
// For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
// is required to cause an overflow, which is unrealistic.
uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;
// The `Transfer` event signature is given by:
// `keccak256(bytes("Transfer(address,address,uint256)"))`.
bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
// =============================================================
// STORAGE
// =============================================================
// The next token ID to be minted.
uint256 private _currentIndex;
// The number of tokens burned.
uint256 private _burnCounter;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned.
// See {_packedOwnershipOf} implementation for details.
//
// Bits Layout:
// - [0..159] `addr`
// - [160..223] `startTimestamp`
// - [224] `burned`
// - [225] `nextInitialized`
// - [232..255] `extraData`
mapping(uint256 => uint256) private _packedOwnerships;
// Mapping owner address to address data.
//
// Bits Layout:
// - [0..63] `balance`
// - [64..127] `numberMinted`
// - [128..191] `numberBurned`
// - [192..255] `aux`
mapping(address => uint256) private _packedAddressData;
// Mapping from token ID to approved address.
mapping(uint256 => TokenApprovalRef) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// =============================================================
// CONSTRUCTOR
// =============================================================
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
}
// =============================================================
// TOKEN COUNTING OPERATIONS
// =============================================================
/**
* @dev Returns the starting token ID.
* To change the starting token ID, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev Returns the next token ID to be minted.
*/
function _nextTokenId() internal view virtual returns (uint256) {
return _currentIndex;
}
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() public view virtual override returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than `_currentIndex - _startTokenId()` times.
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
/**
* @dev Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view virtual returns (uint256) {
// Counter underflow is impossible as `_currentIndex` does not decrement,
// and it is initialized to `_startTokenId()`.
unchecked {
return _currentIndex - _startTokenId();
}
}
/**
* @dev Returns the total number of tokens burned.
*/
function _totalBurned() internal view virtual returns (uint256) {
return _burnCounter;
}
// =============================================================
// ADDRESS DATA OPERATIONS
// =============================================================
/**
* @dev Returns the number of tokens in `owner`'s account.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
}
/**
* Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
* If there are multiple variables, please pack them into a uint64.
*/
function _setAux(address owner, uint64 aux) internal virtual {
uint256 packed = _packedAddressData[owner];
uint256 auxCasted;
// Cast `aux` with assembly to avoid redundant masking.
assembly {
auxCasted := aux
}
packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
_packedAddressData[owner] = packed;
}
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
// The interface IDs are constants representing the first 4 bytes
// of the XOR of all function selectors in the interface.
// See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
// (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
return
interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
}
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @dev Returns the token collection name.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the token collection symbol.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
}
/**
* @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, it can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
// =============================================================
// OWNERSHIPS OPERATIONS
// =============================================================
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
return address(uint160(_packedOwnershipOf(tokenId)));
}
/**
* @dev Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around over time.
*/
function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnershipOf(tokenId));
}
/**
* @dev Returns the unpacked `TokenOwnership` struct at `index`.
*/
function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnerships[index]);
}
/**
* @dev Initializes the ownership slot minted at `index` for efficiency purposes.
*/
function _initializeOwnershipAt(uint256 index) internal virtual {
if (_packedOwnerships[index] == 0) {
_packedOwnerships[index] = _packedOwnershipOf(index);
}
}
/**
* Returns the packed ownership data of `tokenId`.
*/
function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr)
if (curr < _currentIndex) {
uint256 packed = _packedOwnerships[curr];
// If not burned.
if (packed & _BITMASK_BURNED == 0) {
// Invariant:
// There will always be an initialized ownership slot
// (i.e. `ownership.addr != address(0) && ownership.burned == false`)
// before an unintialized ownership slot
// (i.e. `ownership.addr == address(0) && ownership.burned == false`)
// Hence, `curr` will not underflow.
//
// We can directly compare the packed value.
// If the address is zero, packed will be zero.
while (packed == 0) {
packed = _packedOwnerships[--curr];
}
return packed;
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev Returns the unpacked `TokenOwnership` struct from `packed`.
*/
function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
ownership.addr = address(uint160(packed));
ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
ownership.burned = packed & _BITMASK_BURNED != 0;
ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
}
/**
* @dev Packs ownership data into a single uint256.
*/
function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
}
}
/**
* @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
*/
function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
// For branchless setting of the `nextInitialized` flag.
assembly {
// `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
}
}
// =============================================================
// APPROVAL OPERATIONS
// =============================================================
/**
* @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) public virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId].value;
}
/**
* @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) public virtual override {
if (operator == _msgSenderERC721A()) revert ApproveToCaller();
_operatorApprovals[_msgSenderERC721A()][operator] = approved;
emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
}
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @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. See {_mint}.
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return
_startTokenId() <= tokenId &&
tokenId < _currentIndex && // If within bounds,
_packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
}
/**
* @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
*/
function _isSenderApprovedOrOwner(
address approvedAddress,
address owner,
address msgSender
) private pure returns (bool result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
msgSender := and(msgSender, _BITMASK_ADDRESS)
// `msgSender == owner || msgSender == approvedAddress`.
result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
}
}
/**
* @dev Returns the storage slot and value for the approved address of `tokenId`.
*/
function _getApprovedSlotAndAddress(uint256 tokenId)
private
view
returns (uint256 approvedAddressSlot, address approvedAddress)
{
TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
// The following is equivalent to `approvedAddress = _tokenApprovals[tokenId]`.
assembly {
approvedAddressSlot := tokenApproval.slot
approvedAddress := sload(approvedAddressSlot)
}
}
// =============================================================
// TRANSFER OPERATIONS
// =============================================================
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* 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
) public virtual override {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
unchecked {
// We can directly increment and decrement the balances.
--_packedAddressData[from]; // Updates: `balance -= 1`.
++_packedAddressData[to]; // Updates: `balance += 1`.
// Updates:
// - `address` to the next owner.
// - `startTimestamp` to the timestamp of transfering.
// - `burned` to `false`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
to,
_BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @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 memory _data
) public virtual override {
transferFrom(from, to, tokenId);
if (to.code.length != 0)
if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Hook that is called before a set of serially-ordered token IDs
* are about to be transferred. This includes minting.
* And also called before burning one token.
*
* `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`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
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.
* And also called after one token has been burned.
*
* `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` has been
* transferred to `to`.
* - When `from` is zero, `tokenId` has been minted for `to`.
* - When `to` is zero, `tokenId` has been burned by `from`.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* `from` - Previous owner of the given token ID.
* `to` - Target address that will receive the token.
* `tokenId` - Token ID to be transferred.
* `_data` - Optional data to send along with the call.
*
* Returns whether the call correctly returned the expected magic value.
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
bytes4 retval
) {
return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
// =============================================================
// MINT OPERATIONS
// =============================================================
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event for each mint.
*/
function _mint(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// `balance` and `numberMinted` have a maximum limit of 2**64.
// `tokenId` has a maximum limit of 2**256.
unchecked {
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
uint256 toMasked;
uint256 end = startTokenId + quantity;
// Use assembly to loop and emit the `Transfer` event for gas savings.
assembly {
// Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
toMasked := and(to, _BITMASK_ADDRESS)
// Emit the `Transfer` event.
log4(
0, // Start of data (0, since no data).
0, // End of data (0, since no data).
_TRANSFER_EVENT_SIGNATURE, // Signature.
0, // `address(0)`.
toMasked, // `to`.
startTokenId // `tokenId`.
)
for {
let tokenId := add(startTokenId, 1)
} iszero(eq(tokenId, end)) {
tokenId := add(tokenId, 1)
} {
// Emit the `Transfer` event. Similar to above.
log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
}
}
if (toMasked == 0) revert MintToZeroAddress();
_currentIndex = end;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* This function is intended for efficient minting only during contract creation.
*
* It emits only one {ConsecutiveTransfer} as defined in
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
* instead of a sequence of {Transfer} event(s).
*
* Calling this function outside of contract creation WILL make your contract
* non-compliant with the ERC721 standard.
* For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
* {ConsecutiveTransfer} event is only permissible during contract creation.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {ConsecutiveTransfer} event.
*/
function _mintERC2309(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are unrealistic due to the above check for `quantity` to be below the limit.
unchecked {
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);
_currentIndex = startTokenId + quantity;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement
* {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* See {_mint}.
*
* Emits a {Transfer} event for each mint.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
_mint(to, quantity);
unchecked {
if (to.code.length != 0) {
uint256 end = _currentIndex;
uint256 index = end - quantity;
do {
if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (index < end);
// Reentrancy protection.
if (_currentIndex != end) revert();
}
}
}
/**
* @dev Equivalent to `_safeMint(to, quantity, '')`.
*/
function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, '');
}
// =============================================================
// BURN OPERATIONS
// =============================================================
/**
* @dev Equivalent to `_burn(tokenId, false)`.
*/
function _burn(uint256 tokenId) internal virtual {
_burn(tokenId, false);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
address from = address(uint160(prevOwnershipPacked));
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
if (approvalCheck) {
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
unchecked {
// Updates:
// - `balance -= 1`.
// - `numberBurned += 1`.
//
// We can directly decrement the balance, and increment the number burned.
// This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
_packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;
// Updates:
// - `address` to the last owner.
// - `startTimestamp` to the timestamp of burning.
// - `burned` to `true`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
from,
(_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
// =============================================================
// EXTRA DATA OPERATIONS
// =============================================================
/**
* @dev Directly sets the extra data for the ownership data `index`.
*/
function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
uint256 packed = _packedOwnerships[index];
if (packed == 0) revert OwnershipNotInitializedForExtraData();
uint256 extraDataCasted;
// Cast `extraData` with assembly to avoid redundant masking.
assembly {
extraDataCasted := extraData
}
packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
_packedOwnerships[index] = packed;
}
/**
* @dev Called during each token transfer to set the 24bit `extraData` field.
* Intended to be overridden by the cosumer contract.
*
* `previousExtraData` - the value of `extraData` before transfer.
*
* 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, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _extraData(
address from,
address to,
uint24 previousExtraData
) internal view virtual returns (uint24) {}
/**
* @dev Returns the next extra data for the packed ownership data.
* The returned result is shifted into position.
*/
function _nextExtraData(
address from,
address to,
uint256 prevOwnershipPacked
) private view returns (uint256) {
uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
}
// =============================================================
// OTHER OPERATIONS
// =============================================================
/**
* @dev Returns the message sender (defaults to `msg.sender`).
*
* If you are writing GSN compatible contracts, you need to override this function.
*/
function _msgSenderERC721A() internal view virtual returns (address) {
return msg.sender;
}
/**
* @dev Converts a uint256 to its ASCII string decimal representation.
*/
function _toString(uint256 value) internal pure virtual returns (string memory ptr) {
assembly {
// The maximum value of a uint256 contains 78 digits (1 byte per digit),
// but we allocate 128 bytes to keep the free memory pointer 32-byte word aliged.
// We will need 1 32-byte word to store the length,
// and 3 32-byte words to store a maximum of 78 digits. Total: 32 + 3 * 32 = 128.
ptr := add(mload(0x40), 128)
// Update the free memory pointer to allocate.
mstore(0x40, ptr)
// Cache the end of the memory to calculate the length later.
let end := ptr
// We write the string from the rightmost digit to the leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
// Costs a bit more than early returning for the zero case,
// but cheaper in terms of deployment and overall runtime costs.
for {
// Initialize and perform the first pass without check.
let temp := value
// Move the pointer 1 byte leftwards to point to an empty character slot.
ptr := sub(ptr, 1)
// Write the character to the pointer.
// The ASCII index of the '0' character is 48.
mstore8(ptr, add(48, mod(temp, 10)))
temp := div(temp, 10)
} temp {
// Keep dividing `temp` until zero.
temp := div(temp, 10)
} {
// Body of the for loop.
ptr := sub(ptr, 1)
mstore8(ptr, add(48, mod(temp, 10)))
}
let length := sub(end, ptr)
// Move the pointer 32 bytes leftwards to make room for the length.
ptr := sub(ptr, 32)
// Store the length.
mstore(ptr, length)
}
}
}
ECDSA.sol 232 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
IERC2981Royalties.sol 17 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title IERC2981Royalties
/// @dev Interface for the ERC2981 - Token Royalty standard
interface IERC2981Royalties {
/// @notice Called with the sale price to determine how much royalty
// is owed and to whom.
/// @param _tokenId - the NFT asset queried for royalty information
/// @param _value - the sale price of the NFT asset specified by _tokenId
/// @return _receiver - address of who should be sent the royalty payment
/// @return _royaltyAmount - the royalty payment amount for value sale price
function royaltyInfo(uint256 _tokenId, uint256 _value)
external
view
returns (address _receiver, uint256 _royaltyAmount);
}
Moonthers.sol 217 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./ERC721ALockable.sol";
import "./SignedAllowance.sol";
import "./ERC2981/ERC2981ContractWideRoyalties.sol";
/// @title Moonthers implementing ERC721A with Permits
/// @author of contract Fil Makarov (@filmakarov)
contract Moonthers is ERC721ALockable, Ownable, SignedAllowance, ERC2981ContractWideRoyalties {
using Strings for uint256;
/*///////////////////////////////////////////////////////////////
GENERAL STORAGE
//////////////////////////////////////////////////////////////*/
uint256 private constant MAX_ITEMS = 6666;
uint256 public maxPerMint = 1;
string private baseURI;
string private unrevealedURI;
string private metadataExtension = ".json";
bool public publicSaleActive;
bool public presaleActive;
bool public revealState;
/*///////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(string memory _myBase, string memory _unrevBase) ERC721A("Moonthers", "MTR") {
baseURI = _myBase;
unrevealedURI = _unrevBase;
}
// for testing purposes.
// if you want your collection to start from token #0, you can just remove this override
// if you want it to start from token #1, change to 'return 1;' instead of 'return 5;'
function _startTokenId() internal pure override returns (uint256) {
return 1;
}
/*///////////////////////////////////////////////////////////////
MINTING LOGIC
//////////////////////////////////////////////////////////////*/
function presaleOrder(address to, uint256 nonce, bytes memory signature) public {
require (presaleActive, "Presale not active");
//_mintQty is stored in the right-most 128 bits of the nonce
uint256 qty = uint256(uint128(nonce));
require(_totalMinted() + qty <= MAX_ITEMS, ">MaxSupply");
// this will throw if the allowance has already been used or is not valid
_useAllowance(to, nonce, signature);
_safeMint(to, qty);
}
function publicOrder(address to, uint256 qty) public {
require (publicSaleActive, "Public sale not active");
require(_totalMinted() + qty <= MAX_ITEMS, ">MaxSupply");
require (qty <= maxPerMint, ">Max per mint");
_safeMint(to, qty);
}
function adminMint(address to, uint256 qty) public onlyOwner {
require(_totalMinted() + qty <= MAX_ITEMS, ">MaxSupply");
_safeMint(to, qty);
}
/*///////////////////////////////////////////////////////////////
PUBLIC METADATA VIEWS
//////////////////////////////////////////////////////////////*/
/// @notice Returns the link to the metadata for the token
/// @param tokenId token ID
/// @return string with the link
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "NOT_EXISTS");
if (revealState) {
return string(abi.encodePacked(baseURI, tokenId.toString(), metadataExtension));
} else {
return unrevealedURI;
}
}
/**
* @dev Returns an array of token IDs owned by `owner`.
*
* This function scans the ownership mapping and is O(`totalSupply`) in complexity.
* It is meant to be called off-chain.
*
* See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
* multiple smaller scans if the collection is large enough to cause
* an out-of-gas error (10K collections should be fine).
*/
function tokensOfOwner(address owner) external view virtual returns (uint256[] memory) {
unchecked {
uint256 tokenIdsIdx;
address currOwnershipAddr;
uint256 tokenIdsLength = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
TokenOwnership memory ownership;
for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
ownership = _ownershipAt(i);
if (ownership.burned) {
continue;
}
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
return tokenIds;
}
}
function unclaimedSupply() public view returns (uint256) {
return MAX_ITEMS - totalSupply();
}
/// @notice returns the Id of the last minted token
function lastTokenId() public view returns (uint256) {
require(_totalMinted() > 0, "No tokens minted");
return _nextTokenId() - 1;
}
/*///////////////////////////////////////////////////////////////
ADMIN FUNCTIONS
//////////////////////////////////////////////////////////////*/
function setUnrevURI(string memory _newUnrevURI) public onlyOwner {
unrevealedURI = _newUnrevURI;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setMetadataExtension(string memory _newMDExt) public onlyOwner {
metadataExtension = _newMDExt;
}
function setMaxPerMint(uint256 _newMaxPerMint) public onlyOwner {
maxPerMint = _newMaxPerMint;
}
function switchPresale() public onlyOwner {
presaleActive = !presaleActive;
}
function switchPublicSale() public onlyOwner {
publicSaleActive = !publicSaleActive;
}
function setRevealState(bool _revealState) public onlyOwner {
revealState = _revealState;
}
/// @notice sets allowance signer, this can be used to revoke all unused allowances already out there
/// @param newSigner the new signer
function setAllowancesSigner(address newSigner) external onlyOwner {
_setAllowancesSigner(newSigner);
}
/// @notice Allows to set the royalties on the contract
/// @dev See ERC2981ContractWideRoyalties.sol
/// @param recipient the royalties recipient
/// @param value royalties value (between 0 and 10000)
function setRoyalties(address recipient, uint256 value) public onlyOwner {
_setRoyalties(recipient, value);
}
/*///////////////////////////////////////////////////////////////
IERC165
//////////////////////////////////////////////////////////////*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721ALockable, ERC2981ContractWideRoyalties)
returns (bool)
{
return ERC721ALockable.supportsInterface(interfaceId) ||
ERC2981ContractWideRoyalties.supportsInterface(interfaceId);
}
/*///////////////////////////////////////////////////////////////
ERC721Receiver interface compatibility
//////////////////////////////////////////////////////////////*/
function onERC721Received(
address,
address,
uint256,
bytes calldata
) external pure returns(bytes4) {
return bytes4(keccak256("I do not receive ERC721"));
}
}
// That's all, folks!
Strings.sol 75 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @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);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
ERC721ALockable.sol 120 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import "erc721a/contracts/ERC721A.sol";
import './IERC721Lockable.sol';
/// @title Lockable Extension for ERC721A by ChiruLabs
/// @dev Check the repo and readme at https://github.com/filmakarov/erc721s
abstract contract ERC721ALockable is ERC721A, IERC721Lockable {
/*///////////////////////////////////////////////////////////////
LOCKABLE EXTENSION STORAGE
//////////////////////////////////////////////////////////////*/
mapping(uint256 => address) internal unlockers;
/*///////////////////////////////////////////////////////////////
LOCKABLE LOGIC
//////////////////////////////////////////////////////////////*/
/**
* @dev Public function to lock the token. Verifies if the msg.sender is the owner
* or approved party.
*/
function lock(address unlocker, uint256 id) public virtual {
address tokenOwner = ownerOf(id);
require(msg.sender == tokenOwner || isApprovedForAll(tokenOwner, msg.sender)
, "NOT_AUTHORIZED");
require(unlockers[id] == address(0), "ALREADY_LOCKED");
unlockers[id] = unlocker;
super.approve(unlocker, id); //approve unlocker, so unlocker will be able to transfer
}
/**
* @dev Public function to unlock the token. Only the unlocker (stated at the time of locking) can unlock
*/
function unlock(uint256 id) public virtual {
require(msg.sender == unlockers[id], "NOT_UNLOCKER");
unlockers[id] = address(0);
}
/**
* @dev Returns the unlocker for the tokenId
* address(0) means token is not locked
* reverts if token does not exist
*/
function getLocked(uint256 tokenId) public virtual view returns (address) {
require(_exists(tokenId), "Lockable: locking query for nonexistent token");
return unlockers[tokenId];
}
/**
* @dev Locks the token
*/
function _lock(address unlocker, uint256 id) internal virtual {
unlockers[id] = unlocker;
}
/**
* @dev Unlocks the token
*/
function _unlock(uint256 id) internal virtual {
unlockers[id] = address(0);
}
/*///////////////////////////////////////////////////////////////
OVERRIDES
//////////////////////////////////////////////////////////////*/
function approve(address to, uint256 tokenId) public virtual override {
require (getLocked(tokenId) == address(0), "Can not approve locked token");
ERC721A.approve(to, tokenId);
}
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual override {
// if it is a Transfer or Burn, we always deal with one token, that is startTokenId
if (from != address(0)) {
// token should not be locked or msg.sender should be unlocker to do that
require(getLocked(startTokenId) == address(0) || msg.sender == getLocked(startTokenId), "LOCKED");
}
}
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual override {
// if it is a Transfer or Burn, we always deal with one token, that is startTokenId
if (from != address(0)) {
// clear locks
delete unlockers[startTokenId];
}
}
/*///////////////////////////////////////////////////////////////
ERC165 LOGIC
//////////////////////////////////////////////////////////////*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool)
{
return
interfaceId == type(IERC721Lockable).interfaceId ||
ERC721A.supportsInterface(interfaceId);
}
}
ERC2981ContractWideRoyalties.sol 47 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
import './IERC2981Royalties.sol';
/// @dev This is a contract used to add ERC2981 support to ERC721 and 1155
/// @dev This implementation has the same royalties for each and every tokens
abstract contract ERC2981ContractWideRoyalties is IERC2981Royalties {
struct RoyaltyInfo {
address recipient;
uint24 amount;
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
returns (bool)
{
return
interfaceId == type(IERC2981Royalties).interfaceId;
}
RoyaltyInfo private _royalties;
/// @dev Sets token royalties
/// @param recipient recipient of the royalties
/// @param value percentage (using 2 decimals - 10000 = 100, 0 = 0)
function _setRoyalties(address recipient, uint256 value) internal {
require(value <= 10000, 'ERC2981Royalties: Too high');
_royalties = RoyaltyInfo(recipient, uint24(value));
}
/// @inheritdoc IERC2981Royalties
function royaltyInfo(uint256, uint256 value)
external
view
override
returns (address receiver, uint256 royaltyAmount)
{
RoyaltyInfo memory royalties = _royalties;
receiver = royalties.recipient;
royaltyAmount = (value * royalties.amount) / 10000;
}
}
IERC721Lockable.sol 19 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
/// @title ILockable
/// @dev Interface for the Lockable extension
interface IERC721Lockable {
event Lock (address indexed unlocker, uint256 indexed id);
event Unlock (uint256 indexed id);
function lock(address unlocker, uint256 id) external;
function unlock(uint256 id) external;
function getLocked(uint256 tokenId) external view returns (address);
}
IERC721A.sol 287 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
/**
* @dev Interface of ERC721A.
*/
interface IERC721A {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* The caller cannot approve to their own address.
*/
error ApproveToCaller();
/**
* Cannot query the balance for the zero address.
*/
error BalanceQueryForZeroAddress();
/**
* Cannot mint to the zero address.
*/
error MintToZeroAddress();
/**
* The quantity of tokens minted must be more than zero.
*/
error MintZeroQuantity();
/**
* The token does not exist.
*/
error OwnerQueryForNonexistentToken();
/**
* The caller must own the token or be an approved operator.
*/
error TransferCallerNotOwnerNorApproved();
/**
* The token must be owned by `from`.
*/
error TransferFromIncorrectOwner();
/**
* Cannot safely transfer to a contract that does not implement the
* ERC721Receiver interface.
*/
error TransferToNonERC721ReceiverImplementer();
/**
* Cannot transfer to the zero address.
*/
error TransferToZeroAddress();
/**
* The token does not exist.
*/
error URIQueryForNonexistentToken();
/**
* The `quantity` minted with ERC2309 exceeds the safety limit.
*/
error MintERC2309QuantityExceedsLimit();
/**
* The `extraData` cannot be set on an unintialized ownership slot.
*/
error OwnershipNotInitializedForExtraData();
// =============================================================
// STRUCTS
// =============================================================
struct TokenOwnership {
// The address of the owner.
address addr;
// Stores the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
// Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
uint24 extraData;
}
// =============================================================
// TOKEN COUNTERS
// =============================================================
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() external view returns (uint256);
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
// =============================================================
// IERC721
// =============================================================
/**
* @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,
bytes calldata data
) external;
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` 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 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 the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @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);
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @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);
// =============================================================
// IERC2309
// =============================================================
/**
* @dev Emitted when tokens in `fromTokenId` to `toTokenId`
* (inclusive) is transferred from `from` to `to`, as defined in the
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
*
* See {_mintERC2309} for more details.
*/
event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}
Read Contract
allowancesSigner 0x8838b5c3 → address
balanceOf 0x70a08231 → uint256
createMessage 0xfeff1999 → bytes32
getApproved 0x081812fc → address
getLocked 0x3b035df6 → address
isApprovedForAll 0xe985e9c5 → bool
lastTokenId 0xf84ddf0b → uint256
maxPerMint 0x507e094f → uint256
name 0x06fdde03 → string
onERC721Received 0x150b7a02 → bytes4
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
presaleActive 0x53135ca0 → bool
publicSaleActive 0xbc8893b4 → bool
revealState 0x131f5d05 → bool
royaltyInfo 0x2a55205a → address, uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
tokensOfOwner 0x8462151c → uint256[]
totalSupply 0x18160ddd → uint256
unclaimedSupply 0x5afefc09 → uint256
usedAllowances 0x195e8708 → bool
validateSignature 0x890621da → bytes32
Write Contract 21 functions
These functions modify contract state and require a wallet transaction to execute.
adminMint 0xe58306f9
address to
uint256 qty
approve 0x095ea7b3
address to
uint256 tokenId
lock 0x282d3fdf
address unlocker
uint256 id
presaleOrder 0xef3bc7f6
address to
uint256 nonce
bytes signature
publicOrder 0x00ea586b
address to
uint256 qty
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setAllowancesSigner 0x2073447d
address newSigner
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string _newBaseURI
setMaxPerMint 0xdb6242c3
uint256 _newMaxPerMint
setMetadataExtension 0x9f6350e6
string _newMDExt
setRevealState 0x8b2e9809
bool _revealState
setRoyalties 0x8c7ea24b
address recipient
uint256 value
setUnrevURI 0x841bfb27
string _newUnrevURI
switchPresale 0xc29ad3ff
No parameters
switchPublicSale 0x00f7a952
No parameters
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
unlock 0x6198e339
uint256 id
Recent Transactions
No transactions found for this address