Address Contract Verified
Address
0x91A5d4F6e691432a58d5579ae45955210eC6a2f1
Balance
0 ETH
Nonce
1
Code Size
21790 bytes
Creator
0xf8cA77ED...F608 at tx 0x2555dcc3...8ad1f9
Indexed Transactions
0
Contract Bytecode
21790 bytes
0x6080604052600436106102465760003560e01c806370a0823111610139578063a4babffd116100b6578063c6e62e0b1161007a578063c6e62e0b1461083a578063c87b56dd14610865578063d7224ba0146108a2578063e985e9c5146108cd578063f2fde38b1461090a578063fd1e29621461093357610246565b8063a4babffd14610769578063ac44600214610794578063b1f536fa146107ab578063b88d4fde146107e8578063ba2f59c81461081157610246565b806395d89b41116100fd57806395d89b4114610682578063993670f2146106ad5780639c4dab52146106d8578063a22cb46514610703578063a38643971461072c57610246565b806370a08231146105af578063715018a6146105ec57806372830dfd1461060357806376972db21461062c5780638da5cb5b1461065757610246565b806327b3bf11116101c757806355f804b31161018b57806355f804b3146104ca578063617aa43c146104f35780636352211e1461051c5780636817c76c146105595780636c0360eb1461058457610246565b806327b3bf111461040857806328d7b276146104335780632d20fb601461045c5780632db115441461048557806342842e0e146104a157610246565b806318160ddd1161020e57806318160ddd146103425780631b59169d1461036d5780631bdc608e1461038957806322212e2b146103b457806323b872dd146103df57610246565b806301ffc9a71461024b57806306fdde0314610288578063081812fc146102b3578063095ea7b3146102f057806317ccc54b14610319575b600080fd5b34801561025757600080fd5b50610272600480360381019061026d9190613df7565b61095c565b60405161027f9190613e3f565b60405180910390f35b34801561029457600080fd5b5061029d610a3e565b6040516102aa9190613ef3565b60405180910390f35b3480156102bf57600080fd5b506102da60048036038101906102d59190613f4b565b610ad0565b6040516102e79190613fb9565b60405180910390f35b3480156102fc57600080fd5b5061031760048036038101906103129190614000565b610b4c565b005b34801561032557600080fd5b50610340600480360381019061033b9190614040565b610c57565b005b34801561034e57600080fd5b50610357610d17565b604051610364919061407c565b60405180910390f35b610387600480360381019061038291906140fc565b610d2e565b005b34801561039557600080fd5b5061039e6110ec565b6040516103ab919061407c565b60405180910390f35b3480156103c057600080fd5b506103c96110f2565b6040516103d69190614189565b60405180910390f35b3480156103eb57600080fd5b50610406600480360381019061040191906141a4565b6110f8565b005b34801561041457600080fd5b5061041d611108565b60405161042a919061407c565b60405180910390f35b34801561043f57600080fd5b5061045a60048036038101906104559190614223565b61110e565b005b34801561046857600080fd5b50610483600480360381019061047e9190613f4b565b611194565b005b61049f600480360381019061049a9190613f4b565b611272565b005b3480156104ad57600080fd5b506104c860048036038101906104c391906141a4565b61158e565b005b3480156104d657600080fd5b506104f160048036038101906104ec91906142a6565b6115ae565b005b3480156104ff57600080fd5b5061051a600480360381019061051591906142f3565b611640565b005b34801561052857600080fd5b50610543600480360381019061053e9190613f4b565b61175a565b6040516105509190613fb9565b60405180910390f35b34801561056557600080fd5b5061056e611770565b60405161057b919061407c565b60405180910390f35b34801561059057600080fd5b50610599611794565b6040516105a69190613ef3565b60405180910390f35b3480156105bb57600080fd5b506105d660048036038101906105d19190614040565b6117a3565b6040516105e3919061407c565b60405180910390f35b3480156105f857600080fd5b50610601611873565b005b34801561060f57600080fd5b5061062a60048036038101906106259190614346565b6118fb565b005b34801561063857600080fd5b50610641611bff565b60405161064e919061407c565b60405180910390f35b34801561066357600080fd5b5061066c611c23565b6040516106799190613fb9565b60405180910390f35b34801561068e57600080fd5b50610697611c4d565b6040516106a49190613ef3565b60405180910390f35b3480156106b957600080fd5b506106c2611cdf565b6040516106cf9190614405565b60405180910390f35b3480156106e457600080fd5b506106ed611d05565b6040516106fa9190614189565b60405180910390f35b34801561070f57600080fd5b5061072a6004803603810190610725919061444c565b611d0b565b005b34801561073857600080fd5b50610753600480360381019061074e9190613f4b565b611e83565b6040516107609190614189565b60405180910390f35b34801561077557600080fd5b5061077e611edf565b60405161078b919061407c565b60405180910390f35b3480156107a057600080fd5b506107a9611f03565b005b3480156107b757600080fd5b506107d260048036038101906107cd9190614040565b612084565b6040516107df919061407c565b60405180910390f35b3480156107f457600080fd5b5061080f600480360381019061080a91906145bc565b612096565b005b34801561081d57600080fd5b5061083860048036038101906108339190613f4b565b612112565b005b34801561084657600080fd5b5061084f6122c9565b60405161085c919061407c565b60405180910390f35b34801561087157600080fd5b5061088c60048036038101906108879190613f4b565b6122cf565b6040516108999190613ef3565b60405180910390f35b3480156108ae57600080fd5b506108b761236e565b6040516108c4919061407c565b60405180910390f35b3480156108d957600080fd5b506108f460048036038101906108ef919061463f565b612374565b6040516109019190613e3f565b60405180910390f35b34801561091657600080fd5b50610931600480360381019061092c9190614040565b612408565b005b34801561093f57600080fd5b5061095a60048036038101906109559190614223565b612500565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610a2757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610a375750610a3682612586565b5b9050919050565b606060028054610a4d906146ae565b80601f0160208091040260200160405190810160405280929190818152602001828054610a79906146ae565b8015610ac65780601f10610a9b57610100808354040283529160200191610ac6565b820191906000526020600020905b815481529060010190602001808311610aa957829003601f168201915b5050505050905090565b6000610adb826125f0565b610b11576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b578261175a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bbf576040517f943f7b8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610bde61263e565b73ffffffffffffffffffffffffffffffffffffffff1614158015610c105750610c0e81610c0961263e565b612374565b155b15610c47576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c52838383612646565b505050565b610c5f61263e565b73ffffffffffffffffffffffffffffffffffffffff16610c7d611c23565b73ffffffffffffffffffffffffffffffffffffffff1614610cd3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cca9061472c565b60405180910390fd5b80601260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610d216126f8565b6001546000540303905090565b6002600a541415610d74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6b90614798565b60405180910390fd5b6002600a81905550600e54600081118015610d8e57508042115b610dcd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc49061482a565b60405180910390fd5b84843373ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610e3d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e34906148bc565b60405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000000457610e7883610e6a610d17565b6126fd90919063ffffffff16565b1115610eb9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb09061494e565b60405180910390fd5b80610ed583610ec733612713565b6126fd90919063ffffffff16565b1115610f16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0d906149e0565b60405180910390fd5b60008211610f59576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5090614a72565b60405180910390fd5b86610f8d817f000000000000000000000000000000000000000000000000049f0dbc5634800061272590919063ffffffff16565b3414610fce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fc590614b04565b60405180910390fd5b60003411611011576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161100890614a72565b60405180910390fd5b86338787600b5461108c838380806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050828688604051602001611071929190614b8d565b6040516020818303038152906040528051906020012061273b565b6110cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110c290614c2b565b60405180910390fd5b6110d5338e612752565b5050505050505050506001600a8190555050505050565b600f5481565b600b5481565b6111038383836128a2565b505050565b600d5481565b61111661263e565b73ffffffffffffffffffffffffffffffffffffffff16611134611c23565b73ffffffffffffffffffffffffffffffffffffffff161461118a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111819061472c565b60405180910390fd5b80600b8190555050565b61119c61263e565b73ffffffffffffffffffffffffffffffffffffffff166111ba611c23565b73ffffffffffffffffffffffffffffffffffffffff1614611210576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112079061472c565b60405180910390fd5b6002600a541415611256576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124d90614798565b60405180910390fd5b6002600a8190555061126781612d58565b6001600a8190555050565b6002600a5414156112b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112af90614798565b60405180910390fd5b6002600a81905550600f546000811180156112d257508042115b611311576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113089061482a565b60405180910390fd5b817f00000000000000000000000000000000000000000000000000000000000000023373ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff16146113a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611398906148bc565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000004576113dc836113ce610d17565b6126fd90919063ffffffff16565b111561141d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114149061494e565b60405180910390fd5b806114398361142b33612713565b6126fd90919063ffffffff16565b111561147a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611471906149e0565b60405180910390fd5b600082116114bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114b490614a72565b60405180910390fd5b836114f1817f000000000000000000000000000000000000000000000000049f0dbc5634800061272590919063ffffffff16565b3414611532576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161152990614b04565b60405180910390fd5b60003411611575576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161156c90614a72565b60405180910390fd5b61157f3386612752565b505050506001600a8190555050565b6115a983838360405180602001604052806000815250612096565b505050565b6115b661263e565b73ffffffffffffffffffffffffffffffffffffffff166115d4611c23565b73ffffffffffffffffffffffffffffffffffffffff161461162a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116219061472c565b60405180910390fd5b81816011919061163b929190613ca5565b505050565b61164861263e565b73ffffffffffffffffffffffffffffffffffffffff16611666611c23565b73ffffffffffffffffffffffffffffffffffffffff16146116bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b39061472c565b60405180910390fd5b8282116116fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f590614cbd565b60405180910390fd5b818111611740576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173790614d4f565b60405180910390fd5b82600d8190555081600e8190555080600f81905550505050565b600061176582612fb7565b600001519050919050565b7f000000000000000000000000000000000000000000000000049f0dbc5634800081565b606061179e613246565b905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561180b576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900467ffffffffffffffff1667ffffffffffffffff169050919050565b61187b61263e565b73ffffffffffffffffffffffffffffffffffffffff16611899611c23565b73ffffffffffffffffffffffffffffffffffffffff16146118ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118e69061472c565b60405180910390fd5b6118f960006132d8565b565b6002600a541415611941576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193890614798565b60405180910390fd5b6002600a81905550600d5460008111801561195b57508042115b61199a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119919061482a565b60405180910390fd5b83843373ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614611a0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a01906148bc565b60405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000000457611a4583611a37610d17565b6126fd90919063ffffffff16565b1115611a86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a7d9061494e565b60405180910390fd5b80611aa283611a9433612713565b6126fd90919063ffffffff16565b1115611ae3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ada906149e0565b60405180910390fd5b60008211611b26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b1d90614a72565b60405180910390fd5b85338686600c54611ba1838380806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050828688604051602001611b86929190614b8d565b6040516020818303038152906040528051906020012061273b565b611be0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bd790614c2b565b60405180910390fd5b611bea338c612752565b50505050505050506001600a81905550505050565b7f000000000000000000000000000000000000000000000000000000000000002881565b6000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060038054611c5c906146ae565b80601f0160208091040260200160405190810160405280929190818152602001828054611c88906146ae565b8015611cd55780601f10611caa57610100808354040283529160200191611cd5565b820191906000526020600020905b815481529060010190602001808311611cb857829003601f168201915b5050505050905090565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600c5481565b611d1361263e565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d78576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060076000611d8561263e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611e3261263e565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611e779190613e3f565b60405180910390a35050565b6000611e8e826125f0565b611ec4576040517f963eb14f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60106000838152602001908152602001600020549050919050565b7f000000000000000000000000000000000000000000000000000000000000000281565b611f0b61263e565b73ffffffffffffffffffffffffffffffffffffffff16611f29611c23565b73ffffffffffffffffffffffffffffffffffffffff1614611f7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f769061472c565b60405180910390fd5b6002600a541415611fc5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fbc90614798565b60405180910390fd5b6002600a8190555060003373ffffffffffffffffffffffffffffffffffffffff1647604051611ff390614da0565b60006040518083038185875af1925050503d8060008114612030576040519150601f19603f3d011682016040523d82523d6000602084013e612035565b606091505b5050905080612079576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161207090614e27565b60405180910390fd5b506001600a81905550565b600061208f82612713565b9050919050565b6120a18484846128a2565b6120c08373ffffffffffffffffffffffffffffffffffffffff1661339e565b80156120d557506120d3848484846133c1565b155b1561210c576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b61211a61263e565b73ffffffffffffffffffffffffffffffffffffffff16612138611c23565b73ffffffffffffffffffffffffffffffffffffffff161461218e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121859061472c565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000286121c9826121bb610d17565b6126fd90919063ffffffff16565b111561220a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161220190614eb9565b60405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000290506000612244828461352190919063ffffffff16565b14612284576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161227b90614f4b565b60405180910390fd5b6000612299828461353790919063ffffffff16565b905060005b818110156122c3576122b03384612752565b80806122bb90614f9a565b91505061229e565b50505050565b600e5481565b60606122da826125f0565b612310576040517fa14c4b5000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061231a613246565b905060008151141561233b5760405180602001604052806000815250612366565b806123458461354d565b60405160200161235692919061501f565b6040516020818303038152906040525b915050919050565b60085481565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61241061263e565b73ffffffffffffffffffffffffffffffffffffffff1661242e611c23565b73ffffffffffffffffffffffffffffffffffffffff1614612484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161247b9061472c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156124f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124eb906150b5565b60405180910390fd5b6124fd816132d8565b50565b61250861263e565b73ffffffffffffffffffffffffffffffffffffffff16612526611c23565b73ffffffffffffffffffffffffffffffffffffffff161461257c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125739061472c565b60405180910390fd5b80600c8190555050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000816125fb6126f8565b1115801561260a575060005482105b8015612637575060046000838152602001908152602001600020600001601c9054906101000a900460ff16155b9050919050565b600033905090565b826006600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b600090565b6000818361270b91906150d5565b905092915050565b600061271e826136ae565b9050919050565b60008183612733919061512b565b905092915050565b6000826127488584613718565b1490509392505050565b61275c828261378d565b6000612766610d17565b9050600061277d83836137ab90919063ffffffff16565b905060008367ffffffffffffffff81111561279b5761279a614491565b5b6040519080825280602002602001820160405280156127c95781602001602082028036833780820191505090505b50905060005b848110156128485760006127ec82856126fd90919063ffffffff16565b905060006127f9826137c1565b90508084848151811061280f5761280e615185565b5b6020026020010181815250508060106000848152602001908152602001600020819055505050808061284090614f9a565b9150506127cf565b508473ffffffffffffffffffffffffffffffffffffffff167f5cb27d2833c0b1f5f25192224a4f5c4573f3c2a9394c0a0a9a31c092e8879eb484868460405161289393929190615272565b60405180910390a25050505050565b60006128ad82612fb7565b90508373ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612918576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008473ffffffffffffffffffffffffffffffffffffffff1661293961263e565b73ffffffffffffffffffffffffffffffffffffffff16148061296857506129678561296261263e565b612374565b5b806129ad575061297661263e565b73ffffffffffffffffffffffffffffffffffffffff1661299584610ad0565b73ffffffffffffffffffffffffffffffffffffffff16145b9050806129e6576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612a4d576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612a5a85858560016138a2565b612a6660008487612646565b6001600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160392506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506001600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600460008581526020019081526020016000209050848160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550428160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060006001850190506000600460008381526020019081526020016000209050600073ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415612ce6576000548214612ce557878160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084602001518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b505050828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612d5185858560016138a8565b5050505050565b6000811415612d93576040517f56be441500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612d9b6126f8565b6000541415612dd6576040517fc0367cab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060085490506000811415612df157612dee6126f8565b90505b6000548110612e2c576040517f70e89b1b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006001838301039050600054600182011115612e4c5760016000540390505b60008290505b818111612fa757600073ffffffffffffffffffffffffffffffffffffffff166004600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148015612eec575060046000828152602001908152602001600020600001601c9054906101000a900460ff16155b15612f9a576000612efc82612fb7565b905080600001516004600084815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080602001516004600084815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550505b8080600101915050612e52565b5060018101600881905550505050565b612fbf613d2b565b600082905080612fcd6126f8565b11158015612fdc575060005481105b1561320f576000600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050806040015161320d57600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff16146130f1578092505050613241565b5b60011561320c57818060019003925050600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614613207578092505050613241565b6130f2565b5b505b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b606060118054613255906146ae565b80601f0160208091040260200160405190810160405280929190818152602001828054613281906146ae565b80156132ce5780601f106132a3576101008083540402835291602001916132ce565b820191906000526020600020905b8154815290600101906020018083116132b157829003601f168201915b5050505050905090565b6000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60008373ffffffffffffffffffffffffffffffffffffffff1663150b7a026133e761263e565b8786866040518563ffffffff1660e01b81526004016134099493929190615305565b602060405180830381600087803b15801561342357600080fd5b505af192505050801561345457506040513d601f19601f820116820180604052508101906134519190615366565b60015b6134ce573d8060008114613484576040519150601f19603f3d011682016040523d82523d6000602084013e613489565b606091505b506000815114156134c6576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050949350505050565b6000818361352f91906153c2565b905092915050565b6000818361354591906153f3565b905092915050565b60606000821415613595576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506136a9565b600082905060005b600082146135c75780806135b090614f9a565b915050600a826135c091906153f3565b915061359d565b60008167ffffffffffffffff8111156135e3576135e2614491565b5b6040519080825280601f01601f1916602001820160405280156136155781602001600182028036833780820191505090505b5090505b600085146136a25760018261362e9190615424565b9150600a8561363d91906153c2565b603061364991906150d5565b60f81b81838151811061365f5761365e615185565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561369b91906153f3565b9450613619565b8093505050505b919050565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160089054906101000a900467ffffffffffffffff1667ffffffffffffffff169050919050565b60008082905060005b845181101561378257600085828151811061373f5761373e615185565b5b602002602001015190508083116137615761375a83826138ae565b925061376e565b61376b81846138ae565b92505b50808061377a90614f9a565b915050613721565b508091505092915050565b6137a78282604051806020016040528060008152506138c5565b5050565b600081836137b99190615424565b905092915050565b600081326001436137d29190615424565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631486a2766040518163ffffffff1660e01b815260040160206040518083038186803b15801561383a57600080fd5b505afa15801561384e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613872919061546d565b604051602001613885949392919061549a565b604051602081830303815290604052805190602001209050919050565b50505050565b50505050565b600082600052816020526040600020905092915050565b6138d283838360016138d7565b505050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415613944576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600084141561397f576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61398c60008683876138a2565b83600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555083600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160088282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550846004600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426004600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550600081905060008582019050838015613b565750613b558773ffffffffffffffffffffffffffffffffffffffff1661339e565b5b15613c1c575b818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4613bcb60008884806001019550886133c1565b613c01576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80821415613b5c578260005414613c1757600080fd5b613c88565b5b818060010192508773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a480821415613c1d575b816000819055505050613c9e60008683876138a8565b5050505050565b828054613cb1906146ae565b90600052602060002090601f016020900481019282613cd35760008555613d1a565b82601f10613cec57803560ff1916838001178555613d1a565b82800160010185558215613d1a579182015b82811115613d19578235825591602001919060010190613cfe565b5b509050613d279190613d6e565b5090565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681526020016000151581525090565b5b80821115613d87576000816000905550600101613d6f565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b613dd481613d9f565b8114613ddf57600080fd5b50565b600081359050613df181613dcb565b92915050565b600060208284031215613e0d57613e0c613d95565b5b6000613e1b84828501613de2565b91505092915050565b60008115159050919050565b613e3981613e24565b82525050565b6000602082019050613e546000830184613e30565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015613e94578082015181840152602081019050613e79565b83811115613ea3576000848401525b50505050565b6000601f19601f8301169050919050565b6000613ec582613e5a565b613ecf8185613e65565b9350613edf818560208601613e76565b613ee881613ea9565b840191505092915050565b60006020820190508181036000830152613f0d8184613eba565b905092915050565b6000819050919050565b613f2881613f15565b8114613f3357600080fd5b50565b600081359050613f4581613f1f565b92915050565b600060208284031215613f6157613f60613d95565b5b6000613f6f84828501613f36565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613fa382613f78565b9050919050565b613fb381613f98565b82525050565b6000602082019050613fce6000830184613faa565b92915050565b613fdd81613f98565b8114613fe857600080fd5b50565b600081359050613ffa81613fd4565b92915050565b6000806040838503121561401757614016613d95565b5b600061402585828601613feb565b925050602061403685828601613f36565b9150509250929050565b60006020828403121561405657614055613d95565b5b600061406484828501613feb565b91505092915050565b61407681613f15565b82525050565b6000602082019050614091600083018461406d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f8401126140bc576140bb614097565b5b8235905067ffffffffffffffff8111156140d9576140d861409c565b5b6020830191508360208202830111156140f5576140f46140a1565b5b9250929050565b6000806000806060858703121561411657614115613d95565b5b600061412487828801613f36565b945050602061413587828801613f36565b935050604085013567ffffffffffffffff81111561415657614155613d9a565b5b614162878288016140a6565b925092505092959194509250565b6000819050919050565b61418381614170565b82525050565b600060208201905061419e600083018461417a565b92915050565b6000806000606084860312156141bd576141bc613d95565b5b60006141cb86828701613feb565b93505060206141dc86828701613feb565b92505060406141ed86828701613f36565b9150509250925092565b61420081614170565b811461420b57600080fd5b50565b60008135905061421d816141f7565b92915050565b60006020828403121561423957614238613d95565b5b60006142478482850161420e565b91505092915050565b60008083601f84011261426657614265614097565b5b8235905067ffffffffffffffff8111156142835761428261409c565b5b60208301915083600182028301111561429f5761429e6140a1565b5b9250929050565b600080602083850312156142bd576142bc613d95565b5b600083013567ffffffffffffffff8111156142db576142da613d9a565b5b6142e785828601614250565b92509250509250929050565b60008060006060848603121561430c5761430b613d95565b5b600061431a86828701613f36565b935050602061432b86828701613f36565b925050604061433c86828701613f36565b9150509250925092565b60008060006040848603121561435f5761435e613d95565b5b600061436d86828701613f36565b935050602084013567ffffffffffffffff81111561438e5761438d613d9a565b5b61439a868287016140a6565b92509250509250925092565b6000819050919050565b60006143cb6143c66143c184613f78565b6143a6565b613f78565b9050919050565b60006143dd826143b0565b9050919050565b60006143ef826143d2565b9050919050565b6143ff816143e4565b82525050565b600060208201905061441a60008301846143f6565b92915050565b61442981613e24565b811461443457600080fd5b50565b60008135905061444681614420565b92915050565b6000806040838503121561446357614462613d95565b5b600061447185828601613feb565b925050602061448285828601614437565b9150509250929050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6144c982613ea9565b810181811067ffffffffffffffff821117156144e8576144e7614491565b5b80604052505050565b60006144fb613d8b565b905061450782826144c0565b919050565b600067ffffffffffffffff82111561452757614526614491565b5b61453082613ea9565b9050602081019050919050565b82818337600083830152505050565b600061455f61455a8461450c565b6144f1565b90508281526020810184848401111561457b5761457a61448c565b5b61458684828561453d565b509392505050565b600082601f8301126145a3576145a2614097565b5b81356145b384826020860161454c565b91505092915050565b600080600080608085870312156145d6576145d5613d95565b5b60006145e487828801613feb565b94505060206145f587828801613feb565b935050604061460687828801613f36565b925050606085013567ffffffffffffffff81111561462757614626613d9a565b5b6146338782880161458e565b91505092959194509250565b6000806040838503121561465657614655613d95565b5b600061466485828601613feb565b925050602061467585828601613feb565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806146c657607f821691505b602082108114156146da576146d961467f565b5b50919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000614716602083613e65565b9150614721826146e0565b602082019050919050565b6000602082019050818103600083015261474581614709565b9050919050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b6000614782601f83613e65565b915061478d8261474c565b602082019050919050565b600060208201905081810360008301526147b181614775565b9050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d6d696e742d74696d65000000000000000000000000000000000000000000602082015250565b6000614814602b83613e65565b915061481f826147b8565b604082019050919050565b6000602082019050818103600083015261484381614807565b9050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d6d696e742d63616c6c657200000000000000000000000000000000000000602082015250565b60006148a6602d83613e65565b91506148b18261484a565b604082019050919050565b600060208201905081810360008301526148d581614899565b9050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d746f74616c2d737570706c79000000000000000000000000000000000000602082015250565b6000614938602e83613e65565b9150614943826148dc565b604082019050919050565b600060208201905081810360008301526149678161492b565b9050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d696e766f636174696f6e2d75707065722d626f756e646172790000000000602082015250565b60006149ca603b83613e65565b91506149d58261496e565b604082019050919050565b600060208201905081810360008301526149f9816149bd565b9050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d696e766f636174696f6e2d6c6f7765722d626f756e646172790000000000602082015250565b6000614a5c603b83613e65565b9150614a6782614a00565b604082019050919050565b60006020820190508181036000830152614a8b81614a4f565b9050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d6d696e742d76616c75650000000000000000000000000000000000000000602082015250565b6000614aee602c83613e65565b9150614af982614a92565b604082019050919050565b60006020820190508181036000830152614b1d81614ae1565b9050919050565b60008160601b9050919050565b6000614b3c82614b24565b9050919050565b6000614b4e82614b31565b9050919050565b614b66614b6182613f98565b614b43565b82525050565b6000819050919050565b614b87614b8282613f15565b614b6c565b82525050565b6000614b998285614b55565b601482019150614ba98284614b76565b6020820191508190509392505050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d616464726573732d70726f6f660000000000000000000000000000000000602082015250565b6000614c15602f83613e65565b9150614c2082614bb9565b604082019050919050565b60006020820190508181036000830152614c4481614c08565b9050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d70726573616c652d74696d65000000000000000000000000000000000000602082015250565b6000614ca7602e83613e65565b9150614cb282614c4b565b604082019050919050565b60006020820190508181036000830152614cd681614c9a565b9050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d7075626c69632d74696d6500000000000000000000000000000000000000602082015250565b6000614d39602d83613e65565b9150614d4482614cdd565b604082019050919050565b60006020820190508181036000830152614d6881614d2c565b9050919050565b600081905092915050565b50565b6000614d8a600083614d6f565b9150614d9582614d7a565b600082019050919050565b6000614dab82614d7d565b9150819050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d77697468647261772d6d6f6e657900000000000000000000000000000000602082015250565b6000614e11603083613e65565b9150614e1c82614db5565b604082019050919050565b60006020820190508181036000830152614e4081614e04565b9050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d70726f6d6f74696f6e2d737570706c790000000000000000000000000000602082015250565b6000614ea3603283613e65565b9150614eae82614e47565b604082019050919050565b60006020820190508181036000830152614ed281614e96565b9050919050565b7f52686170736f647943726561746f7247656e657261746976652f696e76616c6960008201527f642d62617463682d6d756c7469706c6500000000000000000000000000000000602082015250565b6000614f35603083613e65565b9150614f4082614ed9565b604082019050919050565b60006020820190508181036000830152614f6481614f28565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000614fa582613f15565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614fd857614fd7614f6b565b5b600182019050919050565b600081905092915050565b6000614ff982613e5a565b6150038185614fe3565b9350615013818560208601613e76565b80840191505092915050565b600061502b8285614fee565b91506150378284614fee565b91508190509392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061509f602683613e65565b91506150aa82615043565b604082019050919050565b600060208201905081810360008301526150ce81615092565b9050919050565b60006150e082613f15565b91506150eb83613f15565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156151205761511f614f6b565b5b828201905092915050565b600061513682613f15565b915061514183613f15565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561517a57615179614f6b565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6151e981614170565b82525050565b60006151fb83836151e0565b60208301905092915050565b6000602082019050919050565b600061521f826151b4565b61522981856151bf565b9350615234836151d0565b8060005b8381101561526557815161524c88826151ef565b975061525783615207565b925050600181019050615238565b5085935050505092915050565b6000606082019050615287600083018661406d565b615294602083018561406d565b81810360408301526152a68184615214565b9050949350505050565b600081519050919050565b600082825260208201905092915050565b60006152d7826152b0565b6152e181856152bb565b93506152f1818560208601613e76565b6152fa81613ea9565b840191505092915050565b600060808201905061531a6000830187613faa565b6153276020830186613faa565b615334604083018561406d565b818103606083015261534681846152cc565b905095945050505050565b60008151905061536081613dcb565b92915050565b60006020828403121561537c5761537b613d95565b5b600061538a84828501615351565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006153cd82613f15565b91506153d883613f15565b9250826153e8576153e7615393565b5b828206905092915050565b60006153fe82613f15565b915061540983613f15565b92508261541957615418615393565b5b828204905092915050565b600061542f82613f15565b915061543a83613f15565b92508282101561544d5761544c614f6b565b5b828203905092915050565b60008151905061546781613f1f565b92915050565b60006020828403121561548357615482613d95565b5b600061549184828501615458565b91505092915050565b60006154a68287614b76565b6020820191506154b68286614b55565b6014820191506154c68285614b76565b6020820191506154d68284614b76565b6020820191508190509594505050505056fea2646970667358221220ae081ea08215d7efa99672f67755254bdee1c59774533510f28e2b984f56834c64736f6c63430008090033
Verified Source Code Full Match
Compiler: v0.8.9+commit.e5eed63a
EVM: istanbul
Optimization: No
ERC721A.sol 626 lines
// SPDX-License-Identifier: MIT
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
error ApprovalCallerNotOwnerNorApproved();
error ApprovalQueryForNonexistentToken();
error ApproveToCaller();
error ApprovalToCurrentOwner();
error BalanceQueryForZeroAddress();
error MintToZeroAddress();
error MintZeroQuantity();
error OwnerQueryForNonexistentToken();
error TransferCallerNotOwnerNorApproved();
error TransferFromIncorrectOwner();
error TransferToNonERC721ReceiverImplementer();
error TransferToZeroAddress();
error URIQueryForNonexistentToken();
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension. Built to optimize for lower gas during batch mints.
*
* Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..).
*
* Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
*
* Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Compiler will pack this into a single 256bit word.
struct TokenOwnership {
// The address of the owner.
address addr;
// Keeps track of the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
}
// Compiler will pack this into a single 256bit word.
struct AddressData {
// Realistically, 2**64-1 is more than enough.
uint64 balance;
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
// For miscellaneous variable(s) pertaining to the address
// (e.g. number of whitelist mint slots used).
// If there are multiple variables, please pack them into a uint64.
uint64 aux;
}
// The tokenId of the next token to be minted.
uint256 internal _currentIndex;
// The number of tokens burned.
uint256 internal _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 _ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
}
/**
* To change the starting tokenId, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens.
*/
function totalSupply() public view returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than _currentIndex - _startTokenId() times
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
/**
* Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view returns (uint256) {
// Counter underflow is impossible as _currentIndex does not decrement,
// and it is initialized to _startTokenId()
unchecked {
return _currentIndex - _startTokenId();
}
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return uint256(_addressData[owner].balance);
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return uint256(_addressData[owner].numberMinted);
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return uint256(_addressData[owner].numberBurned);
}
/**
* Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return _addressData[owner].aux;
}
/**
* Sets the auxillary 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 {
_addressData[owner].aux = aux;
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr && curr < _currentIndex) {
TokenOwnership memory ownership = _ownerships[curr];
if (!ownership.burned) {
if (ownership.addr != address(0)) {
return ownership;
}
// Invariant:
// There will always be an ownership that has an address and is not burned
// before an ownership that does not have an address and is not burned.
// Hence, curr will not underflow.
while (true) {
curr--;
ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return _ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = ERC721A.ownerOf(tokenId);
if (to == owner) revert ApprovalToCurrentOwner();
if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
if (operator == _msgSender()) revert ApproveToCaller();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
_transfer(from, to, tokenId);
if (to.isContract() && !_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, 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.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @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.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
uint256 end = updatedIndex + quantity;
if (safe && to.isContract()) {
do {
emit Transfer(address(0), to, updatedIndex);
if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (updatedIndex != end);
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
} else {
do {
emit Transfer(address(0), to, updatedIndex++);
} while (updatedIndex != end);
}
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, from);
// 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 {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = to;
currSlot.startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev This is 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 {
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
address from = prevOwnership.addr;
if (approvalCheck) {
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, from);
// 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 {
AddressData storage addressData = _addressData[from];
addressData.balance -= 1;
addressData.numberBurned += 1;
// Keep track of who burned the token, and the timestamp of burning.
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = from;
currSlot.startTimestamp = uint64(block.timestamp);
currSlot.burned = true;
// If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
/**
* @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 {}
}
REFLECTIONS.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./../RhapsodyCreatorGenerative.sol";
//////////////////////////////////////////////////////////////////////////////////////////////
// //
// .======-. .=====- ========. .==. ==: ==: =========- -=== .-==: //
// -%%****%%%==%%**#%%=.%%******: #%%# %%%*. :#%%+ %%%%%%%%%. .%%% .:. -%+ //
// -%% -%%%%# +%%.%%. *%##%+ %%#%%= +%##%+ %%%%%%%%- .. -%% =%%. %+ //
// -%% :%%%%++*%%+.%%%%%%# =%%..%%- %%-.*%#%%= *%+ %%%%%%%+ *# =% :#+ //
// -%% :%%%%+#%%= .%%-:::: :%%+::+%%:%%- -%#: *%+ %%%%%%* :**: * :+++: - //
// -%% :%%%%# =%%+.%%. #%%%%%%%%#%%- *%+ %%%%%%. =%%%* //
// -%%****%%%==%# :#%%%%******#%* #%%%- *%+ :::::. .%%%%%%. .::: := //
// .======-. .=- -=========== ===. -=: -======- :=: //
// //
//////////////////////////////////////////////////////////////////////////////////////////////
/// @title REFLECTIONS by Jacob Riglin
/// @author rlxyz.eth
contract REFLECTIONS is RhapsodyCreatorGenerative {
constructor() RhapsodyCreatorGenerative("REFLECTIONS by Jacob Riglin", "REFLECTIONS", 1111, 2, 40, 0.333 ether) {}
}
RhapsodyCreatorGenerative.sol 312 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "erc721a/contracts/ERC721A.sol";
import "erc721a/contracts/extensions/ERC721AOwnersExplicit.sol";
import "./utils/interfaces/IRandomizer.sol";
error HashQueryForNonexistentToken();
contract RhapsodyCreatorGenerative is ERC721A, ERC721AOwnersExplicit, Ownable, ReentrancyGuard {
/// ============ Libraries ============
/// @notice safe math for arithmetic operations
using SafeMath for uint256;
/// ============ Events ============
event Created(address indexed to, uint256 currentTotalSupply, uint256 invocations, bytes32[] identifiers);
/// ============ Immutable storage ============
/// @notice promotional nfts count
uint256 public immutable amountForPromotion;
/// @notice max mintable tokens for each address in public
uint256 public immutable maxPublicBatchPerAddress;
/// @notice mint price of each nft; same for pre/public sale.
uint256 public immutable mintPrice;
/// @notice total number of tokens in the collection
uint256 internal immutable collectionSize;
// ============ Mutable storage ============
/// @notice ERC721-presale inclusion root
bytes32 public presaleMerkleRoot;
/// @notice ERC721-claim inclusion root
bytes32 public claimMerkleRoot;
/// @notice time the public starts
uint256 public claimTime;
/// @notice time the presale starts
uint256 public presaleTime;
/// @notice time the public starts
uint256 public publicTime;
/// @notice the hash of each token
mapping(uint256 => bytes32) private _tokenHash;
// ============ Private storage ============
string private _baseTokenURI;
// ============= Dependencies ==============
/// @notice the randomizer contract
IRandomizer public mintRandomizerContract;
/// ============= Constructor =============
/// @notice Creates a new Creator contract
/// @param _collectionSize the total size of the collection
/// @param _maxPublicBatchPerAddress max mintable tokens in public sale
/// @param _amountForPromotion promotional nfts count
/// @param _mintPrice mint price of each nft
constructor(
string memory _name,
string memory _symbol,
uint256 _collectionSize,
uint256 _maxPublicBatchPerAddress,
uint256 _amountForPromotion,
uint256 _mintPrice
) ERC721A(_name, _symbol) {
require(_collectionSize > 0, "RhapsodyCreatorGenerative/invalid-collection-size");
require(_amountForPromotion <= _collectionSize, "RhapsodyCreatorGenerative/invalid-promotion-amount");
require(_mintPrice > 0, "RhapsodyCreatorGenerative/invalid-mint-price");
collectionSize = _collectionSize;
maxPublicBatchPerAddress = _maxPublicBatchPerAddress;
amountForPromotion = _amountForPromotion;
mintPrice = _mintPrice;
}
/// =========== Sale ===========
/// @notice Allows claim of tokens if address is part of merkle tree
/// @param invocations number of tokens to mint
/// @param proof merkle proof to prove address and token mint count are in tree
/// @dev user must mint max invocations
function claimMint(uint256 invocations, bytes32[] calldata proof)
external
nonReentrant
isMintLive(claimTime)
isMintValid(invocations, invocations)
isMintProofValid(invocations, msg.sender, proof, claimMerkleRoot)
{
_mintMany(msg.sender, invocations);
}
/// @notice Allows presale minting of tokens if address is part of merkle tree
/// @param invocations number of tokens to mint
/// @param maxInvocation max number of invocations of the user
/// @param proof merkle proof to prove address and token mint count are in tree
function presaleMint(
uint256 invocations,
uint256 maxInvocation,
bytes32[] calldata proof
)
external
payable
nonReentrant
isMintLive(presaleTime)
isMintValid(invocations, maxInvocation)
isMintPricingValid(invocations)
isMintProofValid(maxInvocation, msg.sender, proof, presaleMerkleRoot)
{
_mintMany(msg.sender, invocations);
}
/// @notice Allows public minting of tokens
/// @param invocations number of tokens to mint
/// @dev user can only mint less than maxPublicBatchPerAddress of tokens
function publicMint(uint256 invocations)
external
payable
nonReentrant
isMintLive(publicTime)
isMintValid(invocations, maxPublicBatchPerAddress)
isMintPricingValid(invocations)
{
_mintMany(msg.sender, invocations);
}
/// @notice mint tokens in batches
/// @param to address to mint to
/// @param invocations number of tokens to mint
function _mintMany(address to, uint256 invocations) internal {
_safeMint(to, invocations);
uint256 currentTotalSupply = totalSupply();
uint256 currentInvocations = currentTotalSupply.sub(invocations);
bytes32[] memory uniqueIdentifiers = new bytes32[](invocations);
for (uint256 i = 0; i < invocations; i++) {
uint256 currentIndex = currentInvocations.add(i);
bytes32 identifier = _generateUniqueIdentifier(currentIndex);
uniqueIdentifiers[i] = identifier;
_tokenHash[currentIndex] = identifier;
}
emit Created(to, currentTotalSupply, invocations, uniqueIdentifiers);
}
/// @notice Set the time for the mint
/// @param _presaleTime time the presale starts
/// @param _publicTime time the public sale starts
/// @dev this function can serve as an "active" and "non-active" sale status
/// @dev set the values to uint256(-1) for "non-active" sale status
/// @dev also, pass contract ownership to address(0) to close sale forever
function setMintTime(
uint256 _claimTime,
uint256 _presaleTime,
uint256 _publicTime
) public onlyOwner {
require(_presaleTime > _claimTime, "RhapsodyCreatorGenerative/invalid-presale-time");
require(_publicTime > _presaleTime, "RhapsodyCreatorGenerative/invalid-public-time");
claimTime = _claimTime;
presaleTime = _presaleTime;
publicTime = _publicTime;
}
/// @notice ensures that minters need valid invocations + value to mint
modifier isMintValid(uint256 invocations, uint256 maxInvocation) {
require(tx.origin == msg.sender, "RhapsodyCreatorGenerative/invalid-mint-caller");
require(totalSupply().add(invocations) <= collectionSize, "RhapsodyCreatorGenerative/invalid-total-supply");
require(
_mintOf(msg.sender).add(invocations) <= maxInvocation,
"RhapsodyCreatorGenerative/invalid-invocation-upper-boundary"
);
require(invocations > 0, "RhapsodyCreatorGenerative/invalid-invocation-lower-boundary");
_;
}
modifier isMintPricingValid(uint256 invocations) {
require(msg.value == mintPrice.mul(invocations), "RhapsodyCreatorGenerative/invalid-mint-value");
require(msg.value > 0, "RhapsodyCreatorGenerative/invalid-invocation-lower-boundary");
_;
}
/// @notice used to check the time of mint of presale and public
/// @dev only publicTime/presaleTime variable is used here; see publicMint/presaleMint function
/// @dev time > 0 is optimization when the sale is not live; r.e mint "not-active" mode
modifier isMintLive(uint256 time) {
require(time > 0 && block.timestamp > time, "RhapsodyCreatorGenerative/invalid-mint-time");
_;
}
modifier isMintProofValid(
uint256 invocations,
address prover,
bytes32[] calldata proof,
bytes32 merkleRoot
) {
require(
MerkleProof.verify(proof, merkleRoot, keccak256(abi.encodePacked(prover, invocations))),
"RhapsodyCreatorGenerative/invalid-address-proof"
);
_;
}
/// @notice used the set the mint randomizer for on-chain generative projects
function setMintRandomizerContract(address _mintRandomizerContract) external onlyOwner {
mintRandomizerContract = IRandomizer(_mintRandomizerContract);
}
/// =========== Merkle Roots ===========
/// @notice force override the merkle root used in presale mint
/// @param _presaleMerkleRoot root of the merklelized whitelist
function setPresaleMerkleRoot(bytes32 _presaleMerkleRoot) public onlyOwner {
presaleMerkleRoot = _presaleMerkleRoot;
}
/// @notice force override the merkle root used in presale mint
/// @param _claimMerkleRoot root of the merklelized claimlist
function setClaimMerkleRoot(bytes32 _claimMerkleRoot) public onlyOwner {
claimMerkleRoot = _claimMerkleRoot;
}
/// =========== Metadata ===========
/// @notice set the new baseURI to change the tokens metadata
function setBaseURI(string calldata newBaseURI) external onlyOwner {
_baseTokenURI = newBaseURI;
}
/// @notice core metadata baseURI used for tokens metadata
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
/// @notice core metadata baseURI used for tokens metadata
function baseURI() public view returns (string memory) {
return _baseURI();
}
/// =========== Dev ===========
/// @notice used by owner to mint promotional nfts
/// @param invocations the number of invocations to batch mint
function promotionMint(uint256 invocations) external onlyOwner {
require(
totalSupply().add(invocations) <= amountForPromotion,
"RhapsodyCreatorGenerative/invalid-promotion-supply"
);
uint256 maxBatchSize = maxPublicBatchPerAddress;
require(invocations.mod(maxBatchSize) == 0, "RhapsodyCreatorGenerative/invalid-batch-multiple");
uint256 blocks = invocations.div(maxBatchSize);
for (uint256 i = 0; i < blocks; i++) {
_mintMany(msg.sender, maxBatchSize);
}
}
/// @notice withdraws the ether in the contract to owner
function withdrawMoney() external onlyOwner nonReentrant {
(bool success, ) = msg.sender.call{ value: address(this).balance }("");
require(success, "RhapsodyCreatorGenerative/invalid-withdraw-money");
}
/// @notice returns the current block timestamp
/// @dev this function is overriden in testing for time-dependent testing
function _currentTime() internal view virtual returns (uint256) {
return block.timestamp;
}
/// @notice sets the owners quantity explicity
/// @dev eliminate loops in future calls of ownerOf()
function setOwnersExplicit(uint256 quantity) external onlyOwner nonReentrant {
_setOwnersExplicit(quantity);
}
/// =========== Helpers ===========
/// @notice internally returns the number of mints of an address
function _mintOf(address _owner) internal view returns (uint256) {
return _numberMinted(_owner);
}
/// @notice returns the number of mints of an address
function mintOf(address _owner) public view returns (uint256) {
return _mintOf(_owner);
}
// @notice returns the hash of a token
function tokenHash(uint256 _tokenId) public view returns (bytes32) {
if (!_exists(_tokenId)) revert HashQueryForNonexistentToken();
return _tokenHash[_tokenId];
}
function _generateUniqueIdentifier(uint256 seed) internal view virtual returns (bytes32) {
return keccak256(abi.encodePacked(seed, tx.origin, block.number - 1, mintRandomizerContract.getRandomValue()));
}
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IRandomizer.sol 7 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IRandomizer {
function getRandomValue() external view returns (uint256);
}
ERC721.sol 447 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
SafeMath.sol 227 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
ERC721AOwnersExplicit.sol 48 lines
// SPDX-License-Identifier: MIT
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import '../ERC721A.sol';
error AllOwnershipsHaveBeenSet();
error QuantityMustBeNonZero();
error NoTokensMintedYet();
abstract contract ERC721AOwnersExplicit is ERC721A {
uint256 public nextOwnerToExplicitlySet;
/**
* @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf().
*/
function _setOwnersExplicit(uint256 quantity) internal {
if (quantity == 0) revert QuantityMustBeNonZero();
if (_currentIndex == _startTokenId()) revert NoTokensMintedYet();
uint256 _nextOwnerToExplicitlySet = nextOwnerToExplicitlySet;
if (_nextOwnerToExplicitlySet == 0) {
_nextOwnerToExplicitlySet = _startTokenId();
}
if (_nextOwnerToExplicitlySet >= _currentIndex) revert AllOwnershipsHaveBeenSet();
// Index underflow is impossible.
// Counter or index overflow is incredibly unrealistic.
unchecked {
uint256 endIndex = _nextOwnerToExplicitlySet + quantity - 1;
// Set the end index to be the last token index
if (endIndex + 1 > _currentIndex) {
endIndex = _currentIndex - 1;
}
for (uint256 i = _nextOwnerToExplicitlySet; i <= endIndex; i++) {
if (_ownerships[i].addr == address(0) && !_ownerships[i].burned) {
TokenOwnership memory ownership = _ownershipOf(i);
_ownerships[i].addr = ownership.addr;
_ownerships[i].startTimestamp = ownership.startTimestamp;
}
}
nextOwnerToExplicitlySet = endIndex + 1;
}
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
MerkleProof.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Trees proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = _efficientHash(computedHash, proofElement);
} else {
// Hash(current element of the proof + current computed hash)
computedHash = _efficientHash(proofElement, computedHash);
}
}
return computedHash;
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
Read Contract
amountForPromotion 0x76972db2 → uint256
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
claimMerkleRoot 0x9c4dab52 → bytes32
claimTime 0x27b3bf11 → uint256
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
maxPublicBatchPerAddress 0xa4babffd → uint256
mintOf 0xb1f536fa → uint256
mintPrice 0x6817c76c → uint256
mintRandomizerContract 0x993670f2 → address
name 0x06fdde03 → string
nextOwnerToExplicitlySet 0xd7224ba0 → uint256
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
presaleMerkleRoot 0x22212e2b → bytes32
presaleTime 0xc6e62e0b → uint256
publicTime 0x1bdc608e → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenHash 0xa3864397 → bytes32
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 18 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
claimMint 0x72830dfd
uint256 invocations
bytes32[] proof
presaleMint 0x1b59169d
uint256 invocations
uint256 maxInvocation
bytes32[] proof
promotionMint 0xba2f59c8
uint256 invocations
publicMint 0x2db11544
uint256 invocations
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string newBaseURI
setClaimMerkleRoot 0xfd1e2962
bytes32 _claimMerkleRoot
setMintRandomizerContract 0x17ccc54b
address _mintRandomizerContract
setMintTime 0x617aa43c
uint256 _claimTime
uint256 _presaleTime
uint256 _publicTime
setOwnersExplicit 0x2d20fb60
uint256 quantity
setPresaleMerkleRoot 0x28d7b276
bytes32 _presaleMerkleRoot
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdrawMoney 0xac446002
No parameters
Recent Transactions
No transactions found for this address