Address Contract Partially Verified
Address
0x2b6dF7F8389e6ecf97A0f06b189349c409A24083
Balance
0 ETH
Nonce
1
Code Size
19620 bytes
Creator
0x941c824b...027D at tx 0x98a56112...4d3ddc
Indexed Transactions
0
Contract Bytecode
19620 bytes
0x6080604052600436106104315760003560e01c80638129fc1c11610229578063b88d4fde1161012e578063d51b817a116100b6578063e985e9c51161007a578063e985e9c514610c7c578063efdf67ca14610cc5578063f0e9b29a14610cdb578063f2fde38b14610cfb578063fcd3533c14610d1b57600080fd5b8063d51b817a14610bf2578063db7aa27314610c07578063dbddb26a14610c27578063e14a0b3714610c3c578063e719ca9c14610c5c57600080fd5b8063c23dc68f116100fd578063c23dc68f14610b50578063c627525514610b7d578063c7f8d01a14610b9d578063c863c39414610bb2578063c87b56dd14610bd257600080fd5b8063b88d4fde14610ae7578063b93f208a14610afa578063bb1fb1db14610b1a578063bedb86fb14610b3057600080fd5b8063a0bcfc7f116101b1578063a546615b11610180578063a546615b146109fd578063a734678014610528578063adc25c0114610a2a578063b0440a3614610a57578063b237b17314610a8f57600080fd5b8063a0bcfc7f1461098d578063a1e14411146109ad578063a22cb465146109c7578063a4f4f8af146109e757600080fd5b806395d89b41116101f857806395d89b4114610902578063962677151461091757806399a2557a146109375780639e34070f146109575780639f272ce01461097757600080fd5b80638129fc1c1461087e5780638462151c146108935780638da5cb5b146108c0578063939f96be146108de57600080fd5b806332cb6b0c1161033a5780635b156934116102c25780636352211e116102865780636352211e146107f357806370a0823114610813578063715018a6146108335780637cb6475914610848578063808b93081461086857600080fd5b80635b156934146107615780635bbb2177146107815780635c975abb146107ae5780635e84d723146107c8578063611f3f10146107dd57600080fd5b80634de0d5eb116103095780634de0d5eb146106a65780634f02c420146106d65780634f828530146106ec578063519b05ba1461070c57806356e1d5e61461074157600080fd5b806332cb6b0c146106575780633c739ed31461066d57806342842e0e146106805780634d3554c31461069357600080fd5b80631a63b587116103bd5780632a00648d1161038c5780632a00648d146105e15780632d3e7ac5146105285780632db115441461060e5780632e1a7d4d146106215780632eb4a7ab1461064157600080fd5b80631a63b5871461056d5780631aa5e8721461058d5780631ad21333146105b957806323b872dd146105ce57600080fd5b8063095ea7b311610404578063095ea7b3146104f35780630b81e216146105085780630d0f38b81461052857806318160ddd1461053d5780631a5d62491461055a57600080fd5b806301ffc9a714610436578063050a0bc51461046b57806306fdde0314610499578063081812fc146104bb575b600080fd5b34801561044257600080fd5b50610456610451366004613fae565b610d3b565b60405190151581526020015b60405180910390f35b34801561047757600080fd5b5061048b610486366004613fcb565b610d4c565b604051908152602001610462565b3480156104a557600080fd5b506104ae610d6d565b6040516104629190614034565b3480156104c757600080fd5b506104db6104d6366004613fcb565b610dff565b6040516001600160a01b039091168152602001610462565b610506610501366004614063565b610e43565b005b34801561051457600080fd5b5061050661052336600461409d565b610e51565b34801561053457600080fd5b5061048b600381565b34801561054957600080fd5b50600154600054036000190161048b565b610506610568366004614103565b610e77565b34801561057957600080fd5b5061048b610588366004613fcb565b6110d3565b34801561059957600080fd5b5061048b6105a836600461416a565b602080526000908152604090205481565b3480156105c557600080fd5b5061048b6110e3565b6105066105dc366004614185565b611108565b3480156105ed57600080fd5b5061048b6105fc36600461416a565b60146020526000908152604090205481565b61050661061c366004613fcb565b611122565b34801561062d57600080fd5b5061050661063c366004613fcb565b6112f6565b34801561064d57600080fd5b5061048b60185481565b34801561066357600080fd5b5061048b6115b381565b61050661067b366004614103565b6113a6565b61050661068e366004614185565b6115ab565b6105066106a1366004613fcb565b6115c0565b3480156106b257600080fd5b506104566106c136600461416a565b60216020526000908152604090205460ff1681565b3480156106e257600080fd5b5061048b601d5481565b3480156106f857600080fd5b50610506610707366004613fcb565b61163f565b34801561071857600080fd5b5061072c610727366004613fcb565b611712565b60408051928352602083019190915201610462565b34801561074d57600080fd5b5061050661075c3660046141c1565b611882565b34801561076d57600080fd5b5061050661077c3660046141fc565b6118a1565b34801561078d57600080fd5b506107a161079c36600461421e565b611a67565b604051610462919061429b565b3480156107ba57600080fd5b50601c546104569060ff1681565b3480156107d457600080fd5b5061048b611b32565b3480156107e957600080fd5b5061048b601e5481565b3480156107ff57600080fd5b506104db61080e366004613fcb565b611b57565b34801561081f57600080fd5b5061048b61082e36600461416a565b611b62565b34801561083f57600080fd5b50610506611bb0565b34801561085457600080fd5b50610506610863366004613fcb565b611bc4565b34801561087457600080fd5b5061048b601a5481565b34801561088a57600080fd5b50610506611bd1565b34801561089f57600080fd5b506108b36108ae36600461416a565b611c02565b6040516104629190614318565b3480156108cc57600080fd5b506008546001600160a01b03166104db565b3480156108ea57600080fd5b506108f3611d0a565b6040516104629392919061432b565b34801561090e57600080fd5b506104ae611ebe565b34801561092357600080fd5b5061050661093236600461436e565b611ecd565b34801561094357600080fd5b506108b3610952366004614407565b612133565b34801561096357600080fd5b50610456610972366004613fcb565b6122ba565b34801561098357600080fd5b5061048b6107d081565b34801561099957600080fd5b506105066109a83660046144c5565b6122fb565b3480156109b957600080fd5b50600d546104569060ff1681565b3480156109d357600080fd5b506105066109e236600461450d565b61230f565b3480156109f357600080fd5b5061048b601b5481565b348015610a0957600080fd5b5061048b610a18366004613fcb565b60226020526000908152604090205481565b348015610a3657600080fd5b50610a4a610a45366004614063565b612319565b6040516104629190614540565b348015610a6357600080fd5b5061048b610a72366004614063565b601f60209081526000928352604080842090915290825290205481565b348015610a9b57600080fd5b50600e54600f54601054601154601254601354610aba95949392919086565b604080519687526020870195909552938501929092526060840152608083015260a082015260c001610462565b610506610af536600461473f565b612a07565b348015610b0657600080fd5b50610506610b1536600461421e565b612a23565b348015610b2657600080fd5b5061048b60155481565b348015610b3c57600080fd5b50610506610b4b36600461409d565b612bab565b348015610b5c57600080fd5b50610b70610b6b366004613fcb565b612bc6565b60405161046291906147ba565b348015610b8957600080fd5b50610506610b98366004613fcb565b612c4e565b348015610ba957600080fd5b5061048b612c5b565b348015610bbe57600080fd5b5061048b610bcd366004613fcb565b612ccc565b348015610bde57600080fd5b506104ae610bed366004613fcb565b612cdc565b348015610bfe57600080fd5b50610456612d5f565b348015610c1357600080fd5b50610506610c2236600461450d565b612d79565b348015610c3357600080fd5b506104ae612dac565b348015610c4857600080fd5b50610506610c5736600461421e565b612e3a565b348015610c6857600080fd5b50610456610c773660046147c8565b612e99565b348015610c8857600080fd5b50610456610c97366004614826565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610cd157600080fd5b5061048b60195481565b348015610ce757600080fd5b50610506610cf636600461416a565b612f38565b348015610d0757600080fd5b50610506610d1636600461416a565b612f62565b348015610d2757600080fd5b50610506610d36366004614850565b612fd8565b6000610d46826130f4565b92915050565b600b8181548110610d5c57600080fd5b600091825260209091200154905081565b606060028054610d7c90614873565b80601f0160208091040260200160405190810160405280929190818152602001828054610da890614873565b8015610df55780601f10610dca57610100808354040283529160200191610df5565b820191906000526020600020905b815481529060010190602001808311610dd857829003601f168201915b5050505050905090565b6000610e0a82613142565b610e27576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b610e4d8282613177565b5050565b610e59613217565b60238054911515600160a01b0260ff60a01b19909216919091179055565b601c5460ff1615610ea35760405162461bcd60e51b8152600401610e9a906148ad565b60405180910390fd5b600260095403610ec55760405162461bcd60e51b8152600401610e9a906148da565b6002600955336001600160a01b0384168114610ef35760405162461bcd60e51b8152600401610e9a90614911565b610efd600061163f565b333214610f1c5760405162461bcd60e51b8152600401610e9a90614954565b3486610f26612c5b565b610f309190614993565b1115610f4e5760405162461bcd60e51b8152600401610e9a906149aa565b6001600160a01b0381166000908152601f6020908152604080832060018452909152902054600390610f819088906149e1565b1115610fed5760405162461bcd60e51b815260206004820152603560248201527f6572726f723a2077686974656c6973742063616e6e6f74206d696e74206d6f7260448201527465207468616e204d41585f4d494e5420283129202160581b6064820152608401610e9a565b6107d086601954610ffe91906149e1565b11156110575760405162461bcd60e51b815260206004820152602260248201527f6572726f723a2063757272656e74207374616765206d696e742066696e697368604482015261195960f21b6064820152608401610e9a565b6000611067866001878787613271565b9050611073828861337e565b6001600160a01b0382166000908152601f6020908152604080832060018452909152812080548992906110a79084906149e1565b9250508190555086601960008282546110c091906149e1565b9091555050600160095550505050505050565b600a8181548110610d5c57600080fd5b601954600f54600091906110f9906115b36149f4565b61110391906149f4565b905090565b61111283836133d1565b61111d838383613430565b505050565b601c5460ff16156111455760405162461bcd60e51b8152600401610e9a906148ad565b6002600954036111675760405162461bcd60e51b8152600401610e9a906148da565b60026009553332811461118c5760405162461bcd60e51b8152600401610e9a90614954565b611196600261163f565b34826111a0612c5b565b6111aa9190614993565b11156111c85760405162461bcd60e51b8152600401610e9a906149aa565b81601d546111d691906149e1565b6115b310156111f75760405162461bcd60e51b8152600401610e9a90614a07565b6001600160a01b0381166000908152601f60209081526040808320600384529091529020546112279083906149e1565b600310156112935760405162461bcd60e51b815260206004820152603360248201527f6572726f723a20752063616e6e6f74206d696e74206d6f7265207468616e205060448201527255424c49435f4d41585f4d494e54283229202160681b6064820152608401610e9a565b61129d818361337e565b81601b60008282546112af91906149e1565b90915550506001600160a01b0381166000908152601f6020908152604080832060038452909152812080548492906112e89084906149e1565b909155505060016009555050565b6112fe613217565b6002600954036113205760405162461bcd60e51b8152600401610e9a906148da565b60026009558060008190036113325750475b600081116113825760405162461bcd60e51b815260206004820152601b60248201527f6572726f723a616d6f756e742063616e6e6f74206265207a65726f00000000006044820152606401610e9a565b61139d6113976008546001600160a01b031690565b826135c1565b50506001600955565b601c5460ff16156113c95760405162461bcd60e51b8152600401610e9a906148ad565b6002600954036113eb5760405162461bcd60e51b8152600401610e9a906148da565b6002600955336001600160a01b03841681146114195760405162461bcd60e51b8152600401610e9a90614911565b611423600161163f565b3332146114425760405162461bcd60e51b8152600401610e9a90614954565b348661144c612c5b565b6114569190614993565b11156114745760405162461bcd60e51b8152600401610e9a906149aa565b6001600160a01b0381166000908152601f60209081526040808320600284529091529020546003906114a79088906149e1565b11156115135760405162461bcd60e51b815260206004820152603560248201527f6572726f723a2077686974656c6973742063616e6e6f74206d696e74206d6f7260448201527465207468616e204d41585f4d494e5420283229202160581b6064820152608401610e9a565b85601d5461152191906149e1565b6115b310156115425760405162461bcd60e51b8152600401610e9a90614a07565b6000611552866002878787613271565b905061155e828861337e565b6001600160a01b0382166000908152601f6020908152604080832060028452909152812080548992906115929084906149e1565b9250508190555086601a60008282546110c091906149e1565b6115b583836133d1565b61111d83838361365d565b601c5460ff16156115e35760405162461bcd60e51b8152600401610e9a906148ad565b6002600954036116055760405162461bcd60e51b8152600401610e9a906148da565b60026009553332811461162a5760405162461bcd60e51b8152600401610e9a90614954565b611635818334613678565b61139d818361337e565b6022600061164e836002614993565b81526020019081526020016000205442101561169e5760405162461bcd60e51b815260206004820152600f60248201526e1cdd1859d9481b9bdd081cdd185c9d608a1b6044820152606401610e9a565b602260006116ad836002614993565b6116b89060016149e1565b81526020019081526020016000205442111561170f5760405162461bcd60e51b81526020600482015260166024820152751cdd1859d948185b1c9958591e48199a5b9a5cda195960521b6044820152606401610e9a565b50565b600a54600090819080820361172d5750600093849350915050565b600a60008154811061174157611741614a3e565b906000526020600020015484101561179b57600b60008154811061176757611767614a3e565b9060005260206000200154600c60008154811061178657611786614a3e565b90600052602060002001549250925050915091565b60005b8181101561183a57600a81815481106117b9576117b9614a3e565b906000526020600020015485101561182857600b6117d86001836149f4565b815481106117e8576117e8614a3e565b9060005260206000200154600c60018361180291906149f4565b8154811061181257611812614a3e565b9060005260206000200154935093505050915091565b8061183281614a54565b91505061179e565b50600b6118486001836149f4565b8154811061185857611858614a3e565b9060005260206000200154600c60018361187291906149f4565b8154811061178657611786614a3e565b61188a613217565b600e94909455601092909255601155601255601355565b6118a9613217565b816001829003611976576118bb612d5f565b6119075760405162461bcd60e51b815260206004820152601960248201527f736f7272792061756374696f6e206e6f742072756e6e696e67000000000000006044820152606401610e9a565b60008061191342611712565b6015829055600f549193509150819061192d9085906149e1565b1061195857600f5461193f90826149f4565b600f829055600d805460ff191660011790559250611973565b82600e600101600082825461196d91906149e1565b90915550505b50505b816002036119c957611988600061163f565b6107d08160195461199991906149e1565b11156119b1576019546119ae906107d06149f4565b90505b80601960008282546119c391906149e1565b90915550505b816003036119f3576119db600161163f565b80601a60008282546119ed91906149e1565b90915550505b81600403611a1d57611a05600261163f565b80601b6000828254611a1791906149e1565b90915550505b80601d54611a2b91906149e1565b6115b31015611a4c5760405162461bcd60e51b8152600401610e9a90614a07565b61111d611a616008546001600160a01b031690565b8261337e565b6060816000816001600160401b03811115611a8457611a8461443a565b604051908082528060200260200182016040528015611ad657816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181611aa25790505b50905060005b828114611b2957611b04868683818110611af857611af8614a3e565b90506020020135612bc6565b828281518110611b1657611b16614a3e565b6020908102919091010152600101611adc565b50949350505050565b6000601a54601954600e600101546115b3611b4d91906149f4565b6110f991906149f4565b6000610d46826138e0565b60006001600160a01b038216611b8b576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b611bb8613217565b611bc2600061394f565b565b611bcc613217565b601855565b611bd9613217565b600260095403611bfb5760405162461bcd60e51b8152600401610e9a906148da565b6001600955565b60606000806000611c1285611b62565b90506000816001600160401b03811115611c2e57611c2e61443a565b604051908082528060200260200182016040528015611c57578160200160208202803683370190505b509050611c8460408051608081018252600080825260208201819052918101829052606081019190915290565b60015b838614611cfe57611c97816139a1565b91508160400151611cf65781516001600160a01b031615611cb757815194505b876001600160a01b0316856001600160a01b031603611cf65780838780600101985081518110611ce957611ce9614a3e565b6020026020010181815250505b600101611c87565b50909695505050505050565b6060806060600a805490506001600160401b03811115611d2c57611d2c61443a565b604051908082528060200260200182016040528015611d55578160200160208202803683370190505b50600a549093506001600160401b03811115611d7357611d7361443a565b604051908082528060200260200182016040528015611d9c578160200160208202803683370190505b50600a549092506001600160401b03811115611dba57611dba61443a565b604051908082528060200260200182016040528015611de3578160200160208202803683370190505b50905060005b600a54811015611eb857600b8181548110611e0657611e06614a3e565b9060005260206000200154848281518110611e2357611e23614a3e565b602002602001018181525050600a8181548110611e4257611e42614a3e565b9060005260206000200154838281518110611e5f57611e5f614a3e565b602002602001018181525050600c8181548110611e7e57611e7e614a3e565b9060005260206000200154828281518110611e9b57611e9b614a3e565b602090810291909101015280611eb081614a54565b915050611de9565b50909192565b606060038054610d7c90614873565b611ed5613217565b84838114611f255760405162461bcd60e51b815260206004820152601c60248201527f61756374696f6e207072696365206c697374206e6f7420657175616c000000006044820152606401610e9a565b808214611f745760405162461bcd60e51b815260206004820152601d60248201527f61756374696f6e20737570706c79206c697374206e6f7420657175616c0000006044820152606401610e9a565b60005b8181101561212957611f8a8160016149e1565b600a541015611fce57600a888883818110611fa757611fa7614a3e565b83546001810185556000948552602094859020919094029290920135919092015550612007565b878782818110611fe057611fe0614a3e565b90506020020135600a8281548110611ffa57611ffa614a3e565b6000918252602090912001555b6120128160016149e1565b600b54101561205657600b86868381811061202f5761202f614a3e565b8354600181018555600094855260209485902091909402929092013591909201555061208f565b85858281811061206857612068614a3e565b90506020020135600b828154811061208257612082614a3e565b6000918252602090912001555b61209a8160016149e1565b600c5410156120de57600c8484838181106120b7576120b7614a3e565b83546001810185556000948552602094859020919094029290920135919092015550612117565b8383828181106120f0576120f0614a3e565b90506020020135600c828154811061210a5761210a614a3e565b6000918252602090912001555b8061212181614a54565b915050611f77565b5050505050505050565b606081831061215557604051631960ccad60e11b815260040160405180910390fd5b60008061216160005490565b9050600185101561217157600194505b8084111561217d578093505b600061218887611b62565b9050848610156121a757858503818110156121a1578091505b506121ab565b5060005b6000816001600160401b038111156121c5576121c561443a565b6040519080825280602002602001820160405280156121ee578160200160208202803683370190505b509050816000036122045793506122b392505050565b600061220f88612bc6565b905060008160400151612220575080515b885b8881141580156122325750848714155b156122a757612240816139a1565b9250826040015161229f5782516001600160a01b03161561226057825191505b8a6001600160a01b0316826001600160a01b03160361229f578084888060010199508151811061229257612292614a3e565b6020026020010181815250505b600101612222565b50505092835250909150505b9392505050565b6000806122c961010084614a83565b905060006122d961010085614a97565b60009283526017602052604090922054600190921b9182169091149392505050565b612303613217565b6016610e4d8282614af1565b610e4d82826139dd565b61241b60405180610440016040528060001515815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160608152602001606081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581525090565b601c5460ff16151581526115b36020820152601d5460408201526001546000540360001901606082015260008061245142611712565b60a08501829052600f5460c086015260e085018190526001600160a01b038716600090815260146020526040902054610100860152600a5491935091506001600160401b038111156124a5576124a561443a565b6040519080825280602002602001820160405280156124ce578160200160208202803683370190505b50610120840152600a546001600160401b038111156124ef576124ef61443a565b604051908082528060200260200182016040528015612518578160200160208202803683370190505b50610140840152600a546001600160401b038111156125395761253961443a565b604051908082528060200260200182016040528015612562578160200160208202803683370190505b5061016084015260005b600a5481101561264a57600b818154811061258957612589614a3e565b906000526020600020015484610120015182815181106125ab576125ab614a3e565b602002602001018181525050600a81815481106125ca576125ca614a3e565b906000526020600020015484610140015182815181106125ec576125ec614a3e565b602002602001018181525050600c818154811061260b5761260b614a3e565b9060005260206000200154846101600151828151811061262d5761262d614a3e565b60209081029190910101528061264281614a54565b91505061256c565b50612653612c5b565b6101808401526019546101a08401526107d06101c08401526001600160a01b0385166000908152601f60209081526040808320600184529091529020546101e0840152601a546102008401526126a76110e3565b6102208401526001600160a01b0385166000908152601f6020908152604080832060028452909152902054610240840152601b546102608401526126e9611b32565b6102808401526001600160a01b0385166000908152601f602090815260408083206003845282528220546102a08601526010546102c08601526011546102e08601527fb84cf808d0d5b1ad44962c9bfddd3cfce67763c49ab557cfd0e9f6804faade99546103008601527fe39b43e4224876d80510ac9d8f190663bcce357e28a4aec26f3bf2e600bb40ec546103208601527f52978eb6718a0ed733b71dbb3c4781d6da146a41523832713c09679420d0cac5546103408601527f3f1c07aec4ba487306d5d4faaa1d9deb5d8db1e41c6130041b740cb07487a597546103608601527fd7343ae3d2c16eacc7c893fad12c1ec38efa5751e5cb5741a848035a232aa5e85461038086015260058252602290527f7936fc421e3565b4d3dbcb3877e96699375ad835c0ef9d9615e712c52b84dd4a546103a085015261282e9042906149e1565b6103c0840152600d5460ff1615156104208401526102c083015142101561285b57606560808401526129ff565b826102e00151421080156128725750600d5460ff16155b1561289857600160808401526101008301516103e08401526013546104008401526129ff565b826102e00151421080156128ae5750600d5460ff165b156128d457606660808401526101008301516103e08401526013546104008401526129ff565b82610300015142101561290257606660808401526101008301516103e08401526013546104008401526129ff565b82610320015142101561292f57600260808401526101e08301516103e084015260036104008401526129ff565b82610340015142101561295c57606760808401526101e08301516103e084015260036104008401526129ff565b826103600151421015612989576003608084018190526102408401516103e08501526104008401526129ff565b8261038001514210156129b657606860808401526102408301516103e084015260036104008401526129ff565b826103a001514210156129e357600460808401526102a08301516103e084015260036104008401526129ff565b606960808401526102a08301516103e084015260036104008401525b505092915050565b612a1184846133d1565b612a1d84848484613a49565b50505050565b602354600160a01b900460ff16612a6f5760405162461bcd60e51b815260206004820152601060248201526f3932bb32b0b6103737ba103132b3b4b760811b6044820152606401610e9a565b333214612a8e5760405162461bcd60e51b8152600401610e9a90614954565b60005b8181101561111d576000838383818110612aad57612aad614a3e565b905060200201359050612abd3390565b6001600160a01b0316612acf82611b57565b6001600160a01b031614612b1d5760405162461bcd60e51b81526020600482015260156024820152741bdb9b1e481bdddb995c8818d85b881c995d99585b605a1b6044820152606401610e9a565b6023546001600160a01b0316633292fa63336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b158015612b7757600080fd5b505af1158015612b8b573d6000803e3d6000fd5b50505050612b9881613a8d565b5080612ba381614a54565b915050612a91565b612bb3613217565b601c805460ff1916911515919091179055565b6040805160808101825260008082526020820181905291810182905260608101919091526040805160808101825260008082526020820181905291810182905260608101919091526001831080612c1f57506000548310155b15612c2a5792915050565b612c33836139a1565b9050806040015115612c455792915050565b6122b383613a98565b612c56613217565b601e55565b600d5460009060ff168015612c9e5750600a54600b90612c7d906001906149f4565b81548110612c8d57612c8d614a3e565b906000526020600020015460155414155b15612cc0576103e8601554610320612cb69190614993565b6111039190614a83565b50662a46fca8d3c00090565b600c8181548110610d5c57600080fd5b6060612ce782613142565b612d0457604051630a14c4b560e41b815260040160405180910390fd5b6000612d0e613acd565b90508051600003612d2e57604051806020016040528060008152506122b3565b80612d3884613adc565b604051602001612d49929190614bb0565b6040516020818303038152906040529392505050565b601054600090421080159061110357505060115442111590565b612d81613217565b6001600160a01b03919091166000908152602160205260409020805460ff1916911515919091179055565b60168054612db990614873565b80601f0160208091040260200160405190810160405280929190818152602001828054612de590614873565b8015612e325780601f10612e0757610100808354040283529160200191612e32565b820191906000526020600020905b815481529060010190602001808311612e1557829003601f168201915b505050505081565b612e42613217565b60005b60ff811682111561111d5782828260ff16818110612e6557612e65614a3e565b90506020020135602260008360ff168152602001908152602001600020819055508080612e9190614bdf565b915050612e45565b600080868686604051602001612ed49392919092835260609190911b6bffffffffffffffffffffffff19166020830152603482015260540190565b604051602081830303815290604052805190602001209050612f2c8484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508c9250859150613b209050565b98975050505050505050565b612f40613217565b602380546001600160a01b0319166001600160a01b0392909216919091179055565b612f6a613217565b6001600160a01b038116612fcf5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610e9a565b61170f8161394f565b6008546001600160a01b031633148061300057503360009081526021602052604090205460ff165b61305a5760405162461bcd60e51b815260206004820152602560248201527f6572726f723a75736572206f7220636f6e7472616374207368616c6c206e6f74604482015264207061737360d81b6064820152608401610e9a565b806001600160a01b031661306d83611b57565b6001600160a01b0316146130d15760405162461bcd60e51b815260206004820152602560248201527f6572726f723a6f6e6c79206f776e65722063616e206275726e207468697320746044820152646f6b656e2160d81b6064820152608401610e9a565b610e4d82613a8d565b610e4d828260405180602001604052806000815250613b36565b60006301ffc9a760e01b6001600160e01b03198316148061312557506380ac58cd60e01b6001600160e01b03198316145b80610d465750506001600160e01b031916635b5e139f60e01b1490565b600081600111158015613156575060005482105b8015610d46575050600090815260046020526040902054600160e01b161590565b600061318282611b57565b9050336001600160a01b038216146131bb5761319e8133610c97565b6131bb576040516367d9dca160e11b815260040160405180910390fd5b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6008546001600160a01b03163314611bc25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610e9a565b6000808685876040516020016132ac9392919092835260609190911b6bffffffffffffffffffffffff19166020830152603482015260540190565b604051602081830303815290604052805190602001209050613305848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506018549150849050613b20565b61335b5760405162461bcd60e51b815260206004820152602160248201527f4d65726b6c654469737472696275746f723a20496e76616c69642070726f6f666044820152601760f91b6064820152608401610e9a565b613364876122ba565b9150816133745761337487613b9c565b5095945050505050565b61338882826130da565b6001600160a01b0382166000908152602080526040812080548392906133af9084906149e1565b9250508190555080601d60008282546133c891906149e1565b90915550505050565b602354600160a01b900460ff16610e4d576001600160a01b03821615610e4d5760405162461bcd60e51b81526020600482015260146024820152731d1c985b9cd9995c881c995858da081b1a5b5a5d60621b6044820152606401610e9a565b600061343b826138e0565b9050836001600160a01b0316816001600160a01b03161461346e5760405162a1148160e81b815260040160405180910390fd5b6000828152600660205260409020805461349a8187335b6001600160a01b039081169116811491141790565b6134c5576134a88633610c97565b6134c557604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0385166134ec57604051633a954ecd60e21b815260040160405180910390fd5b80156134f757600082555b6001600160a01b038681166000908152600560205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260046020526040812091909155600160e11b84169003613589576001840160008181526004602052604081205490036135875760005481146135875760008181526004602052604090208490555b505b83856001600160a01b0316876001600160a01b0316600080516020614c4f83398151915260405160405180910390a45b505050505050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461360e576040519150601f19603f3d011682016040523d82523d6000602084013e613613565b606091505b505090508061111d5760405162461bcd60e51b815260206004820152601660248201527532b93937b91d2a3930b739b332b9103330b4b632b21760511b6044820152606401610e9a565b61111d83838360405180602001604052806000815250612a07565b613680612d5f565b6136c55760405162461bcd60e51b815260206004820152601660248201527561756374696f6e206973206e6f742072756e6e696e6760501b6044820152606401610e9a565b6013546001600160a01b0384166000908152601460205260409020546136ec9084906149e1565b111561372d5760405162461bcd60e51b815260206004820152601060248201526f752063616e206f6e6c7920627579203560801b6044820152606401610e9a565b60008061373942611712565b90925090506137488483614993565b83101561378d5760405162461bcd60e51b81526020600482015260136024820152720eae6cae440e0c2f240dcdee840cadcdeeaced606b1b6044820152606401610e9a565b600f54819061379d9086906149e1565b111561381d5760405162461bcd60e51b815260206004820152604360248201527f7468657265206973206e6f20656e6f7567682061756374696f6e20736f66612060448201527f6d616b657220666f722075212061756374696f6e2073656c6c2066696e69736860648201526265642160e81b608482015260a401610e9a565b604080516001600160a01b03871681526020810186905242818301526060810184905290517f18870ddfb3e2de337bc0a83a3a3783d3ec73a5464740f33abe6576c7629861959181900360800190a16001600160a01b038516600090815260146020526040812080548692906138949084906149e1565b9091555050600f80548591906000906138ae9084906149e1565b909155505060155482146138c25760158290555b600f5481116138d957600d805460ff191660011790555b5050505050565b60008180600111613936576000548110156139365760008181526004602052604081205490600160e01b82169003613934575b806000036122b3575060001901600081815260046020526040902054613913565b505b604051636f96cda160e11b815260040160405180910390fd5b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516080810182526000808252602082018190529181018290526060810191909152600082815260046020526040902054610d4690613bda565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b613a54848484611108565b6001600160a01b0383163b15612a1d57613a7084848484613c21565b612a1d576040516368d2bf6b60e11b815260040160405180910390fd5b61170f816000613d0d565b604080516080810182526000808252602082018190529181018290526060810191909152610d46613ac8836138e0565b613bda565b606060168054610d7c90614873565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a900480613af65750819003601f19909101908152919050565b600082613b2d8584613e45565b14949350505050565b613b408383613e92565b6001600160a01b0383163b1561111d576000548281035b613b6a6000868380600101945086613c21565b613b87576040516368d2bf6b60e11b815260040160405180910390fd5b818110613b575781600054146138d957600080fd5b6000613baa61010083614a83565b90506000613bba61010084614a97565b6000928352601760205260409092208054600190931b9092179091555050565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290613c56903390899088908890600401614bfe565b6020604051808303816000875af1925050508015613c91575060408051601f3d908101601f19168201909252613c8e91810190614c31565b60015b613cef573d808015613cbf576040519150601f19603f3d011682016040523d82523d6000602084013e613cc4565b606091505b508051600003613ce7576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b6000613d18836138e0565b905080600080613d3686600090815260066020526040902080549091565b915091508415613d7657613d4b818433613485565b613d7657613d598333610c97565b613d7657604051632ce44b5f60e11b815260040160405180910390fd5b8015613d8157600082555b6001600160a01b038316600081815260056020526040902080546fffffffffffffffffffffffffffffffff0190554260a01b17600360e01b17600087815260046020526040812091909155600160e11b85169003613e0f57600186016000818152600460205260408120549003613e0d576000548114613e0d5760008181526004602052604090208590555b505b60405186906000906001600160a01b03861690600080516020614c4f833981519152908390a45050600180548101905550505050565b600081815b8451811015613e8a57613e7682868381518110613e6957613e69614a3e565b6020026020010151613f6c565b915080613e8281614a54565b915050613e4a565b509392505050565b6000805490829003613eb75760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b03831660008181526005602090815260408083208054680100000000000000018802019055848352600490915281206001851460e11b4260a01b17831790558284019083908390600080516020614c4f8339815191528180a4600183015b818114613f425780836000600080516020614c4f833981519152600080a4600101613f1c565b5081600003613f6357604051622e076360e81b815260040160405180910390fd5b60005550505050565b6000818310613f885760008281526020849052604090206122b3565b5060009182526020526040902090565b6001600160e01b03198116811461170f57600080fd5b600060208284031215613fc057600080fd5b81356122b381613f98565b600060208284031215613fdd57600080fd5b5035919050565b60005b83811015613fff578181015183820152602001613fe7565b50506000910152565b60008151808452614020816020860160208601613fe4565b601f01601f19169290920160200192915050565b6020815260006122b36020830184614008565b80356001600160a01b038116811461405e57600080fd5b919050565b6000806040838503121561407657600080fd5b61407f83614047565b946020939093013593505050565b8035801515811461405e57600080fd5b6000602082840312156140af57600080fd5b6122b38261408d565b60008083601f8401126140ca57600080fd5b5081356001600160401b038111156140e157600080fd5b6020830191508360208260051b85010111156140fc57600080fd5b9250929050565b60008060008060006080868803121561411b57600080fd5b853594506020860135935061413260408701614047565b925060608601356001600160401b0381111561414d57600080fd5b614159888289016140b8565b969995985093965092949392505050565b60006020828403121561417c57600080fd5b6122b382614047565b60008060006060848603121561419a57600080fd5b6141a384614047565b92506141b160208501614047565b9150604084013590509250925092565b600080600080600060a086880312156141d957600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b6000806040838503121561420f57600080fd5b50508035926020909101359150565b6000806020838503121561423157600080fd5b82356001600160401b0381111561424757600080fd5b614253858286016140b8565b90969095509350505050565b80516001600160a01b031682526020808201516001600160401b03169083015260408082015115159083015260609081015162ffffff16910152565b6020808252825182820181905260009190848201906040850190845b81811015611cfe576142ca83855161425f565b92840192608092909201916001016142b7565b600081518084526020808501945080840160005b8381101561430d578151875295820195908201906001016142f1565b509495945050505050565b6020815260006122b360208301846142dd565b60608152600061433e60608301866142dd565b828103602084015261435081866142dd565b9050828103604084015261436481856142dd565b9695505050505050565b6000806000806000806060878903121561438757600080fd5b86356001600160401b038082111561439e57600080fd5b6143aa8a838b016140b8565b909850965060208901359150808211156143c357600080fd5b6143cf8a838b016140b8565b909650945060408901359150808211156143e857600080fd5b506143f589828a016140b8565b979a9699509497509295939492505050565b60008060006060848603121561441c57600080fd5b61442584614047565b95602085013595506040909401359392505050565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b038084111561446a5761446a61443a565b604051601f8501601f19908116603f011681019082821181831017156144925761449261443a565b816040528093508581528686860111156144ab57600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156144d757600080fd5b81356001600160401b038111156144ed57600080fd5b8201601f810184136144fe57600080fd5b613d0584823560208401614450565b6000806040838503121561452057600080fd5b61452983614047565b91506145376020840161408d565b90509250929050565b6020815261455360208201835115159052565b602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e0820152600060e083015161010081818501528085015191505061012081818501528085015191505061044061014081818601526145cd6104608601846142dd565b9250808601519050601f196101608187860301818801526145ee85846142dd565b94508088015192505061018081878603018188015261460d85846142dd565b908801516101a0888101919091528801516101c0808901919091528801516101e08089019190915288015161020080890191909152880151610220808901919091528801516102408089019190915288015161026080890191909152880151610280808901919091528801516102a0808901919091528801516102c0808901919091528801516102e08089019190915288015161030080890191909152880151610320808901919091528801516103408089019190915288015161036080890191909152880151610380808901919091528801516103a0808901919091528801516103c0808901919091528801516103e08089019190915288015161040080890191909152880151610420808901919091528801518015158589015290945091506147359050565b5090949350505050565b6000806000806080858703121561475557600080fd5b61475e85614047565b935061476c60208601614047565b92506040850135915060608501356001600160401b0381111561478e57600080fd5b8501601f8101871361479f57600080fd5b6147ae87823560208401614450565b91505092959194509250565b60808101610d46828461425f565b60008060008060008060a087890312156147e157600080fd5b86359550602087013594506147f860408801614047565b93506060870135925060808701356001600160401b0381111561481a57600080fd5b6143f589828a016140b8565b6000806040838503121561483957600080fd5b61484283614047565b915061453760208401614047565b6000806040838503121561486357600080fd5b8235915061453760208401614047565b600181811c9082168061488757607f821691505b6020821081036148a757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252601390820152726572726f723a2073616c65207061757365642160681b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526023908201527f6572726f723a207520617265206e6f7420746865207265616c20574c206f776e60408201526265722160e81b606082015260800190565b6020808252600f908201526e6572726f723a20656f61206f6e6c7960881b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610d4657610d4661497d565b60208082526017908201527f6572726f723a207072696365206e6f7420656e6f756768000000000000000000604082015260600190565b80820180821115610d4657610d4661497d565b81810381811115610d4657610d4661497d565b6020808252601a908201527f6572726f723a204d41585f535550504c59207265616368656421000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060018201614a6657614a6661497d565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082614a9257614a92614a6d565b500490565b600082614aa657614aa6614a6d565b500690565b601f82111561111d57600081815260208120601f850160051c81016020861015614ad25750805b601f850160051c820191505b818110156135b957828155600101614ade565b81516001600160401b03811115614b0a57614b0a61443a565b614b1e81614b188454614873565b84614aab565b602080601f831160018114614b535760008415614b3b5750858301515b600019600386901b1c1916600185901b1785556135b9565b600085815260208120601f198616915b82811015614b8257888601518255948401946001909101908401614b63565b5085821015614ba05787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008351614bc2818460208801613fe4565b835190830190614bd6818360208801613fe4565b01949350505050565b600060ff821660ff8103614bf557614bf561497d565b60010192915050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061436490830184614008565b600060208284031215614c4357600080fd5b81516122b381613f9856feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220c65ef1e625bf327e87d977086fdf84ca12d08bf4839b76e2435d6fb1502f252d64736f6c63430008120033
Verified Source Code Partial Match
Compiler: v0.8.18+commit.87f61d96
EVM: paris
Optimization: Yes (200 runs)
Auction.sol 141 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* @title
* @author
* @notice
*/
contract AuctionMintContract is Ownable {
struct AuctionData {
uint256 initialSupply;
uint256 minted;
uint256 startTimestamp;
uint256 finishTimestamp;
uint256 initialPrice;
uint256 maxBuy;
}
uint256[] public auctionStepList;
uint256[] public auctionPriceList;
uint256[] public auctionSupplyList;
bool public auctionSoldout = false;
event AuctionNewStep(address user, uint256 minted, uint256 newPrice, uint256 newSupply);
event AuctionMint(address user, uint256 amount, uint256 timestamp, uint256 price);
AuctionData public auctionData;
mapping(address => uint256) public auctionMinted;
uint256 public finalAuctionPrice = 0.0169 ether;
function initAuction(
uint256 initialSupply,
uint256 startTimestamp,
uint256 finishTimestamp,
uint256 initialPrice,
uint256 maxBuy
) public onlyOwner {
auctionData.initialSupply = initialSupply;
auctionData.startTimestamp = startTimestamp;
auctionData.finishTimestamp = finishTimestamp;
auctionData.initialPrice = initialPrice;
auctionData.maxBuy = maxBuy;
}
function initAuctionPrice(
uint256[] calldata _auctionStepList,
uint256[] calldata _auctionPriceList,
uint256[] calldata _auctionSupplyList
) public onlyOwner {
uint len = _auctionStepList.length;
require(len == _auctionPriceList.length, "auction price list not equal");
require(len == _auctionSupplyList.length, "auction supply list not equal");
for (uint256 i = 0; i < len; i++) {
if (auctionStepList.length < i + 1) {
auctionStepList.push(_auctionStepList[i]);
} else {
auctionStepList[i] = _auctionStepList[i];
}
if (auctionPriceList.length < i + 1) {
auctionPriceList.push(_auctionPriceList[i]);
} else {
auctionPriceList[i] = _auctionPriceList[i];
}
if (auctionSupplyList.length < i + 1) {
auctionSupplyList.push(_auctionSupplyList[i]);
} else {
auctionSupplyList[i] = _auctionSupplyList[i];
}
}
}
function currentPriceAndSupply(uint256 currentTime) public view returns (uint256 price, uint256 supply) {
uint256 len = auctionStepList.length;
if (len == 0) {
return (uint256(0), uint256(0));
}
if (currentTime < auctionStepList[0]) {
return (auctionPriceList[0], auctionSupplyList[0]);
}
for (uint256 i = 0; i < len; i++) {
if (currentTime < auctionStepList[i]) {
return (auctionPriceList[i - 1], auctionSupplyList[i - 1]);
}
}
return (auctionPriceList[len - 1], auctionSupplyList[len - 1]);
}
function auctionRunning() public view returns (bool) {
return block.timestamp >= auctionData.startTimestamp && block.timestamp <= auctionData.finishTimestamp;
}
function auctionBeforeMint(
address user,
uint256 amount,
uint256 userPayed
) internal {
require(auctionRunning(), "auction is not running");
// user cap
require(auctionMinted[user] + amount <= auctionData.maxBuy, "u can only buy 5");
(uint256 newPrice, uint256 newSupply) = currentPriceAndSupply(block.timestamp);
require(userPayed >= newPrice * amount, "user pay not enough");
require(
auctionData.minted + amount <= newSupply,
"there is no enough auction sofa maker for u! auction sell finished!"
);
emit AuctionMint(user, amount, block.timestamp, newPrice);
auctionMinted[user] += amount;
auctionData.minted += amount;
if (finalAuctionPrice != newPrice) {
finalAuctionPrice = newPrice;
}
if (auctionData.minted >= newSupply) {
auctionSoldout = true;
}
}
function getAuctionPriceConfig()
public
view
returns (
uint256[] memory priceList,
uint256[] memory timeList,
uint256[] memory supplyList
)
{
priceList = new uint256[](auctionStepList.length);
timeList = new uint256[](auctionStepList.length);
supplyList = new uint256[](auctionStepList.length);
for (uint i = 0; i < auctionStepList.length; i++) {
priceList[i] = auctionPriceList[i];
timeList[i] = auctionStepList[i];
supplyList[i] = auctionSupplyList[i];
}
}
}
SofaNft.sol 513 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "erc721a/contracts/ERC721A.sol";
import "erc721a/contracts/extensions/ERC721AQueryable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "./interface/IRevealed721NFT.sol";
import "./Auction.sol";
contract SofaNFT is Ownable, ERC721AQueryable, ReentrancyGuard, AuctionMintContract {
constructor() ERC721A("Sofa Maker", "Sofa Maker") {
_safeMint(owner(), 1);
}
string public BASE_URI = "ipfs://bafybeiei3tgirxccl4sgoq4b5xkzquropmgzucy3w3pz5wmgs5pprf5o2q/";
mapping(uint256 => uint256) private claimedBitMap;
bytes32 public merkleRoot;
function initialize() public onlyOwner nonReentrant {}
/**
* @dev Returns the starting token ID.
* To change the starting token ID, please override this function.
*/
function _startTokenId() internal view virtual override returns (uint256) {
return 1;
}
uint256 public constant MAX_SUPPLY = 5555;
uint256 public constant WL1_SUPPLY = 2000;
uint256 public constant WL1_MAX_MINT = 3;
uint256 public constant WL_MAX_MINT = 3;
uint256 public constant PUBLIC_MAX_MINT = 3;
uint256 public wl1Minted = 0;
uint256 public wl2Minted = 0;
uint256 public publicMinted = 0;
bool public paused = false; // if the saling is running
uint256 public minted = 0;
uint256 public PUBLIC_PRICE = 0.0169 ether;
mapping(address => mapping(uint256 => uint256)) public userStageMinted;
mapping(address => uint256) public userMinted; // to limit single user mint max
mapping(address => bool) public burnPassMap;
mapping(uint256 => uint256) public timeRanges; // the ranges of start and end
function setBaseUri(string memory uri) public onlyOwner {
BASE_URI = uri;
}
function setMerkleRoot(bytes32 _root) public onlyOwner {
merkleRoot = _root;
}
function _baseURI() internal view virtual override returns (string memory) {
return BASE_URI;
}
function setPause(bool _paused) public onlyOwner {
paused = _paused;
}
function setPublicPrice(uint256 newPrice) public onlyOwner {
PUBLIC_PRICE = newPrice;
}
function setTimeRanges(uint256[] calldata ranges) public onlyOwner {
for (uint8 i = 0; i < ranges.length; i++) {
timeRanges[i] = ranges[i];
}
}
function checkRange(uint256 index) public {
require(block.timestamp >= timeRanges[index * 2], "stage not start");
require(block.timestamp <= timeRanges[index * 2 + 1], "stage already finished");
}
modifier notPaused() {
require(!paused, "error: sale paused!");
_;
}
function wlPrice() public view returns (uint256) {
// if (finalAuctionPrice == 0) return 0;
// if auction soldout, check
if (auctionSoldout && finalAuctionPrice != auctionPriceList[auctionStepList.length - 1]) {
return (finalAuctionPrice * 800) / 1000;
}
return 0.0119 ether;
}
function whitelist1Mint(
uint256 amount,
uint256 index,
address account,
bytes32[] calldata merkleProof
) public payable notPaused nonReentrant {
address wallet = _msgSender();
require(wallet == account, "error: u are not the real WL owner!");
// check time range
checkRange(0);
// EOA check
require(msg.sender == tx.origin, "error: eoa only");
// CHECK PAYMENT
require(wlPrice() * amount <= msg.value, "error: price not enough");
// CHECK REACH USER MINT CAP
require(
userStageMinted[wallet][1] + amount <= WL1_MAX_MINT,
"error: whitelist cannot mint more than MAX_MINT (1) !"
);
require(wl1Minted + amount <= WL1_SUPPLY, "error: current stage mint finished");
// 7. verify merkle proof
bool claimed = merkleVerifyAndSetClaimed(index, 1, account, merkleProof);
_safeMint(wallet, amount);
userStageMinted[wallet][1] += amount;
wl1Minted += amount;
}
function whitelistMint(
uint256 amount,
uint256 index,
address account,
bytes32[] calldata merkleProof
) public payable notPaused nonReentrant {
address wallet = _msgSender();
require(wallet == account, "error: u are not the real WL owner!");
// check time range
checkRange(1);
// EOA check
require(msg.sender == tx.origin, "error: eoa only");
// CHECK PAYMENT
require(wlPrice() * amount <= msg.value, "error: price not enough");
// CHECK REACH USER MINT CAP
require(
userStageMinted[wallet][2] + amount <= WL_MAX_MINT,
"error: whitelist cannot mint more than MAX_MINT (2) !"
);
// require(wl2Minted + amount <= WL2_SUPPLY(), "error: current stage mint finished");
// CHECK REACH CAP
require(MAX_SUPPLY >= minted + amount, "error: MAX_SUPPLY reached!");
// 7. verify merkle proof
bool claimed = merkleVerifyAndSetClaimed(index, 2, account, merkleProof);
_safeMint(wallet, amount);
userStageMinted[wallet][2] += amount;
wl2Minted += amount;
}
// auction user mint
function auctionMint(uint256 amount) public payable notPaused nonReentrant {
address wallet = _msgSender();
// EOA check
require(msg.sender == tx.origin, "error: eoa only");
// precheck and set state
auctionBeforeMint(wallet, amount, msg.value);
// just mint
_safeMint(wallet, amount);
}
function WL2_SUPPLY() public view returns (uint256) {
return MAX_SUPPLY - auctionData.minted - wl1Minted;
}
function publicSupply() public view returns (uint256) {
return MAX_SUPPLY - auctionData.minted - wl1Minted - wl2Minted;
}
function publicMint(uint256 amount) public payable notPaused nonReentrant {
address wallet = _msgSender();
// EOA check
require(msg.sender == tx.origin, "error: eoa only");
// check time range
checkRange(2);
// CHECK PAYMENT
require(wlPrice() * amount <= msg.value, "error: price not enough");
// CHECK REACH CAP
require(MAX_SUPPLY >= minted + amount, "error: MAX_SUPPLY reached!");
// CHECK REACH USER MINT CAP
require(
PUBLIC_MAX_MINT >= userStageMinted[wallet][3] + amount,
"error: u cannot mint more than PUBLIC_MAX_MINT(2) !"
);
_safeMint(wallet, amount);
publicMinted += amount;
userStageMinted[wallet][3] += amount;
}
/// rertieve if the nth tree's index has claimed
function isClaimed(uint256 index) public view returns (bool) {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
uint256 claimedWord = claimedBitMap[claimedWordIndex];
uint256 mask = (1 << claimedBitIndex);
return claimedWord & mask == mask;
}
/// set the exact pool's index was claimed
function _setClaimed(uint256 index) internal {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex);
}
// only for dev time
function verify(
bytes32 _merkleRoot,
uint256 index,
address account,
uint256 stage,
bytes32[] calldata merkleProof
) public pure returns (bool) {
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(index, account, stage));
return MerkleProof.verify(merkleProof, _merkleRoot, node);
}
/**
* @notice user claim using merkle proof, providing info to the contract
be sure,u must ensure that the account is verified to be the sender!
* @dev
* @param index the tree leaf index
* @param stage identify which stage this address in
* @param account the user address, ofcourse, it shall be the msg.sender
* @param merkleProof the tree generated proof data
*/
function merkleVerifyAndSetClaimed(
uint256 index,
uint256 stage,
address account,
bytes32[] calldata merkleProof
) internal returns (bool claimed) {
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(index, account, stage));
require(MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDistributor: Invalid proof.");
claimed = isClaimed(index);
// Mark it claimed and send the token.
if (!claimed) {
_setClaimed(index);
}
}
function _safeMint(address wallet, uint256 amount) internal override {
// mint
super._safeMint(wallet, amount);
userMinted[wallet] += amount;
minted += amount;
}
function setBurnPassMap(address _addr, bool pass) public onlyOwner {
burnPassMap[_addr] = pass;
}
function burn(uint256 tokenId, address _user) external {
require(_msgSender() == owner() || burnPassMap[_msgSender()], "error:user or contract shall not pass");
require(ownerOf(tokenId) == _user, "error:only owner can burn this token!");
_burn(tokenId);
}
function setApprovalForAll(address operator, bool approved) public override(IERC721A, ERC721A) {
super.setApprovalForAll(operator, approved);
}
function approve(address operator, uint256 tokenId) public payable override(IERC721A, ERC721A) {
super.approve(operator, tokenId);
}
struct ContractDashboard {
bool paused;
uint256 maxSupply;
uint256 totalMinted;
uint256 totalSupply;
uint256 currentStage;
// auction
uint256 price_auction;
uint256 minted_auction;
uint256 supply_auction;
uint256 user_minted_auction;
// auctionConf
uint256[] auction_price_list;
uint256[] auction_time_list;
uint256[] auction_supply_list;
// wl_1
uint256 price;
uint256 minted_wl_1;
uint256 supply_wl_1;
uint256 user_minted_wl_1;
// wl_2
uint256 minted_wl_2;
uint256 supply_wl_2;
uint256 user_minted_wl_2;
// public
uint256 minted_public;
uint256 supply_public;
uint256 user_minted_public;
// time
uint256 auctionStart;
uint256 auctionEnd;
uint256 wl1Start;
uint256 wl1End;
uint256 wl2Start;
uint256 wl2End;
uint256 publicStart;
uint256 publicEnd;
uint256 now;
uint256 userCurrentMinted;
uint256 currentRoundUserMax;
bool auctionSoldout;
}
function status(address _addr, uint256 now) public view returns (ContractDashboard memory dashboard) {
dashboard.paused = paused;
dashboard.maxSupply = MAX_SUPPLY;
dashboard.totalMinted = minted;
dashboard.totalSupply = totalSupply();
(uint256 auctionPrice, uint256 auctionSupply) = currentPriceAndSupply(block.timestamp);
dashboard.price_auction = auctionPrice;
dashboard.minted_auction = auctionData.minted;
dashboard.supply_auction = auctionSupply;
dashboard.user_minted_auction = auctionMinted[_addr];
dashboard.auction_price_list = new uint256[](auctionStepList.length);
dashboard.auction_time_list = new uint256[](auctionStepList.length);
dashboard.auction_supply_list = new uint256[](auctionStepList.length);
for (uint i = 0; i < auctionStepList.length; i++) {
dashboard.auction_price_list[i] = auctionPriceList[i];
dashboard.auction_time_list[i] = auctionStepList[i];
dashboard.auction_supply_list[i] = auctionSupplyList[i];
}
dashboard.price = wlPrice();
dashboard.minted_wl_1 = wl1Minted;
dashboard.supply_wl_1 = WL1_SUPPLY;
dashboard.user_minted_wl_1 = userStageMinted[_addr][1];
dashboard.minted_wl_2 = wl2Minted;
dashboard.supply_wl_2 = WL2_SUPPLY();
dashboard.user_minted_wl_2 = userStageMinted[_addr][2];
dashboard.minted_public = publicMinted;
dashboard.supply_public = publicSupply();
dashboard.user_minted_public = userStageMinted[_addr][3];
dashboard.auctionStart = auctionData.startTimestamp;
dashboard.auctionEnd = auctionData.finishTimestamp;
dashboard.wl1Start = timeRanges[0];
dashboard.wl1End = timeRanges[1];
dashboard.wl2Start = timeRanges[2];
dashboard.wl2End = timeRanges[3];
dashboard.publicStart = timeRanges[4];
dashboard.publicEnd = timeRanges[5];
dashboard.now = block.timestamp + 0;
dashboard.auctionSoldout = auctionSoldout;
if (block.timestamp < dashboard.auctionStart) {
dashboard.currentStage = 101;
} else if (block.timestamp < dashboard.auctionEnd && !auctionSoldout) {
dashboard.currentStage = 1;
dashboard.userCurrentMinted = dashboard.user_minted_auction;
dashboard.currentRoundUserMax = auctionData.maxBuy;
} else if (block.timestamp < dashboard.auctionEnd && auctionSoldout) {
// auction stoped
dashboard.currentStage = 102;
dashboard.userCurrentMinted = dashboard.user_minted_auction;
dashboard.currentRoundUserMax = auctionData.maxBuy;
} else if (block.timestamp < dashboard.wl1Start) {
dashboard.currentStage = 102;
dashboard.userCurrentMinted = dashboard.user_minted_auction;
dashboard.currentRoundUserMax = auctionData.maxBuy;
} else if (block.timestamp < dashboard.wl1End) {
dashboard.currentStage = 2;
dashboard.userCurrentMinted = dashboard.user_minted_wl_1;
dashboard.currentRoundUserMax = WL1_MAX_MINT;
} else if (block.timestamp < dashboard.wl2Start) {
dashboard.currentStage = 103;
dashboard.userCurrentMinted = dashboard.user_minted_wl_1;
dashboard.currentRoundUserMax = WL1_MAX_MINT;
} else if (block.timestamp < dashboard.wl2End) {
dashboard.currentStage = 3;
dashboard.userCurrentMinted = dashboard.user_minted_wl_2;
dashboard.currentRoundUserMax = WL_MAX_MINT;
} else if (block.timestamp < dashboard.publicStart) {
dashboard.currentStage = 104;
dashboard.userCurrentMinted = dashboard.user_minted_wl_2;
dashboard.currentRoundUserMax = WL_MAX_MINT;
} else if (block.timestamp < dashboard.publicEnd) {
dashboard.currentStage = 4;
dashboard.userCurrentMinted = dashboard.user_minted_public;
dashboard.currentRoundUserMax = PUBLIC_MAX_MINT;
} else {
dashboard.currentStage = 105;
dashboard.userCurrentMinted = dashboard.user_minted_public;
dashboard.currentRoundUserMax = PUBLIC_MAX_MINT;
}
return dashboard;
}
IRevealed721NFT revealedContract;
function setRevealContract(address addr) public onlyOwner {
revealedContract = IRevealed721NFT(addr);
}
function reveal(uint256[] calldata tokenIdList) public {
require(isAllowTransfer, "reveal not begin");
require(_msgSender() == tx.origin, "error: eoa only");
for (uint i = 0; i < tokenIdList.length; i++) {
uint256 tokenId = tokenIdList[i];
require(ownerOf(tokenId) == _msgSender(), "only owner can reveal");
revealedContract.revealMint(_msgSender(), tokenId);
_burn(tokenId);
}
}
function transferFrom(address from, address to, uint256 tokenId) public payable override(IERC721A, ERC721A) {
assertAllowTransfer(from, to);
super.transferFrom(from, to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId) public payable override(IERC721A, ERC721A) {
assertAllowTransfer(from, to);
super.safeTransferFrom(from, to, tokenId);
}
bool private isAllowTransfer = false;
function setAllowTransfer(bool _isAllow) public onlyOwner {
isAllowTransfer = _isAllow;
}
function assertAllowTransfer(address from, address to) internal view {
if (!isAllowTransfer) {
require(from == address(0), "transfer reach limit");
}
}
function mintTreasure(uint256 _amount,uint256 stage) public onlyOwner {
uint256 amount = _amount;
if(stage == 1) {
require(auctionRunning(),"sorry auction not running");
(uint256 newPrice, uint256 newSupply) = currentPriceAndSupply(block.timestamp);
finalAuctionPrice = newPrice;
// reach cap
if (auctionData.minted + amount >= newSupply) {
amount = newSupply - auctionData.minted;
auctionData.minted = newSupply;
auctionSoldout = true;
} else {
// not reach cap
auctionData.minted += amount;
}
}
if(stage == 2) {
checkRange(0);
if(wl1Minted + amount > WL1_SUPPLY) {
amount = WL1_SUPPLY - wl1Minted;
}
wl1Minted += amount;
}
if(stage == 3) {
checkRange(1);
wl2Minted += amount;
}
if(stage == 4) {
checkRange(2);
publicMinted += amount;
}
require(MAX_SUPPLY >= minted + amount, "error: MAX_SUPPLY reached!");
_safeMint(owner(), amount);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public payable override(IERC721A, ERC721A) {
assertAllowTransfer(from, to);
super.safeTransferFrom(from, to, tokenId, data);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC721A, ERC721A) returns (bool) {
// Supports the following `interfaceId`s:
// - IERC165: 0x01ffc9a7
// - IERC721: 0x80ac58cd
// - IERC721Metadata: 0x5b5e139f
return ERC721A.supportsInterface(interfaceId);
}
function withdraw(uint256 amount) public onlyOwner nonReentrant {
uint256 _amt = amount;
if (amount == 0) {
_amt = address(this).balance;
}
require(_amt > 0, "error:amount cannot be zero");
_widthdraw(owner(), _amt);
}
function _widthdraw(address _address, uint256 _amount) private {
(bool success, ) = _address.call{value: _amount}("");
require(success, "error:Transfer failed.");
}
}
ERC721A.sol 1091 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import './IERC721A.sol';
/**
* @dev Interface of ERC721 token receiver.
*/
interface ERC721A__IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
/**
* @title ERC721A
*
* @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
* Non-Fungible Token Standard, including the Metadata extension.
* Optimized for lower gas during batch mints.
*
* Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
* starting from `_startTokenId()`.
*
* Assumptions:
*
* - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
* - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is IERC721A {
// Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).
struct TokenApprovalRef {
address value;
}
// =============================================================
// CONSTANTS
// =============================================================
// Mask of an entry in packed address data.
uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;
// The bit position of `numberMinted` in packed address data.
uint256 private constant _BITPOS_NUMBER_MINTED = 64;
// The bit position of `numberBurned` in packed address data.
uint256 private constant _BITPOS_NUMBER_BURNED = 128;
// The bit position of `aux` in packed address data.
uint256 private constant _BITPOS_AUX = 192;
// Mask of all 256 bits in packed address data except the 64 bits for `aux`.
uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;
// The bit position of `startTimestamp` in packed ownership.
uint256 private constant _BITPOS_START_TIMESTAMP = 160;
// The bit mask of the `burned` bit in packed ownership.
uint256 private constant _BITMASK_BURNED = 1 << 224;
// The bit position of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;
// The bit mask of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;
// The bit position of `extraData` in packed ownership.
uint256 private constant _BITPOS_EXTRA_DATA = 232;
// Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;
// The mask of the lower 160 bits for addresses.
uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;
// The maximum `quantity` that can be minted with {_mintERC2309}.
// This limit is to prevent overflows on the address data entries.
// For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
// is required to cause an overflow, which is unrealistic.
uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;
// The `Transfer` event signature is given by:
// `keccak256(bytes("Transfer(address,address,uint256)"))`.
bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
// =============================================================
// STORAGE
// =============================================================
// The next token ID to be minted.
uint256 private _currentIndex;
// The number of tokens burned.
uint256 private _burnCounter;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned.
// See {_packedOwnershipOf} implementation for details.
//
// Bits Layout:
// - [0..159] `addr`
// - [160..223] `startTimestamp`
// - [224] `burned`
// - [225] `nextInitialized`
// - [232..255] `extraData`
mapping(uint256 => uint256) private _packedOwnerships;
// Mapping owner address to address data.
//
// Bits Layout:
// - [0..63] `balance`
// - [64..127] `numberMinted`
// - [128..191] `numberBurned`
// - [192..255] `aux`
mapping(address => uint256) private _packedAddressData;
// Mapping from token ID to approved address.
mapping(uint256 => TokenApprovalRef) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// =============================================================
// CONSTRUCTOR
// =============================================================
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
}
// =============================================================
// TOKEN COUNTING OPERATIONS
// =============================================================
/**
* @dev Returns the starting token ID.
* To change the starting token ID, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev Returns the next token ID to be minted.
*/
function _nextTokenId() internal view virtual returns (uint256) {
return _currentIndex;
}
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() public view virtual override returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than `_currentIndex - _startTokenId()` times.
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
/**
* @dev Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view virtual returns (uint256) {
// Counter underflow is impossible as `_currentIndex` does not decrement,
// and it is initialized to `_startTokenId()`.
unchecked {
return _currentIndex - _startTokenId();
}
}
/**
* @dev Returns the total number of tokens burned.
*/
function _totalBurned() internal view virtual returns (uint256) {
return _burnCounter;
}
// =============================================================
// ADDRESS DATA OPERATIONS
// =============================================================
/**
* @dev Returns the number of tokens in `owner`'s account.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
}
/**
* Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
* If there are multiple variables, please pack them into a uint64.
*/
function _setAux(address owner, uint64 aux) internal virtual {
uint256 packed = _packedAddressData[owner];
uint256 auxCasted;
// Cast `aux` with assembly to avoid redundant masking.
assembly {
auxCasted := aux
}
packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
_packedAddressData[owner] = packed;
}
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
// The interface IDs are constants representing the first 4 bytes
// of the XOR of all function selectors in the interface.
// See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
// (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
return
interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
}
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @dev Returns the token collection name.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the token collection symbol.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, it can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
// =============================================================
// OWNERSHIPS OPERATIONS
// =============================================================
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
return address(uint160(_packedOwnershipOf(tokenId)));
}
/**
* @dev Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around over time.
*/
function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnershipOf(tokenId));
}
/**
* @dev Returns the unpacked `TokenOwnership` struct at `index`.
*/
function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnerships[index]);
}
/**
* @dev Initializes the ownership slot minted at `index` for efficiency purposes.
*/
function _initializeOwnershipAt(uint256 index) internal virtual {
if (_packedOwnerships[index] == 0) {
_packedOwnerships[index] = _packedOwnershipOf(index);
}
}
/**
* Returns the packed ownership data of `tokenId`.
*/
function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr)
if (curr < _currentIndex) {
uint256 packed = _packedOwnerships[curr];
// If not burned.
if (packed & _BITMASK_BURNED == 0) {
// Invariant:
// There will always be an initialized ownership slot
// (i.e. `ownership.addr != address(0) && ownership.burned == false`)
// before an unintialized ownership slot
// (i.e. `ownership.addr == address(0) && ownership.burned == false`)
// Hence, `curr` will not underflow.
//
// We can directly compare the packed value.
// If the address is zero, packed will be zero.
while (packed == 0) {
packed = _packedOwnerships[--curr];
}
return packed;
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev Returns the unpacked `TokenOwnership` struct from `packed`.
*/
function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
ownership.addr = address(uint160(packed));
ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
ownership.burned = packed & _BITMASK_BURNED != 0;
ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
}
/**
* @dev Packs ownership data into a single uint256.
*/
function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
}
}
/**
* @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
*/
function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
// For branchless setting of the `nextInitialized` flag.
assembly {
// `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
}
}
// =============================================================
// APPROVAL OPERATIONS
// =============================================================
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the
* zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) public payable virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId].value;
}
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom}
* for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_operatorApprovals[_msgSenderERC721A()][operator] = approved;
emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
}
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted. See {_mint}.
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return
_startTokenId() <= tokenId &&
tokenId < _currentIndex && // If within bounds,
_packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
}
/**
* @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
*/
function _isSenderApprovedOrOwner(
address approvedAddress,
address owner,
address msgSender
) private pure returns (bool result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
msgSender := and(msgSender, _BITMASK_ADDRESS)
// `msgSender == owner || msgSender == approvedAddress`.
result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
}
}
/**
* @dev Returns the storage slot and value for the approved address of `tokenId`.
*/
function _getApprovedSlotAndAddress(uint256 tokenId)
private
view
returns (uint256 approvedAddressSlot, address approvedAddress)
{
TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
// The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.
assembly {
approvedAddressSlot := tokenApproval.slot
approvedAddress := sload(approvedAddressSlot)
}
}
// =============================================================
// TRANSFER OPERATIONS
// =============================================================
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token
* by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public payable virtual override {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
unchecked {
// We can directly increment and decrement the balances.
--_packedAddressData[from]; // Updates: `balance -= 1`.
++_packedAddressData[to]; // Updates: `balance += 1`.
// Updates:
// - `address` to the next owner.
// - `startTimestamp` to the timestamp of transfering.
// - `burned` to `false`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
to,
_BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public payable virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token
* by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement
* {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public payable virtual override {
transferFrom(from, to, tokenId);
if (to.code.length != 0)
if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Hook that is called before a set of serially-ordered token IDs
* are about to be transferred. This includes minting.
* And also called before burning one token.
*
* `startTokenId` - the first token ID to be transferred.
* `quantity` - the amount to be transferred.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token IDs
* have been transferred. This includes minting.
* And also called after one token has been burned.
*
* `startTokenId` - the first token ID to be transferred.
* `quantity` - the amount to be transferred.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
* transferred to `to`.
* - When `from` is zero, `tokenId` has been minted for `to`.
* - When `to` is zero, `tokenId` has been burned by `from`.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* `from` - Previous owner of the given token ID.
* `to` - Target address that will receive the token.
* `tokenId` - Token ID to be transferred.
* `_data` - Optional data to send along with the call.
*
* Returns whether the call correctly returned the expected magic value.
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
bytes4 retval
) {
return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
// =============================================================
// MINT OPERATIONS
// =============================================================
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event for each mint.
*/
function _mint(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// `balance` and `numberMinted` have a maximum limit of 2**64.
// `tokenId` has a maximum limit of 2**256.
unchecked {
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
uint256 toMasked;
uint256 end = startTokenId + quantity;
// Use assembly to loop and emit the `Transfer` event for gas savings.
// The duplicated `log4` removes an extra check and reduces stack juggling.
// The assembly, together with the surrounding Solidity code, have been
// delicately arranged to nudge the compiler into producing optimized opcodes.
assembly {
// Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
toMasked := and(to, _BITMASK_ADDRESS)
// Emit the `Transfer` event.
log4(
0, // Start of data (0, since no data).
0, // End of data (0, since no data).
_TRANSFER_EVENT_SIGNATURE, // Signature.
0, // `address(0)`.
toMasked, // `to`.
startTokenId // `tokenId`.
)
// The `iszero(eq(,))` check ensures that large values of `quantity`
// that overflows uint256 will make the loop run out of gas.
// The compiler will optimize the `iszero` away for performance.
for {
let tokenId := add(startTokenId, 1)
} iszero(eq(tokenId, end)) {
tokenId := add(tokenId, 1)
} {
// Emit the `Transfer` event. Similar to above.
log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
}
}
if (toMasked == 0) revert MintToZeroAddress();
_currentIndex = end;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* This function is intended for efficient minting only during contract creation.
*
* It emits only one {ConsecutiveTransfer} as defined in
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
* instead of a sequence of {Transfer} event(s).
*
* Calling this function outside of contract creation WILL make your contract
* non-compliant with the ERC721 standard.
* For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
* {ConsecutiveTransfer} event is only permissible during contract creation.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {ConsecutiveTransfer} event.
*/
function _mintERC2309(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are unrealistic due to the above check for `quantity` to be below the limit.
unchecked {
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);
_currentIndex = startTokenId + quantity;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement
* {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* See {_mint}.
*
* Emits a {Transfer} event for each mint.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
_mint(to, quantity);
unchecked {
if (to.code.length != 0) {
uint256 end = _currentIndex;
uint256 index = end - quantity;
do {
if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (index < end);
// Reentrancy protection.
if (_currentIndex != end) revert();
}
}
}
/**
* @dev Equivalent to `_safeMint(to, quantity, '')`.
*/
function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, '');
}
// =============================================================
// BURN OPERATIONS
// =============================================================
/**
* @dev Equivalent to `_burn(tokenId, false)`.
*/
function _burn(uint256 tokenId) internal virtual {
_burn(tokenId, false);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
address from = address(uint160(prevOwnershipPacked));
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
if (approvalCheck) {
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
unchecked {
// Updates:
// - `balance -= 1`.
// - `numberBurned += 1`.
//
// We can directly decrement the balance, and increment the number burned.
// This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
_packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;
// Updates:
// - `address` to the last owner.
// - `startTimestamp` to the timestamp of burning.
// - `burned` to `true`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
from,
(_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
// =============================================================
// EXTRA DATA OPERATIONS
// =============================================================
/**
* @dev Directly sets the extra data for the ownership data `index`.
*/
function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
uint256 packed = _packedOwnerships[index];
if (packed == 0) revert OwnershipNotInitializedForExtraData();
uint256 extraDataCasted;
// Cast `extraData` with assembly to avoid redundant masking.
assembly {
extraDataCasted := extraData
}
packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
_packedOwnerships[index] = packed;
}
/**
* @dev Called during each token transfer to set the 24bit `extraData` field.
* Intended to be overridden by the cosumer contract.
*
* `previousExtraData` - the value of `extraData` before transfer.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _extraData(
address from,
address to,
uint24 previousExtraData
) internal view virtual returns (uint24) {}
/**
* @dev Returns the next extra data for the packed ownership data.
* The returned result is shifted into position.
*/
function _nextExtraData(
address from,
address to,
uint256 prevOwnershipPacked
) private view returns (uint256) {
uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
}
// =============================================================
// OTHER OPERATIONS
// =============================================================
/**
* @dev Returns the message sender (defaults to `msg.sender`).
*
* If you are writing GSN compatible contracts, you need to override this function.
*/
function _msgSenderERC721A() internal view virtual returns (address) {
return msg.sender;
}
/**
* @dev Converts a uint256 to its ASCII string decimal representation.
*/
function _toString(uint256 value) internal pure virtual returns (string memory str) {
assembly {
// The maximum value of a uint256 contains 78 digits (1 byte per digit), but
// we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
// We will need 1 word for the trailing zeros padding, 1 word for the length,
// and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
let m := add(mload(0x40), 0xa0)
// Update the free memory pointer to allocate.
mstore(0x40, m)
// Assign the `str` to the end.
str := sub(m, 0x20)
// Zeroize the slot after the string.
mstore(str, 0)
// Cache the end of the memory to calculate the length later.
let end := str
// We write the string from rightmost digit to leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
// prettier-ignore
for { let temp := value } 1 {} {
str := sub(str, 1)
// Write the character to the pointer.
// The ASCII index of the '0' character is 48.
mstore8(str, add(48, mod(temp, 10)))
// Keep dividing `temp` until zero.
temp := div(temp, 10)
// prettier-ignore
if iszero(temp) { break }
}
let length := sub(end, str)
// Move the pointer 32 bytes leftwards to make room for the length.
str := sub(str, 0x20)
// Store the length.
mstore(str, length)
}
}
}
IERC721A.sol 282 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs
pragma solidity ^0.8.4;
/**
* @dev Interface of ERC721A.
*/
interface IERC721A {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* Cannot query the balance for the zero address.
*/
error BalanceQueryForZeroAddress();
/**
* Cannot mint to the zero address.
*/
error MintToZeroAddress();
/**
* The quantity of tokens minted must be more than zero.
*/
error MintZeroQuantity();
/**
* The token does not exist.
*/
error OwnerQueryForNonexistentToken();
/**
* The caller must own the token or be an approved operator.
*/
error TransferCallerNotOwnerNorApproved();
/**
* The token must be owned by `from`.
*/
error TransferFromIncorrectOwner();
/**
* Cannot safely transfer to a contract that does not implement the
* ERC721Receiver interface.
*/
error TransferToNonERC721ReceiverImplementer();
/**
* Cannot transfer to the zero address.
*/
error TransferToZeroAddress();
/**
* The token does not exist.
*/
error URIQueryForNonexistentToken();
/**
* The `quantity` minted with ERC2309 exceeds the safety limit.
*/
error MintERC2309QuantityExceedsLimit();
/**
* The `extraData` cannot be set on an unintialized ownership slot.
*/
error OwnershipNotInitializedForExtraData();
// =============================================================
// STRUCTS
// =============================================================
struct TokenOwnership {
// The address of the owner.
address addr;
// Stores the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
// Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
uint24 extraData;
}
// =============================================================
// TOKEN COUNTERS
// =============================================================
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() external view returns (uint256);
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
// =============================================================
// IERC721
// =============================================================
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables
* (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in `owner`'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`,
* checking first that contract recipients are aware of the ERC721 protocol
* to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move
* this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement
* {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external payable;
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom}
* whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token
* by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @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 payable;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom}
* for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
// =============================================================
// IERC2309
// =============================================================
/**
* @dev Emitted when tokens in `fromTokenId` to `toTokenId`
* (inclusive) is transferred from `from` to `to`, as defined in the
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
*
* See {_mintERC2309} for more details.
*/
event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}
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;
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IRevealed721NFT.sol 9 lines
// contracts/MyNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
interface IRevealed721NFT is IERC721 {
function revealMint(address wallet, uint256 tokenId) external;
}
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 "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* 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);
}
ERC721AQueryable.sol 178 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import './IERC721AQueryable.sol';
import '../ERC721A.sol';
/**
* @title ERC721AQueryable.
*
* @dev ERC721A subclass with convenience query functions.
*/
abstract contract ERC721AQueryable is ERC721A, IERC721AQueryable {
/**
* @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.
*
* If the `tokenId` is out of bounds:
*
* - `addr = address(0)`
* - `startTimestamp = 0`
* - `burned = false`
* - `extraData = 0`
*
* If the `tokenId` is burned:
*
* - `addr = <Address of owner before token was burned>`
* - `startTimestamp = <Timestamp when token was burned>`
* - `burned = true`
* - `extraData = <Extra data when token was burned>`
*
* Otherwise:
*
* - `addr = <Address of owner>`
* - `startTimestamp = <Timestamp of start of ownership>`
* - `burned = false`
* - `extraData = <Extra data at start of ownership>`
*/
function explicitOwnershipOf(uint256 tokenId) public view virtual override returns (TokenOwnership memory) {
TokenOwnership memory ownership;
if (tokenId < _startTokenId() || tokenId >= _nextTokenId()) {
return ownership;
}
ownership = _ownershipAt(tokenId);
if (ownership.burned) {
return ownership;
}
return _ownershipOf(tokenId);
}
/**
* @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order.
* See {ERC721AQueryable-explicitOwnershipOf}
*/
function explicitOwnershipsOf(uint256[] calldata tokenIds)
external
view
virtual
override
returns (TokenOwnership[] memory)
{
unchecked {
uint256 tokenIdsLength = tokenIds.length;
TokenOwnership[] memory ownerships = new TokenOwnership[](tokenIdsLength);
for (uint256 i; i != tokenIdsLength; ++i) {
ownerships[i] = explicitOwnershipOf(tokenIds[i]);
}
return ownerships;
}
}
/**
* @dev Returns an array of token IDs owned by `owner`,
* in the range [`start`, `stop`)
* (i.e. `start <= tokenId < stop`).
*
* This function allows for tokens to be queried if the collection
* grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
*
* Requirements:
*
* - `start < stop`
*/
function tokensOfOwnerIn(
address owner,
uint256 start,
uint256 stop
) external view virtual override returns (uint256[] memory) {
unchecked {
if (start >= stop) revert InvalidQueryRange();
uint256 tokenIdsIdx;
uint256 stopLimit = _nextTokenId();
// Set `start = max(start, _startTokenId())`.
if (start < _startTokenId()) {
start = _startTokenId();
}
// Set `stop = min(stop, stopLimit)`.
if (stop > stopLimit) {
stop = stopLimit;
}
uint256 tokenIdsMaxLength = balanceOf(owner);
// Set `tokenIdsMaxLength = min(balanceOf(owner), stop - start)`,
// to cater for cases where `balanceOf(owner)` is too big.
if (start < stop) {
uint256 rangeLength = stop - start;
if (rangeLength < tokenIdsMaxLength) {
tokenIdsMaxLength = rangeLength;
}
} else {
tokenIdsMaxLength = 0;
}
uint256[] memory tokenIds = new uint256[](tokenIdsMaxLength);
if (tokenIdsMaxLength == 0) {
return tokenIds;
}
// We need to call `explicitOwnershipOf(start)`,
// because the slot at `start` may not be initialized.
TokenOwnership memory ownership = explicitOwnershipOf(start);
address currOwnershipAddr;
// If the starting slot exists (i.e. not burned), initialize `currOwnershipAddr`.
// `ownership.address` will not be zero, as `start` is clamped to the valid token ID range.
if (!ownership.burned) {
currOwnershipAddr = ownership.addr;
}
for (uint256 i = start; i != stop && tokenIdsIdx != tokenIdsMaxLength; ++i) {
ownership = _ownershipAt(i);
if (ownership.burned) {
continue;
}
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
// Downsize the array to fit.
assembly {
mstore(tokenIds, tokenIdsIdx)
}
return tokenIds;
}
}
/**
* @dev Returns an array of token IDs owned by `owner`.
*
* This function scans the ownership mapping and is O(`totalSupply`) in complexity.
* It is meant to be called off-chain.
*
* See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
* multiple smaller scans if the collection is large enough to cause
* an out-of-gas error (10K collections should be fine).
*/
function tokensOfOwner(address owner) external view virtual override returns (uint256[] memory) {
unchecked {
uint256 tokenIdsIdx;
address currOwnershipAddr;
uint256 tokenIdsLength = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
TokenOwnership memory ownership;
for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
ownership = _ownershipAt(i);
if (ownership.burned) {
continue;
}
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
return tokenIds;
}
}
}
IERC721AQueryable.sol 79 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import '../IERC721A.sol';
/**
* @dev Interface of ERC721AQueryable.
*/
interface IERC721AQueryable is IERC721A {
/**
* Invalid query range (`start` >= `stop`).
*/
error InvalidQueryRange();
/**
* @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.
*
* If the `tokenId` is out of bounds:
*
* - `addr = address(0)`
* - `startTimestamp = 0`
* - `burned = false`
* - `extraData = 0`
*
* If the `tokenId` is burned:
*
* - `addr = <Address of owner before token was burned>`
* - `startTimestamp = <Timestamp when token was burned>`
* - `burned = true`
* - `extraData = <Extra data when token was burned>`
*
* Otherwise:
*
* - `addr = <Address of owner>`
* - `startTimestamp = <Timestamp of start of ownership>`
* - `burned = false`
* - `extraData = <Extra data at start of ownership>`
*/
function explicitOwnershipOf(uint256 tokenId) external view returns (TokenOwnership memory);
/**
* @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order.
* See {ERC721AQueryable-explicitOwnershipOf}
*/
function explicitOwnershipsOf(uint256[] memory tokenIds) external view returns (TokenOwnership[] memory);
/**
* @dev Returns an array of token IDs owned by `owner`,
* in the range [`start`, `stop`)
* (i.e. `start <= tokenId < stop`).
*
* This function allows for tokens to be queried if the collection
* grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
*
* Requirements:
*
* - `start < stop`
*/
function tokensOfOwnerIn(
address owner,
uint256 start,
uint256 stop
) external view returns (uint256[] memory);
/**
* @dev Returns an array of token IDs owned by `owner`.
*
* This function scans the ownership mapping and is O(`totalSupply`) in complexity.
* It is meant to be called off-chain.
*
* See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
* multiple smaller scans if the collection is large enough to cause
* an out-of-gas error (10K collections should be fine).
*/
function tokensOfOwner(address owner) external view returns (uint256[] memory);
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
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);
}
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)
}
}
}
Read Contract
BASE_URI 0xdbddb26a → string
MAX_SUPPLY 0x32cb6b0c → uint256
PUBLIC_MAX_MINT 0xa7346780 → uint256
PUBLIC_PRICE 0x611f3f10 → uint256
WL1_MAX_MINT 0x2d3e7ac5 → uint256
WL1_SUPPLY 0x9f272ce0 → uint256
WL2_SUPPLY 0x1ad21333 → uint256
WL_MAX_MINT 0x0d0f38b8 → uint256
auctionData 0xb237b173 → uint256, uint256, uint256, uint256, uint256, uint256
auctionMinted 0x2a00648d → uint256
auctionPriceList 0x050a0bc5 → uint256
auctionRunning 0xd51b817a → bool
auctionSoldout 0xa1e14411 → bool
auctionStepList 0x1a63b587 → uint256
auctionSupplyList 0xc863c394 → uint256
balanceOf 0x70a08231 → uint256
burnPassMap 0x4de0d5eb → bool
currentPriceAndSupply 0x519b05ba → uint256, uint256
explicitOwnershipOf 0xc23dc68f → tuple
explicitOwnershipsOf 0x5bbb2177 → tuple[]
finalAuctionPrice 0xbb1fb1db → uint256
getApproved 0x081812fc → address
getAuctionPriceConfig 0x939f96be → uint256[], uint256[], uint256[]
isApprovedForAll 0xe985e9c5 → bool
isClaimed 0x9e34070f → bool
merkleRoot 0x2eb4a7ab → bytes32
minted 0x4f02c420 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
publicMinted 0xa4f4f8af → uint256
publicSupply 0x5e84d723 → uint256
status 0xadc25c01 → tuple
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
timeRanges 0xa546615b → uint256
tokenURI 0xc87b56dd → string
tokensOfOwner 0x8462151c → uint256[]
tokensOfOwnerIn 0x99a2557a → uint256[]
totalSupply 0x18160ddd → uint256
userMinted 0x1aa5e872 → uint256
userStageMinted 0xb0440a36 → uint256
verify 0xe719ca9c → bool
wl1Minted 0xefdf67ca → uint256
wl2Minted 0x808b9308 → uint256
wlPrice 0xc7f8d01a → uint256
Write Contract 27 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address operator
uint256 tokenId
auctionMint 0x4d3554c3
uint256 amount
burn 0xfcd3533c
uint256 tokenId
address _user
checkRange 0x4f828530
uint256 index
initAuction 0x56e1d5e6
uint256 initialSupply
uint256 startTimestamp
uint256 finishTimestamp
uint256 initialPrice
uint256 maxBuy
initAuctionPrice 0x96267715
uint256[] _auctionStepList
uint256[] _auctionPriceList
uint256[] _auctionSupplyList
initialize 0x8129fc1c
No parameters
mintTreasure 0x5b156934
uint256 _amount
uint256 stage
publicMint 0x2db11544
uint256 amount
renounceOwnership 0x715018a6
No parameters
reveal 0xb93f208a
uint256[] tokenIdList
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes data
setAllowTransfer 0x0b81e216
bool _isAllow
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseUri 0xa0bcfc7f
string uri
setBurnPassMap 0xdb7aa273
address _addr
bool pass
setMerkleRoot 0x7cb64759
bytes32 _root
setPause 0xbedb86fb
bool _paused
setPublicPrice 0xc6275255
uint256 newPrice
setRevealContract 0xf0e9b29a
address addr
setTimeRanges 0xe14a0b37
uint256[] ranges
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
whitelist1Mint 0x1a5d6249
uint256 amount
uint256 index
address account
bytes32[] merkleProof
whitelistMint 0x3c739ed3
uint256 amount
uint256 index
address account
bytes32[] merkleProof
withdraw 0x2e1a7d4d
uint256 amount
Recent Transactions
No transactions found for this address