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