Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x470c27a0Ed83f44B09aCAE49e6cefFd1C7FaA6F0
Balance 0 ETH
Nonce 1
Code Size 15875 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

15875 bytes
0x60806040526004361061041a5760003560e01c80637835c6351161021e578063c3ac4feb11610123578063ea6eb836116100ab578063f132dc291161007a578063f132dc2914610b4f578063f2fde38b14610b64578063f4a0a52814610b84578063f6c9d9e314610ba4578063f7cb9e5414610bc45761041a565b8063ea6eb83614610ae5578063ebf0c71714610b05578063ec7d099114610b1a578063ee1cc94414610b2f5761041a565b8063d7224ba0116100f2578063d7224ba014610a5b578063dab5f34014610a70578063dc33e68114610a90578063e7b62d9614610ab0578063e985e9c514610ac55761041a565b8063c3ac4feb146109f1578063c4e41b2214610a11578063c87b56dd14610a26578063cadf881814610a465761041a565b806398590a39116101a6578063a51312c811610175578063a51312c814610972578063a7f93ebd14610992578063ad06d758146109a7578063b88d4fde146109bc578063c3441646146109dc5761041a565b806398590a39146109085780639a3bf728146109285780639ccb0fea1461093d578063a22cb465146109525761041a565b80637f44ab2f116101ed5780637f44ab2f1461089f5780638bc35c2f146108b45780638da5cb5b146108c9578063932ecebc146108de57806395d89b41146108f35761041a565b80637835c635146108445780637890b2c9146108575780637a6685f11461086a5780637d26f4701461088a5761041a565b8063431adcb1116103245780635ca1e165116102ac578063715018a61161027b578063715018a6146107ba57806371e3500c146107cf5780637263cfe2146107e45780637389fbb71461080457806377b501b9146108245761041a565b80635ca1e165146107505780636352211e146107655780636817c76c1461078557806370a082311461079a5761041a565b80634dfea627116102f35780634dfea627146106bb5780634f6ccce7146106db57806355f804b3146106fb57806356a87caa1461071b5780635b92ac0d1461073b5761041a565b8063431adcb11461064f578063438b630014610664578063442890d5146106915780634d0550de146106a65761041a565b80632c1205f4116103a75780633ccfd60b116103765780633ccfd60b146105d25780633cfac570146105e75780633e8f09871461060757806340c10f191461061c57806342842e0e1461062f5761041a565b80632c1205f4146105525780632f57bcfe146105725780632f745c59146105925780633b9ee7e4146105b25761041a565b8063095ea7b3116103ee578063095ea7b3146104d157806318160ddd146104f357806321a911f81461050857806323b872dd1461051d5780632992b0b01461053d5761041a565b806208ffdd1461041f57806301ffc9a71461045557806306fdde0314610482578063081812fc146104a4575b600080fd5b34801561042b57600080fd5b5061043f61043a366004612db8565b610be4565b60405161044c91906131f0565b60405180910390f35b34801561046157600080fd5b50610475610470366004612fa9565b610c35565b60405161044c91906131e5565b34801561048e57600080fd5b50610497610c96565b60405161044c91906131f9565b3480156104b057600080fd5b506104c46104bf366004612f91565b610d28565b60405161044c9190613150565b3480156104dd57600080fd5b506104f16104ec366004612ee0565b610d6b565b005b3480156104ff57600080fd5b5061043f610e04565b34801561051457600080fd5b5061043f610e0a565b34801561052957600080fd5b506104f1610538366004612e04565b610e10565b34801561054957600080fd5b5061043f610e1b565b34801561055e57600080fd5b5061047561056d366004612db8565b610e21565b34801561057e57600080fd5b506104f161058d366004612f77565b610e3f565b34801561059e57600080fd5b5061043f6105ad366004612ee0565b610e6e565b3480156105be57600080fd5b506104f16105cd366004612f91565b610f63565b3480156105de57600080fd5b506104f1610f84565b3480156105f357600080fd5b506104f1610602366004612f77565b61109c565b34801561061357600080fd5b5061043f6110d4565b6104f161062a366004612ee0565b6110da565b34801561063b57600080fd5b506104f161064a366004612e04565b611352565b34801561065b57600080fd5b5061047561136d565b34801561067057600080fd5b5061068461067f366004612db8565b61137e565b60405161044c91906131a1565b34801561069d57600080fd5b506104c461143b565b3480156106b257600080fd5b5061043f61144a565b3480156106c757600080fd5b506104f16106d6366004612f91565b611450565b3480156106e757600080fd5b5061043f6106f6366004612f91565b611471565b34801561070757600080fd5b506104f1610716366004612fe1565b61149d565b34801561072757600080fd5b506104f1610736366004612f91565b6114cc565b34801561074757600080fd5b506104756114ed565b34801561075c57600080fd5b5061043f6114fb565b34801561077157600080fd5b506104c4610780366004612f91565b611501565b34801561079157600080fd5b5061043f611513565b3480156107a657600080fd5b5061043f6107b5366004612db8565b611519565b3480156107c657600080fd5b506104f1611566565b3480156107db57600080fd5b506104f161157a565b3480156107f057600080fd5b506104f16107ff366004612f09565b611640565b34801561081057600080fd5b506104f161081f366004612f91565b6117fe565b34801561083057600080fd5b506104f161083f366004612ee0565b61181f565b6104f1610852366004612f91565b6118a2565b6104f1610865366004613026565b611a31565b34801561087657600080fd5b506104f1610885366004612f91565b611be1565b34801561089657600080fd5b50610475611c02565b3480156108ab57600080fd5b5061043f611c12565b3480156108c057600080fd5b5061043f611c18565b3480156108d557600080fd5b506104c4611c3c565b3480156108ea57600080fd5b506104f1611c4b565b3480156108ff57600080fd5b50610497611c7c565b34801561091457600080fd5b506104f1610923366004612f77565b611c8b565b34801561093457600080fd5b5061043f611cc7565b34801561094957600080fd5b50610475611ccd565b34801561095e57600080fd5b506104f161096d366004612eb7565b611cdc565b34801561097e57600080fd5b506104f161098d366004612f09565b611daa565b34801561099e57600080fd5b5061043f611ea4565b3480156109b357600080fd5b5061043f611eaa565b3480156109c857600080fd5b506104f16109d7366004612e3f565b611ecf565b3480156109e857600080fd5b50610475611f08565b3480156109fd57600080fd5b506104f1610a0c366004612f91565b611f11565b348015610a1d57600080fd5b5061043f611f32565b348015610a3257600080fd5b50610497610a41366004612f91565b611f3c565b348015610a5257600080fd5b5061043f611fbf565b348015610a6757600080fd5b5061043f611fc5565b348015610a7c57600080fd5b506104f1610a8b366004612f91565b611fcb565b348015610a9c57600080fd5b5061043f610aab366004612db8565b611fec565b348015610abc57600080fd5b5061043f611ff7565b348015610ad157600080fd5b50610475610ae0366004612dd2565b611ffd565b348015610af157600080fd5b506104f1610b00366004612f91565b61202b565b348015610b1157600080fd5b5061043f61204c565b348015610b2657600080fd5b5061043f612052565b348015610b3b57600080fd5b506104f1610b4a366004612f77565b612058565b348015610b5b57600080fd5b506104756120c2565b348015610b7057600080fd5b506104f1610b7f366004612db8565b6120d2565b348015610b9057600080fd5b506104f1610b9f366004612f91565b612109565b348015610bb057600080fd5b506104f1610bbf366004612f91565b61212a565b348015610bd057600080fd5b5061043f610bdf366004612db8565b61214b565b60006001600160a01b038216610c155760405162461bcd60e51b8152600401610c0c9061367a565b60405180910390fd5b506001600160a01b0381166000908152601960205260409020545b919050565b60006001600160e01b031982166380ac58cd60e01b1480610c6657506001600160e01b03198216635b5e139f60e01b145b80610c8157506001600160e01b0319821663780e9d6360e01b145b80610c905750610c908261218f565b92915050565b606060018054610ca590613d0b565b80601f0160208091040260200160405190810160405280929190818152602001828054610cd190613d0b565b8015610d1e5780601f10610cf357610100808354040283529160200191610d1e565b820191906000526020600020905b815481529060010190602001808311610d0157829003601f168201915b5050505050905090565b6000610d33826121a8565b610d4f5760405162461bcd60e51b8152600401610c0c90613b28565b506000908152600560205260409020546001600160a01b031690565b6000610d7682611501565b9050806001600160a01b0316836001600160a01b03161415610daa5760405162461bcd60e51b8152600401610c0c906137f0565b806001600160a01b0316610dbc6121af565b6001600160a01b03161480610dd85750610dd881610ae06121af565b610df45760405162461bcd60e51b8152600401610c0c90613520565b610dff8383836121b3565b505050565b60005490565b600b5490565b610dff83838361220f565b600c5490565b6001600160a01b031660009081526018602052604090205460ff1690565b33610e48611c3c565b6001600160a01b031614610e5b57600080fd5b6011805460ff1916911515919091179055565b6000610e7983611519565b8210610e975760405162461bcd60e51b8152600401610c0c9061320c565b6000610ea1610e04565b905060008060005b83811015610f4a576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b03169183019190915215610efb57805192505b876001600160a01b0316836001600160a01b03161415610f375786841415610f2957509350610c9092505050565b83610f3381613d46565b9450505b5080610f4281613d46565b915050610ea9565b5060405162461bcd60e51b8152600401610c0c90613a1d565b33610f6c611c3c565b6001600160a01b031614610f7f57600080fd5b600b55565b33610f8d611c3c565b6001600160a01b031614610fa057600080fd5b60165447906001600160a01b03166108fc612710610fc084612328613c6a565b610fca9190613c56565b6040518115909202916000818181858888f19350505050158015610ff2573d6000803e3d6000fd5b506017546001600160a01b03166108fc612710611011846103e8613c6a565b61101b9190613c56565b6040518115909202916000818181858888f19350505050158015611043573d6000803e3d6000fd5b5061104c611c3c565b6001600160a01b03166108fc612710611066846000613c6a565b6110709190613c56565b6040518115909202916000818181858888f19350505050158015611098573d6000803e3d6000fd5b5050565b336110a5611c3c565b6001600160a01b0316146110b857600080fd5b60118054911515620100000262ff000019909216919091179055565b600c5481565b6012546110e5610e04565b11156111035760405162461bcd60e51b8152600401610c0c9061342a565b3233146111225760405162461bcd60e51b8152600401610c0c906134e9565b61112a611c3c565b6001600160a01b0316336001600160a01b03161461116957601154610100900460ff166111695760405162461bcd60e51b8152600401610c0c906132bc565b611171611c3c565b6001600160a01b0316826001600160a01b0316146111be576014548161119684611519565b6111a09190613c3e565b11156111be5760405162461bcd60e51b8152600401610c0c906133b0565b601454336000908152601a60205260409020546111dc908390613c3e565b11156111fa5760405162461bcd60e51b8152600401610c0c90613a6b565b60125481611206610e04565b6112109190613c3e565b111561122e5760405162461bcd60e51b8152600401610c0c906137c0565b601254611239610e04565b11156112575760405162461bcd60e51b8152600401610c0c906139b9565b6013548111156112795760405162461bcd60e51b8152600401610c0c90613789565b7f0000000000000000000000000000000000000000000000000000000000002328816112a433611fec565b6112ae9190613c3e565b11156112cc5760405162461bcd60e51b8152600401610c0c90613952565b6011546301000000900460ff16156112f65760405162461bcd60e51b8152600401610c0c90613383565b80600a546113049190613c6a565b3410156113235760405162461bcd60e51b8152600401610c0c906139e6565b336000908152601a602052604081208054839290611342908490613c3e565b9091555061109890508282612521565b610dff83838360405180602001604052806000815250611ecf565b601154640100000000900460ff1681565b6060600061138b83611519565b90506000816001600160401b038111156113b557634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156113de578160200160208202803683370190505b50905060005b82811015611433576113f68582610e6e565b82828151811061141657634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061142b81613d46565b9150506113e4565b509392505050565b6000611445611c3c565b905090565b60125481565b33611459611c3c565b6001600160a01b03161461146c57600080fd5b601355565b600061147b610e04565b82106114995760405162461bcd60e51b8152600401610c0c906133e7565b5090565b336114a6611c3c565b6001600160a01b0316146114b957600080fd5b8051611098906010906020840190612c8e565b336114d5611c3c565b6001600160a01b0316146114e857600080fd5b600f55565b601154610100900460ff1681565b60095490565b600061150c8261253b565b5192915050565b600a5481565b60006001600160a01b0382166115415760405162461bcd60e51b8152600401610c0c9061357d565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b61156e61264d565b611578600061268c565b565b33611583611c3c565b6001600160a01b03161461159657600080fd5b600f54600e5411156115ba5760405162461bcd60e51b8152600401610c0c9061324e565b601254600d546115c8610e04565b6115d29190613c3e565b11156115f05760405162461bcd60e51b8152600401610c0c906137c0565b6012546115fb610e04565b11156116195760405162461bcd60e51b8152600401610c0c906139b9565b600d54600e600082825461162d9190613c3e565b9250508190555061157833600d54612521565b33611649611c3c565b6001600160a01b03161461165c57600080fd5b60005b81811015610dff57600083838381811061168957634e487b7160e01b600052603260045260246000fd5b905060200201602081019061169e9190612db8565b6001600160a01b031614156116c55760405162461bcd60e51b8152600401610c0c9061360e565b6001601860008585858181106116eb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906117009190612db8565b6001600160a01b0316815260208101919091526040016000908120805460ff19169215159290921790915560198185858581811061174e57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906117639190612db8565b6001600160a01b03166001600160a01b0316815260200190815260200160002054116117905760006117eb565b601960008484848181106117b457634e487b7160e01b600052603260045260246000fd5b90506020020160208101906117c99190612db8565b6001600160a01b03166001600160a01b03168152602001908152602001600020545b50806117f681613d46565b91505061165f565b33611807611c3c565b6001600160a01b03161461181a57600080fd5b601255565b33611828611c3c565b6001600160a01b03161461183b57600080fd5b60125481611847610e04565b6118519190613c3e565b111561186f5760405162461bcd60e51b8152600401610c0c906137c0565b60125461187a610e04565b11156118985760405162461bcd60e51b8152600401610c0c906139b9565b6110988282612521565b6012546118ad610e04565b11156118cb5760405162461bcd60e51b8152600401610c0c9061342a565b60115462010000900460ff166118f35760405162461bcd60e51b8152600401610c0c90613982565b3360009081526018602052604090205460ff166119225760405162461bcd60e51b8152600401610c0c90613285565b60125461192d610e04565b1061194a5760405162461bcd60e51b8152600401610c0c90613af1565b60155481111561196c5760405162461bcd60e51b8152600401610c0c90613bb7565b6015543360009081526019602052604090205461198a908390613c3e565b11156119a85760405162461bcd60e51b8152600401610c0c90613a6b565b80600b546119b69190613c6a565b3410156119d55760405162461bcd60e51b8152600401610c0c906139e6565b6011546301000000900460ff16156119ff5760405162461bcd60e51b8152600401610c0c90613383565b3360009081526019602052604081208054839290611a1e908490613c3e565b90915550611a2e90503382612521565b50565b601254611a3c610e04565b1115611a5a5760405162461bcd60e51b8152600401610c0c9061342a565b600033604051602001611a6d9190613104565b60408051601f19818403018152919052805160209091012060115490915060ff16611aaa5760405162461bcd60e51b8152600401610c0c90613832565b600954611ab9908390836126de565b611ad55760405162461bcd60e51b8152600401610c0c906138ea565b601254611ae0610e04565b10611afd5760405162461bcd60e51b8152600401610c0c90613af1565b601554831115611b1f5760405162461bcd60e51b8152600401610c0c90613bb7565b60155433600090815260196020526040902054611b3d908590613c3e565b1115611b5b5760405162461bcd60e51b8152600401610c0c90613a6b565b82600c54611b699190613c6a565b341015611b885760405162461bcd60e51b8152600401610c0c906139e6565b6011546301000000900460ff1615611bb25760405162461bcd60e51b8152600401610c0c90613383565b3360009081526019602052604081208054859290611bd1908490613c3e565b90915550610dff90503384612521565b33611bea611c3c565b6001600160a01b031614611bfd57600080fd5b601555565b6011546301000000900460ff1681565b60155481565b7f000000000000000000000000000000000000000000000000000000000000232881565b6008546001600160a01b031690565b33611c54611c3c565b6001600160a01b031614611c6757600080fd5b6011805463ff00000019166301000000179055565b606060028054610ca590613d0b565b33611c94611c3c565b6001600160a01b031614611ca757600080fd5b601180549115156401000000000264ff0000000019909216919091179055565b60135481565b60115462010000900460ff1681565b611ce46121af565b6001600160a01b0316826001600160a01b03161415611d155760405162461bcd60e51b8152600401610c0c90613700565b8060066000611d226121af565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155611d666121af565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611d9e91906131e5565b60405180910390a35050565b33611db3611c3c565b6001600160a01b031614611dc657600080fd5b60005b81811015610dff576000838383818110611df357634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611e089190612db8565b6001600160a01b03161415611e2f5760405162461bcd60e51b8152600401610c0c9061360e565b600060186000858585818110611e5557634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611e6a9190612db8565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580611e9c81613d46565b915050611dc9565b600a5490565b600033611eb5611c3c565b6001600160a01b031614611ec857600080fd5b5060135490565b611eda84848461220f565b611ee6848484846126f4565b611f025760405162461bcd60e51b8152600401610c0c90613860565b50505050565b60115460ff1681565b33611f1a611c3c565b6001600160a01b031614611f2d57600080fd5b600c55565b6000611445610e04565b6060611f47826121a8565b611f635760405162461bcd60e51b8152600401610c0c906136b1565b6000611f6d612810565b90506000815111611f8d5760405180602001604052806000815250611fb8565b80611f978461281f565b604051602001611fa8929190613121565b6040516020818303038152906040525b9392505050565b60145481565b60075481565b33611fd4611c3c565b6001600160a01b031614611fe757600080fd5b600955565b6000610c9082612939565b600d5490565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b33612034611c3c565b6001600160a01b03161461204757600080fd5b601455565b60095481565b600b5481565b33612061611c3c565b6001600160a01b03161461207457600080fd5b6011805461ff001916610100831515021790556040517f58655b75d3df612fe99ead00dbf0812d415d35078fe06217a94c0818bb13967f906120b79083906131e5565b60405180910390a150565b6011546301000000900460ff1690565b6120da61264d565b6001600160a01b0381166121005760405162461bcd60e51b8152600401610c0c906132f3565b611a2e8161268c565b33612112611c3c565b6001600160a01b03161461212557600080fd5b600a55565b33612133611c3c565b6001600160a01b03161461214657600080fd5b600d55565b60006001600160a01b0382166121735760405162461bcd60e51b8152600401610c0c9061367a565b506001600160a01b03166000908152601a602052604090205490565b6001600160e01b031981166301ffc9a760e01b14919050565b6000541190565b3390565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600061221a8261253b565b9050600081600001516001600160a01b03166122346121af565b6001600160a01b03161480612269575061224c6121af565b6001600160a01b031661225e84610d28565b6001600160a01b0316145b8061227d5750815161227d90610ae06121af565b90508061229c5760405162461bcd60e51b8152600401610c0c90613737565b846001600160a01b031682600001516001600160a01b0316146122d15760405162461bcd60e51b8152600401610c0c906135c8565b6001600160a01b0384166122f75760405162461bcd60e51b8152600401610c0c90613453565b6123048585856001611f02565b61231460008484600001516121b3565b6001600160a01b03851660009081526004602052604081208054600192906123469084906001600160801b0316613c89565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b0386166000908152600460205260408120805460019450909261239291859116613c1c565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b0380871682526001600160401b03428116602080850191825260008981526003909152948520935184549151909216600160a01b0267ffffffffffffffff60a01b19929093166001600160a01b03199091161716179055612427846001613c3e565b6000818152600360205260409020549091506001600160a01b03166124cb5761244f816121a8565b156124cb5760408051808201825284516001600160a01b0390811682526020808701516001600160401b0390811682850190815260008781526003909352949091209251835494516001600160a01b031990951692169190911767ffffffffffffffff60a01b1916600160a01b93909116929092029190911790555b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46125198686866001611f02565b505050505050565b61109882826040518060200160405280600081525061298d565b612543612d0e565b61254c826121a8565b6125685760405162461bcd60e51b8152600401610c0c90613339565b60007f000000000000000000000000000000000000000000000000000000000000232883106125c9576125bb7f000000000000000000000000000000000000000000000000000000000000232884613cb1565b6125c6906001613c3e565b90505b825b818110612634576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b03169183019190915215612621579250610c30915050565b508061262c81613cf4565b9150506125cb565b5060405162461bcd60e51b8152600401610c0c90613aa2565b6126556121af565b6001600160a01b0316612666611c3c565b6001600160a01b0316146115785760405162461bcd60e51b8152600401610c0c90613645565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000826126eb8584612bff565b14949350505050565b6000612708846001600160a01b0316612c52565b1561280457836001600160a01b031663150b7a026127246121af565b8786866040518563ffffffff1660e01b81526004016127469493929190613164565b602060405180830381600087803b15801561276057600080fd5b505af1925050508015612790575060408051601f3d908101601f1916820190925261278d91810190612fc5565b60015b6127ea573d8080156127be576040519150601f19603f3d011682016040523d82523d6000602084013e6127c3565b606091505b5080516127e25760405162461bcd60e51b8152600401610c0c90613860565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612808565b5060015b949350505050565b606060108054610ca590613d0b565b60608161284457506040805180820190915260018152600360fc1b6020820152610c30565b8160005b811561286e578061285881613d46565b91506128679050600a83613c56565b9150612848565b6000816001600160401b0381111561289657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156128c0576020820181803683370190505b5090505b8415612808576128d5600183613cb1565b91506128e2600a86613d61565b6128ed906030613c3e565b60f81b81838151811061291057634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612932600a86613c56565b94506128c4565b60006001600160a01b0382166129615760405162461bcd60e51b8152600401610c0c90613498565b506001600160a01b0316600090815260046020526040902054600160801b90046001600160801b031690565b6000546001600160a01b0384166129b65760405162461bcd60e51b8152600401610c0c90613911565b6129bf816121a8565b156129dc5760405162461bcd60e51b8152600401610c0c906138b3565b7f0000000000000000000000000000000000000000000000000000000000002328831115612a1c5760405162461bcd60e51b8152600401610c0c90613b75565b612a296000858386611f02565b6001600160a01b0384166000908152600460209081526040918290208251808401845290546001600160801b038082168352600160801b9091041691810191909152815180830190925280519091908190612a85908790613c1c565b6001600160801b03168152602001858360200151612aa39190613c1c565b6001600160801b039081169091526001600160a01b03808816600081815260046020908152604080832087518154988401518816600160801b029088166fffffffffffffffffffffffffffffffff199099169890981790961696909617909455845180860186529182526001600160401b034281168386019081528883526003909552948120915182549451909516600160a01b0267ffffffffffffffff60a01b19959093166001600160a01b031990941693909317939093161790915582905b85811015612bed5760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4612bb160008884886126f4565b612bcd5760405162461bcd60e51b8152600401610c0c90613860565b81612bd781613d46565b9250508080612be590613d46565b915050612b64565b50600081815561251990878588611f02565b600081815b845181101561143357612c3e82868381518110612c3157634e487b7160e01b600052603260045260246000fd5b6020026020010151612c61565b915080612c4a81613d46565b915050612c04565b6001600160a01b03163b151590565b6000818310612c7957612c748284612c7f565b611fb8565b611fb883835b60009182526020526040902090565b828054612c9a90613d0b565b90600052602060002090601f016020900481019282612cbc5760008555612d02565b82601f10612cd557805160ff1916838001178555612d02565b82800160010185558215612d02579182015b82811115612d02578251825591602001919060010190612ce7565b50611499929150612d25565b604080518082019091526000808252602082015290565b5b808211156114995760008155600101612d26565b60006001600160401b03831115612d5357612d53613da1565b612d66601f8401601f1916602001613bec565b9050828152838383011115612d7a57600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b0381168114610c3057600080fd5b80358015158114610c3057600080fd5b600060208284031215612dc9578081fd5b611fb882612d91565b60008060408385031215612de4578081fd5b612ded83612d91565b9150612dfb60208401612d91565b90509250929050565b600080600060608486031215612e18578081fd5b612e2184612d91565b9250612e2f60208501612d91565b9150604084013590509250925092565b60008060008060808587031215612e54578081fd5b612e5d85612d91565b9350612e6b60208601612d91565b92506040850135915060608501356001600160401b03811115612e8c578182fd5b8501601f81018713612e9c578182fd5b612eab87823560208401612d3a565b91505092959194509250565b60008060408385031215612ec9578182fd5b612ed283612d91565b9150612dfb60208401612da8565b60008060408385031215612ef2578182fd5b612efb83612d91565b946020939093013593505050565b60008060208385031215612f1b578182fd5b82356001600160401b0380821115612f31578384fd5b818501915085601f830112612f44578384fd5b813581811115612f52578485fd5b8660208083028501011115612f65578485fd5b60209290920196919550909350505050565b600060208284031215612f88578081fd5b611fb882612da8565b600060208284031215612fa2578081fd5b5035919050565b600060208284031215612fba578081fd5b8135611fb881613db7565b600060208284031215612fd6578081fd5b8151611fb881613db7565b600060208284031215612ff2578081fd5b81356001600160401b03811115613007578182fd5b8201601f81018413613017578182fd5b61280884823560208401612d3a565b60008060408385031215613038578182fd5b823591506020808401356001600160401b0380821115613056578384fd5b818601915086601f830112613069578384fd5b81358181111561307b5761307b613da1565b838102915061308b848301613bec565b8181528481019084860184860187018b10156130a5578788fd5b8795505b838610156130c75780358352600195909501949186019186016130a9565b508096505050505050509250929050565b600081518084526130f0816020860160208601613cc8565b601f01601f19169290920160200192915050565b60609190911b6bffffffffffffffffffffffff1916815260140190565b60008351613133818460208801613cc8565b835190830190613147818360208801613cc8565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613197908301846130d8565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156131d9578351835292840192918401916001016131bd565b50909695505050505050565b901515815260200190565b90815260200190565b600060208252611fb860208301846130d8565b60208082526022908201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252601b908201527f4d61782052657365727665732074616b656e20616c7265616479210000000000604082015260600190565b6020808252601d908201527f596f7520617265206e6f74206f6e2074686520416c6c6f77204c697374000000604082015260600190565b6020808252601d908201527f53616c65206973206e6f74206163746976652063757272656e746c792e000000604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252602a908201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736040820152693a32b73a103a37b5b2b760b11b606082015260800190565b60208082526013908201527226b4b73a1021b637b9b2b2102337b932bb32b960691b604082015260600190565b60208082526018908201527f4d617820686f6c64696e672063617020726561636865642e0000000000000000604082015260600190565b60208082526023908201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756040820152626e647360e81b606082015260800190565b6020808252600f908201526e29b0b632903430b99032b73232b21760891b604082015260600190565b60208082526025908201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526031908201527f455243373231413a206e756d626572206d696e74656420717565727920666f7260408201527020746865207a65726f206164647265737360781b606082015260800190565b6020808252601e908201527f5468652063616c6c657220697320616e6f7468657220636f6e74726163740000604082015260600190565b60208082526039908201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60408201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000606082015260800190565b6020808252602b908201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60408201526a65726f206164647265737360a81b606082015260800190565b60208082526026908201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746040820152651037bbb732b960d11b606082015260800190565b60208082526018908201527f43616e2774206164642061206e756c6c20616464726573730000000000000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601e908201527f5a65726f2061646472657373206e6f74206f6e20416c6c6f77204c6973740000604082015260600190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b6020808252601a908201527f455243373231413a20617070726f766520746f2063616c6c6572000000000000604082015260600190565b60208082526032908201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206040820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b606082015260800190565b6020808252601e908201527f45786365656473206d6178696d756d20616c6c6f77656420746f6b656e730000604082015260600190565b6020808252601690820152752a37ba30b61039bab838363c9032bc31b2b2b232b21760511b604082015260600190565b60208082526022908201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60408201526132b960f11b606082015260800190565b602080825260149082015273526166666c65206973206e6f742061637469766560601b604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b6020808252601d908201527f455243373231413a20746f6b656e20616c7265616479206d696e746564000000604082015260600190565b6020808252600d908201526c34b73b30b634b210383937b7b360991b604082015260600190565b60208082526021908201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526016908201527563616e206e6f74206d696e742074686973206d616e7960501b604082015260600190565b6020808252601b908201527f5072652053616c65204d696e74206973206e6f74206163746976650000000000604082015260600190565b6020808252601390820152722a37ba30b61039bab838363c9039b832b73a1760691b604082015260600190565b6020808252601b908201527f496e7375666669656e742045544820616d6f756e742073656e742e0000000000604082015260600190565b6020808252602e908201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060408201526d0deeedccae440c4f240d2dcc8caf60931b606082015260800190565b6020808252601c908201527f50757263686173652065786365656473206d617820616c6c6f77656400000000604082015260600190565b6020808252602f908201527f455243373231413a20756e61626c6520746f2064657465726d696e652074686560408201526e1037bbb732b91037b3103a37b5b2b760891b606082015260800190565b6020808252601b908201527f416c6c20746f6b656e732068617665206265656e206d696e7465640000000000604082015260600190565b6020808252602d908201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560408201526c3c34b9ba32b73a103a37b5b2b760991b606082015260800190565b60208082526022908201527f455243373231413a207175616e7469747920746f206d696e7420746f6f2068696040820152610ced60f31b606082015260800190565b6020808252818101527f43616e6e6f742070757263686173652074686973206d616e7920746f6b656e73604082015260600190565b604051601f8201601f191681016001600160401b0381118282101715613c1457613c14613da1565b604052919050565b60006001600160801b0380831681851680830382111561314757613147613d75565b60008219821115613c5157613c51613d75565b500190565b600082613c6557613c65613d8b565b500490565b6000816000190483118215151615613c8457613c84613d75565b500290565b60006001600160801b0383811690831681811015613ca957613ca9613d75565b039392505050565b600082821015613cc357613cc3613d75565b500390565b60005b83811015613ce3578181015183820152602001613ccb565b83811115611f025750506000910152565b600081613d0357613d03613d75565b506000190190565b600281046001821680613d1f57607f821691505b60208210811415613d4057634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613d5a57613d5a613d75565b5060010190565b600082613d7057613d70613d8b565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114611a2e57600080fdfea2646970667358221220a108ef957841b1d0a0befc157c65c3724e4cbd0f7517ecb0f20aa91f9a91453364736f6c63430008010033

Verified Source Code Partial Match

Compiler: v0.8.1+commit.df193b15 EVM: istanbul Optimization: Yes (200 runs)
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;
    }
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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
                /// @solidity memory-safe-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;
    }
}
ERC721A.sol 557 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./IERC721Metadata.sol";
import "./IERC721Enumerable.sol";
import "./Address.sol";
import "./Context.sol";
import "./Strings.sol";
import "./ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints.
 *
 * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..).
 *
 * Assumes the number of issuable tokens (collection size) is capped and fits in a uint128.
 *
 * Does not support burning tokens to address(0).
 */
contract ERC721A is
  Context,
  ERC165,
  IERC721,
  IERC721Metadata,
  IERC721Enumerable
{
  using Address for address;
  using Strings for uint256;

  struct TokenOwnership {
    address addr;
    uint64 startTimestamp;
  }

  struct AddressData {
    uint128 balance;
    uint128 numberMinted;
  }

  uint256 private currentIndex = 0;

  uint256 internal immutable collectionSize;
  uint256 internal immutable maxBatchSize;

  // 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) private _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;

  /**
   * @dev
   * `maxBatchSize` refers to how much a minter can mint at a time.
   * `collectionSize_` refers to how many tokens are in the collection.
   */
  constructor(
    string memory name_,
    string memory symbol_,
    uint256 maxBatchSize_,
    uint256 collectionSize_
  ) {
    require(
      collectionSize_ > 0,
      "ERC721A: collection must have a nonzero supply"
    );
    require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero");
    _name = name_;
    _symbol = symbol_;
    maxBatchSize = maxBatchSize_;
    collectionSize = collectionSize_;
  }

  /**
   * @dev See {IERC721Enumerable-totalSupply}.
   */
  function totalSupply() public view override returns (uint256) {
    return currentIndex;
  }

  /**
   * @dev See {IERC721Enumerable-tokenByIndex}.
   */
  function tokenByIndex(uint256 index) public view override returns (uint256) {
    require(index < totalSupply(), "ERC721A: global index out of bounds");
    return index;
  }

  /**
   * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
   * This read function is O(collectionSize). If calling from a separate contract, be sure to test gas first.
   * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
   */
  function tokenOfOwnerByIndex(address owner, uint256 index)
    public
    view
    override
    returns (uint256)
  {
    require(index < balanceOf(owner), "ERC721A: owner index out of bounds");
    uint256 numMintedSoFar = totalSupply();
    uint256 tokenIdsIdx = 0;
    address currOwnershipAddr = address(0);
    for (uint256 i = 0; i < numMintedSoFar; i++) {
      TokenOwnership memory ownership = _ownerships[i];
      if (ownership.addr != address(0)) {
        currOwnershipAddr = ownership.addr;
      }
      if (currOwnershipAddr == owner) {
        if (tokenIdsIdx == index) {
          return i;
        }
        tokenIdsIdx++;
      }
    }
    revert("ERC721A: unable to get token of owner by index");
  }

  /**
   * @dev See {IERC165-supportsInterface}.
   */
  function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC165, IERC165)
    returns (bool)
  {
    return
      interfaceId == type(IERC721).interfaceId ||
      interfaceId == type(IERC721Metadata).interfaceId ||
      interfaceId == type(IERC721Enumerable).interfaceId ||
      super.supportsInterface(interfaceId);
  }

  /**
   * @dev See {IERC721-balanceOf}.
   */
  function balanceOf(address owner) public view override returns (uint256) {
    require(owner != address(0), "ERC721A: balance query for the zero address");
    return uint256(_addressData[owner].balance);
  }

  function _numberMinted(address owner) internal view returns (uint256) {
    require(
      owner != address(0),
      "ERC721A: number minted query for the zero address"
    );
    return uint256(_addressData[owner].numberMinted);
  }

  function ownershipOf(uint256 tokenId)
    internal
    view
    returns (TokenOwnership memory)
  {
    require(_exists(tokenId), "ERC721A: owner query for nonexistent token");

    uint256 lowestTokenToCheck;
    if (tokenId >= maxBatchSize) {
      lowestTokenToCheck = tokenId - maxBatchSize + 1;
    }

    for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) {
      TokenOwnership memory ownership = _ownerships[curr];
      if (ownership.addr != address(0)) {
        return ownership;
      }
    }

    revert("ERC721A: unable to determine the owner of token");
  }

  /**
   * @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)
  {
    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 override {
    address owner = ERC721A.ownerOf(tokenId);
    require(to != owner, "ERC721A: approval to current owner");

    require(
      _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
      "ERC721A: approve caller is not owner nor approved for all"
    );

    _approve(to, tokenId, owner);
  }

  /**
   * @dev See {IERC721-getApproved}.
   */
  function getApproved(uint256 tokenId) public view override returns (address) {
    require(_exists(tokenId), "ERC721A: approved query for nonexistent token");

    return _tokenApprovals[tokenId];
  }

  /**
   * @dev See {IERC721-setApprovalForAll}.
   */
  function setApprovalForAll(address operator, bool approved) public override {
    require(operator != _msgSender(), "ERC721A: approve to caller");

    _operatorApprovals[_msgSender()][operator] = approved;
    emit ApprovalForAll(_msgSender(), operator, approved);
  }

  /**
   * @dev See {IERC721-isApprovedForAll}.
   */
  function isApprovedForAll(address owner, address operator)
    public
    view
    virtual
    override
    returns (bool)
  {
    return _operatorApprovals[owner][operator];
  }

  /**
   * @dev See {IERC721-transferFrom}.
   */
  function transferFrom(
    address from,
    address to,
    uint256 tokenId
  ) public override {
    _transfer(from, to, tokenId);
  }

  /**
   * @dev See {IERC721-safeTransferFrom}.
   */
  function safeTransferFrom(
    address from,
    address to,
    uint256 tokenId
  ) public override {
    safeTransferFrom(from, to, tokenId, "");
  }

  /**
   * @dev See {IERC721-safeTransferFrom}.
   */
  function safeTransferFrom(
    address from,
    address to,
    uint256 tokenId,
    bytes memory _data
  ) public override {
    _transfer(from, to, tokenId);
    require(
      _checkOnERC721Received(from, to, tokenId, _data),
      "ERC721A: transfer to non ERC721Receiver implementer"
    );
  }

  /**
   * @dev Returns whether `tokenId` exists.
   *
   * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
   *
   * Tokens start existing when they are minted (`_mint`),
   */
  function _exists(uint256 tokenId) internal view returns (bool) {
    return tokenId < currentIndex;
  }

  function _safeMint(address to, uint256 quantity) internal {
    _safeMint(to, quantity, "");
  }

  /**
   * @dev Mints `quantity` tokens and transfers them to `to`.
   *
   * Requirements:
   *
   * - there must be `quantity` tokens remaining unminted in the total collection.
   * - `to` cannot be the zero address.
   * - `quantity` cannot be larger than the max batch size.
   *
   * Emits a {Transfer} event.
   */
  function _safeMint(
    address to,
    uint256 quantity,
    bytes memory _data
  ) internal {
    uint256 startTokenId = currentIndex;
    require(to != address(0), "ERC721A: mint to the zero address");
    // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
    require(!_exists(startTokenId), "ERC721A: token already minted");
    require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high");

    _beforeTokenTransfers(address(0), to, startTokenId, quantity);

    AddressData memory addressData = _addressData[to];
    _addressData[to] = AddressData(
      addressData.balance + uint128(quantity),
      addressData.numberMinted + uint128(quantity)
    );
    _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp));

    uint256 updatedIndex = startTokenId;

    for (uint256 i = 0; i < quantity; i++) {
      emit Transfer(address(0), to, updatedIndex);
      require(
        _checkOnERC721Received(address(0), to, updatedIndex, _data),
        "ERC721A: transfer to non ERC721Receiver implementer"
      );
      updatedIndex++;
    }

    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);

    bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
      getApproved(tokenId) == _msgSender() ||
      isApprovedForAll(prevOwnership.addr, _msgSender()));

    require(
      isApprovedOrOwner,
      "ERC721A: transfer caller is not owner nor approved"
    );

    require(
      prevOwnership.addr == from,
      "ERC721A: transfer from incorrect owner"
    );
    require(to != address(0), "ERC721A: transfer to the zero address");

    _beforeTokenTransfers(from, to, tokenId, 1);

    // Clear approvals from the previous owner
    _approve(address(0), tokenId, prevOwnership.addr);

    _addressData[from].balance -= 1;
    _addressData[to].balance += 1;
    _ownerships[tokenId] = TokenOwnership(to, 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;
    if (_ownerships[nextTokenId].addr == address(0)) {
      if (_exists(nextTokenId)) {
        _ownerships[nextTokenId] = TokenOwnership(
          prevOwnership.addr,
          prevOwnership.startTimestamp
        );
      }
    }

    emit Transfer(from, to, tokenId);
    _afterTokenTransfers(from, to, tokenId, 1);
  }

  /**
   * @dev Approve `to` to operate on `tokenId`
   *
   * Emits a {Approval} event.
   */
  function _approve(
    address to,
    uint256 tokenId,
    address owner
  ) private {
    _tokenApprovals[tokenId] = to;
    emit Approval(owner, to, tokenId);
  }

  uint256 public nextOwnerToExplicitlySet = 0;

  /**
   * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf().
   */
  function _setOwnersExplicit(uint256 quantity) internal {
    uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet;
    require(quantity > 0, "quantity must be nonzero");
    uint256 endIndex = oldNextOwnerToSet + quantity - 1;
    if (endIndex > collectionSize - 1) {
      endIndex = collectionSize - 1;
    }
    // We know if the last one in the group exists, all in the group exist, due to serial ordering.
    require(_exists(endIndex), "not enough minted yet for this cleanup");
    for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) {
      if (_ownerships[i].addr == address(0)) {
        TokenOwnership memory ownership = ownershipOf(i);
        _ownerships[i] = TokenOwnership(
          ownership.addr,
          ownership.startTimestamp
        );
      }
    }
    nextOwnerToExplicitlySet = endIndex + 1;
  }

  /**
   * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
   * The call is not executed if the target address is not a contract.
   *
   * @param from address representing the previous owner of the given token ID
   * @param to target address that will receive the tokens
   * @param tokenId uint256 ID of the token to be transferred
   * @param _data bytes optional data to send along with the call
   * @return bool whether the call correctly returned the expected magic value
   */
  function _checkOnERC721Received(
    address from,
    address to,
    uint256 tokenId,
    bytes memory _data
  ) private returns (bool) {
    if (to.isContract()) {
      try
        IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data)
      returns (bytes4 retval) {
        return retval == IERC721Receiver(to).onERC721Received.selector;
      } catch (bytes memory reason) {
        if (reason.length == 0) {
          revert("ERC721A: transfer to non ERC721Receiver implementer");
        } else {
          assembly {
            revert(add(32, reason), mload(reason))
          }
        }
      }
    } else {
      return true;
    }
  }

  /**
   * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
   *
   * startTokenId - the first token id to be transferred
   * quantity - the amount to be transferred
   *
   * Calling conditions:
   *
   * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
   * transferred to `to`.
   * - When `from` is zero, `tokenId` will be minted for `to`.
   */
  function _beforeTokenTransfers(
    address from,
    address to,
    uint256 startTokenId,
    uint256 quantity
  ) internal virtual {}

  /**
   * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
   * minting.
   *
   * startTokenId - the first token id to be transferred
   * quantity - the amount to be transferred
   *
   * Calling conditions:
   *
   * - when `from` and `to` are both non-zero.
   * - `from` and `to` are never both zero.
   */
  function _afterTokenTransfers(
    address from,
    address to,
    uint256 startTokenId,
    uint256 quantity
  ) internal virtual {}
}
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);
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "./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`.
     *
     * 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;

    /**
     * @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 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 Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "./Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
Strings.sol 75 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}
MerkleProof.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Tree 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.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the merkle tree could be reinterpreted as a leaf value.
 */
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 Calldata version of {verify}
     *
     * _Available since v4.7._
     */
    function verifyCalldata(
        bytes32[] calldata proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle 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++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     *
     * _Available since v4.7._
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be proved to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * _Available since v4.7._
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * _Available since v4.7._
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and the sibling nodes in `proof`,
     * consuming from one or the other at each step according to the instructions given by
     * `proofFlags`.
     *
     * _Available since v4.7._
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}
     *
     * _Available since v4.7._
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        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);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (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 `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "./IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}
BucketsClubFrontNine.sol 298 lines
// SPDX-License-Identifier: MIT
// Made by: NFT Stack
//          https://nftstack.info
//

pragma solidity ^0.8.1;

import "./Ownable.sol";
import "./MerkleProof.sol";
import "./ERC721A.sol";

contract BucketsClubFrontNine is ERC721A, Ownable {
  using MerkleProof for bytes32[];

  bytes32 public root;

  uint256 public mintPrice = 0.4 ether;
  uint256 public preSaleMintPrice =  0.1 ether;
  uint256 public raffleMintPrice = 0.1 ether;

  uint256 private reserveAtATime = 50;
  uint256 private reservedCount = 0;
  uint256 private maxReserveCount = 300;

  string _baseTokenURI;

  bool public isRaffleActive = false;
  bool public isMintActive = false;
  bool public isPreSaleMintActive = false;
  bool public isClosedMintForever = false;
  bool public isSellOpen = false;

  uint256 public maximumMintSupply = 9000;
  uint256 public maximumAllowedTokensPerPurchase = 10;
  uint256 public maximumAllowedTokensPerWallet = 10;
  uint256 public allowListMaxMint = 10;
  uint256 public immutable maxPerAddressDuringMint;

  address private OtherAddress1 = 0x053490B1e960AeeB1aCB2bf10d53BE7d264f35Af;
  address private OtherAddress2 = 0xAFc1229EA5fBBD814CECb0A4d402FA6450762467;

  mapping(address => bool) private _allowList;
  mapping(address => uint256) private _allowListClaimed;
  mapping(address => uint256) private _publicMintClaimed;

  event AssetMinted(uint256 tokenId, address sender);
  event SaleActivation(bool isMintActive);

  constructor(
    string memory baseURI,
    uint256 maxBatchSize_,
    uint256 collectionSize_
  ) ERC721A("Buckets Club Front Nine", "Buckets Club Front Nine", maxBatchSize_, collectionSize_) {
    setBaseURI(baseURI);
    maxPerAddressDuringMint = maxBatchSize_;
  }

  modifier saleIsOpen {
    require(totalSupply() <= maximumMintSupply, "Sale has ended.");
    _;
  }

  modifier onlyAuthorized() {
    require(owner() == msg.sender);
    _;
  }

  modifier callerIsUser() {
    require(tx.origin == msg.sender, "The caller is another contract");
    _;
  }

  function setMaximumAllowedTokens(uint256 _count) public onlyAuthorized {
    maximumAllowedTokensPerPurchase = _count;
  }

  function setMaximumAllowedTokensPerWallet(uint256 _count) public onlyAuthorized {
    maximumAllowedTokensPerWallet = _count;
  }

  function setMintActive(bool val) public onlyAuthorized {
    isMintActive = val;
    emit SaleActivation(val);
  }

  function setMaxMintSupply(uint256 maxMintSupply) external  onlyAuthorized {
    maximumMintSupply = maxMintSupply;
  }

  function setRaffleActive(bool _isRaffleActive) public onlyAuthorized {
    isRaffleActive = _isRaffleActive;
  }

  function setIsPreSaleMintActive(bool _isPreSaleMintActive) external onlyAuthorized {
    isPreSaleMintActive = _isPreSaleMintActive;
  }

  function setIsSellOpen(bool _isSellOpen) external onlyAuthorized {
    isSellOpen = _isSellOpen;
  }

  function setAllowListMaxMint(uint256 maxMint) external  onlyAuthorized {
    allowListMaxMint = maxMint;
  }

  function addToAllowList(address[] calldata addresses) external onlyAuthorized {
    for (uint256 i = 0; i < addresses.length; i++) {
      require(addresses[i] != address(0), "Can't add a null address");
      _allowList[addresses[i]] = true;
      _allowListClaimed[addresses[i]] > 0 ? _allowListClaimed[addresses[i]] : 0;
    }
  }

  function checkIfOnAllowList(address addr) external view returns (bool) {
    return _allowList[addr];
  }

  function removeFromAllowList(address[] calldata addresses) external onlyAuthorized {
    for (uint256 i = 0; i < addresses.length; i++) {
      require(addresses[i] != address(0), "Can't add a null address");
      _allowList[addresses[i]] = false;
    }
  }

  function allowListClaimedBy(address owner) external view returns (uint256){
    require(owner != address(0), 'Zero address not on Allow List');
    return _allowListClaimed[owner];
  }

  function publicMintClaimed(address owner) external view returns (uint256){
    require(owner != address(0), 'Zero address not on Allow List');
    return _publicMintClaimed[owner];
  }

  function setReserveAtATime(uint256 val) public onlyAuthorized {
    reserveAtATime = val;
  }

  function setMaxReserve(uint256 val) public onlyAuthorized {
    maxReserveCount = val;
  }

  function setMintPrice(uint256 _price) public onlyAuthorized {
    mintPrice = _price;
  }

  function setPreSaleMintPrice(uint256 _price) public onlyAuthorized {
    preSaleMintPrice = _price;
  }

  function setRaffleMintPrice(uint256 _price) public onlyAuthorized {
    raffleMintPrice = _price;
  }

  function setBaseURI(string memory baseURI) public onlyAuthorized {
    _baseTokenURI = baseURI;
  }

  function getMaximumAllowedTokens() public view onlyAuthorized returns (uint256) {
    return maximumAllowedTokensPerPurchase;
  }

  function getMintPrice() external view returns (uint256) {
    return mintPrice;
  }

  function getPreSaleMintPrice() external view returns (uint256) {
    return preSaleMintPrice;
  }

  function getRaffleMintPrice() external view returns (uint256) {
    return raffleMintPrice;
  }

  function getIsClosedMintForever() external view returns (bool) {
    return isClosedMintForever;
  }

  function setIsClosedMintForever() external onlyAuthorized {
    isClosedMintForever = true;
  }

  function setRoot(bytes32 _root) public onlyAuthorized {
    root = _root;
  }

  function getReserveAtATime() external view returns (uint256) {
    return reserveAtATime;
  }

  function getTotalSupply() external view returns (uint256) {
    return totalSupply();
  }

  function getRoot() external view returns (bytes32) {
    return root;
  }

  function getContractOwner() public view returns (address) {
    return owner();
  }

  function _baseURI() internal view virtual override returns (string memory) {
    return _baseTokenURI;
  }

  function reserveNft() public onlyAuthorized {
    require(reservedCount <= maxReserveCount, "Max Reserves taken already!");
    require(totalSupply() + reserveAtATime <= maximumMintSupply, "Total supply exceeded.");
    require(totalSupply() <= maximumMintSupply, "Total supply spent.");

    reservedCount += reserveAtATime;
    _safeMint(msg.sender, reserveAtATime);
  }

  function reserveToCustomWallet(address _walletAddress, uint256 _count) public onlyAuthorized {
    require(totalSupply() + _count <= maximumMintSupply, "Total supply exceeded.");
    require(totalSupply() <= maximumMintSupply, "Total supply spent.");

    _safeMint(_walletAddress, _count);
  }

  function mint(address _to, uint256 _count) public payable saleIsOpen callerIsUser {
    if (msg.sender != owner()) {
      require(isMintActive, "Sale is not active currently.");
    }

    if(_to != owner()) {
      require(balanceOf(_to) + _count <= maximumAllowedTokensPerWallet, "Max holding cap reached.");
    }

    require(_publicMintClaimed[msg.sender] + _count <= maximumAllowedTokensPerWallet, "Purchase exceeds max allowed");
    require(totalSupply() + _count <= maximumMintSupply, "Total supply exceeded.");
    require(totalSupply() <= maximumMintSupply, "Total supply spent.");
    require(
      _count <= maximumAllowedTokensPerPurchase,
      "Exceeds maximum allowed tokens"
    );
    require(
      numberMinted(msg.sender) + _count <= maxPerAddressDuringMint,
      "can not mint this many"
    );
    require(!isClosedMintForever, "Mint Closed Forever");
    require(msg.value >= mintPrice * _count, "Insuffient ETH amount sent.");

    _publicMintClaimed[msg.sender] += _count;
    _safeMint(_to, _count);
  }

  function raffleMint(uint256 _count, bytes32[] memory _proof) public payable saleIsOpen {
    bytes32 leaf = keccak256(abi.encodePacked(msg.sender));

    require(isRaffleActive, "Raffle is not active");
    require(_proof.verify(root, leaf), "invalid proof");
    require(totalSupply() < maximumMintSupply, "All tokens have been minted");
    require(_count <= allowListMaxMint, "Cannot purchase this many tokens");
    require(_allowListClaimed[msg.sender] + _count <= allowListMaxMint, "Purchase exceeds max allowed");
    require(msg.value >= raffleMintPrice * _count, "Insuffient ETH amount sent.");
    require(!isClosedMintForever, "Mint Closed Forever");
    _allowListClaimed[msg.sender] += _count;

    _safeMint(msg.sender, _count);
  }

  function preSaleMint(uint256 _count) public payable saleIsOpen {
    require(isPreSaleMintActive, 'Pre Sale Mint is not active');
    require(_allowList[msg.sender], 'You are not on the Allow List');
    require(totalSupply() < maximumMintSupply, 'All tokens have been minted');
    require(_count <= allowListMaxMint, 'Cannot purchase this many tokens');
    require(_allowListClaimed[msg.sender] + _count <= allowListMaxMint, 'Purchase exceeds max allowed');
    require(msg.value >= preSaleMintPrice * _count, 'Insuffient ETH amount sent.');
    require(!isClosedMintForever, 'Mint Closed Forever');
    _allowListClaimed[msg.sender] += _count;

    _safeMint(msg.sender, _count);
  }

  function numberMinted(address owner) public view returns (uint256) {
    return _numberMinted(owner);
  }

  function walletOfOwner(address _owner) external view returns(uint256[] memory) {
    uint tokenCount = balanceOf(_owner);
    uint256[] memory tokensId = new uint256[](tokenCount);

    for(uint i = 0; i < tokenCount; i++){
      tokensId[i] = tokenOfOwnerByIndex(_owner, i);
    }
    return tokensId;
  }

  function withdraw() external onlyAuthorized {
    uint balance = address(this).balance;
    payable(OtherAddress1).transfer(balance * 9000 / 10000);
    payable(OtherAddress2).transfer(balance * 1000 / 10000);
    payable(owner()).transfer(balance * 0 / 10000);
  }
}

Read Contract

allowListClaimedBy 0x0008ffdd → uint256
allowListMaxMint 0x7f44ab2f → uint256
balanceOf 0x70a08231 → uint256
checkIfOnAllowList 0x2c1205f4 → bool
getApproved 0x081812fc → address
getContractOwner 0x442890d5 → address
getIsClosedMintForever 0xf132dc29 → bool
getMaximumAllowedTokens 0xad06d758 → uint256
getMintPrice 0xa7f93ebd → uint256
getPreSaleMintPrice 0x21a911f8 → uint256
getRaffleMintPrice 0x2992b0b0 → uint256
getReserveAtATime 0xe7b62d96 → uint256
getRoot 0x5ca1e165 → bytes32
getTotalSupply 0xc4e41b22 → uint256
isApprovedForAll 0xe985e9c5 → bool
isClosedMintForever 0x7d26f470 → bool
isMintActive 0x5b92ac0d → bool
isPreSaleMintActive 0x9ccb0fea → bool
isRaffleActive 0xc3441646 → bool
isSellOpen 0x431adcb1 → bool
maxPerAddressDuringMint 0x8bc35c2f → uint256
maximumAllowedTokensPerPurchase 0x9a3bf728 → uint256
maximumAllowedTokensPerWallet 0xcadf8818 → uint256
maximumMintSupply 0x4d0550de → uint256
mintPrice 0x6817c76c → uint256
name 0x06fdde03 → string
nextOwnerToExplicitlySet 0xd7224ba0 → uint256
numberMinted 0xdc33e681 → uint256
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
preSaleMintPrice 0xec7d0991 → uint256
publicMintClaimed 0xf7cb9e54 → uint256
raffleMintPrice 0x3e8f0987 → uint256
root 0xebf0c717 → bytes32
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
walletOfOwner 0x438b6300 → uint256[]

Write Contract 31 functions

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

addToAllowList 0x7263cfe2
address[] addresses
approve 0x095ea7b3
address to
uint256 tokenId
mint 0x40c10f19
address _to
uint256 _count
preSaleMint 0x7835c635
uint256 _count
raffleMint 0x7890b2c9
uint256 _count
bytes32[] _proof
removeFromAllowList 0xa51312c8
address[] addresses
renounceOwnership 0x715018a6
No parameters
reserveNft 0x71e3500c
No parameters
reserveToCustomWallet 0x77b501b9
address _walletAddress
uint256 _count
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setAllowListMaxMint 0x7a6685f1
uint256 maxMint
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string baseURI
setIsClosedMintForever 0x932ecebc
No parameters
setIsPreSaleMintActive 0x3cfac570
bool _isPreSaleMintActive
setIsSellOpen 0x98590a39
bool _isSellOpen
setMaxMintSupply 0x7389fbb7
uint256 maxMintSupply
setMaxReserve 0x56a87caa
uint256 val
setMaximumAllowedTokens 0x4dfea627
uint256 _count
setMaximumAllowedTokensPerWallet 0xea6eb836
uint256 _count
setMintActive 0xee1cc944
bool val
setMintPrice 0xf4a0a528
uint256 _price
setPreSaleMintPrice 0x3b9ee7e4
uint256 _price
setRaffleActive 0x2f57bcfe
bool _isRaffleActive
setRaffleMintPrice 0xc3ac4feb
uint256 _price
setReserveAtATime 0xf6c9d9e3
uint256 val
setRoot 0xdab5f340
bytes32 _root
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters

Recent Transactions

No transactions found for this address