Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x249aeAa7fA06a63Ea5389b72217476db881294df
Balance 0 ETH
Nonce 1
Code Size 17055 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

17055 bytes
0x60806040526004361061036b5760003560e01c806370dca974116101c6578063a217fddf116100f7578063c634b78e11610095578063d547741f1161006f578063d547741f146109b4578063d5abeb01146109d4578063e985e9c514610a08578063f2fde38b14610a5157600080fd5b8063c634b78e1461095f578063c87b56dd1461097f578063cfdbf2541461099f57600080fd5b8063b0bf74e3116100d1578063b0bf74e3146108f9578063b3ab66b014610919578063b88d4fde1461092c578063c0612b7b1461094c57600080fd5b8063a217fddf146108ae578063a22cb465146108c3578063a7f949b1146108e357600080fd5b80638da5cb5b1161016457806395d89b411161013e57806395d89b41146108435780639a19c7b0146108585780639ab06fcb146108785780639b6860c81461089857600080fd5b80638da5cb5b146107e557806391c152461461080357806391d148541461082357600080fd5b806376e8687c116101a057806376e8687c1461076357806379f67c5a146107905780638456cb59146107b05780638975ede2146107c557600080fd5b806370dca9741461070e578063715018a61461072e57806371c5ecb11461074357600080fd5b80633ccfd60b116102a057806355f804b31161023e5780636352211e116102185780636352211e146106a6578063673ef0a7146106c65780636c0360eb146106d957806370a08231146106ee57600080fd5b806355f804b31461064e578063568af0811461066e5780635c975abb1461068e57600080fd5b806342f6487a1161027a57806342f6487a146105ce5780634f6ccce7146105ee57806351cff8d91461060e578063525f8a5c1461062e57600080fd5b80633ccfd60b146105845780633f4ba83a1461059957806342842e0e146105ae57600080fd5b80631cbaee2d1161030d578063248a9ca3116102e7578063248a9ca3146104f45780632f2ff15d146105245780632f745c591461054457806336568abe1461056457600080fd5b80631cbaee2d1461049e5780631deede8f146104b457806323b872dd146104d457600080fd5b8063095ea7b311610349578063095ea7b3146103ff57806317957f841461042157806318160ddd1461045c5780631a9143891461047157600080fd5b806301ffc9a71461037057806306fdde03146103a5578063081812fc146103c7575b600080fd5b34801561037c57600080fd5b5061039061038b3660046137c8565b610a71565b60405190151581526020015b60405180910390f35b3480156103b157600080fd5b506103ba610a9c565b60405161039c919061383d565b3480156103d357600080fd5b506103e76103e2366004613850565b610b2e565b6040516001600160a01b03909116815260200161039c565b34801561040b57600080fd5b5061041f61041a36600461387e565b610bbe565b005b34801561042d57600080fd5b5061044e61043c3660046138aa565b601a6020526000908152604090205481565b60405190815260200161039c565b34801561046857600080fd5b5060015461044e565b34801561047d57600080fd5b5061044e61048c3660046138aa565b601b6020526000908152604090205481565b3480156104aa57600080fd5b5061044e600d5481565b3480156104c057600080fd5b5061044e6104cf366004613850565b610cd5565b3480156104e057600080fd5b5061041f6104ef3660046138c7565b610cec565b34801561050057600080fd5b5061044e61050f366004613850565b60009081526009602052604090206001015490565b34801561053057600080fd5b5061041f61053f366004613908565b610cf7565b34801561055057600080fd5b5061044e61055f36600461387e565b610d1c565b34801561057057600080fd5b5061041f61057f366004613908565b610e81565b34801561059057600080fd5b5061041f610eff565b3480156105a557600080fd5b5061041f610f1f565b3480156105ba57600080fd5b5061041f6105c93660046138c7565b610f32565b3480156105da57600080fd5b50600c546103e7906001600160a01b031681565b3480156105fa57600080fd5b5061044e610609366004613850565b610f4d565b34801561061a57600080fd5b5061041f6106293660046138aa565b610fb6565b34801561063a57600080fd5b5061041f610649366004613850565b611083565b34801561065a57600080fd5b5061041f610669366004613938565b611094565b34801561067a57600080fd5b5061041f6106893660046139f4565b6110b2565b34801561069a57600080fd5b5060085460ff16610390565b3480156106b257600080fd5b506103e76106c1366004613850565b61138b565b61041f6106d4366004613850565b61139d565b3480156106e557600080fd5b506103ba611645565b3480156106fa57600080fd5b5061044e6107093660046138aa565b6116d3565b34801561071a57600080fd5b50600b546103e7906001600160a01b031681565b34801561073a57600080fd5b5061041f611764565b34801561074f57600080fd5b5061044e61075e366004613850565b61179a565b34801561076f57600080fd5b5061044e61077e366004613850565b60196020526000908152604090205481565b34801561079c57600080fd5b5061041f6107ab3660046139f4565b6117aa565b3480156107bc57600080fd5b5061041f6118fd565b3480156107d157600080fd5b5061041f6107e0366004613a5f565b611910565b3480156107f157600080fd5b506000546001600160a01b03166103e7565b34801561080f57600080fd5b5061044e61081e3660046138aa565b611928565b34801561082f57600080fd5b5061039061083e366004613908565b611a61565b34801561084f57600080fd5b506103ba611a8c565b34801561086457600080fd5b5061041f6108733660046138aa565b611a9b565b34801561088457600080fd5b5061041f6108933660046138aa565b611ad0565b3480156108a457600080fd5b5061044e60175481565b3480156108ba57600080fd5b5061044e600081565b3480156108cf57600080fd5b5061041f6108de366004613a95565b611afe565b3480156108ef57600080fd5b5061044e60165481565b34801561090557600080fd5b5061041f6109143660046138aa565b611bc2565b61041f610927366004613850565b611bf0565b34801561093857600080fd5b5061041f610947366004613ad9565b611e2b565b61041f61095a366004613bb8565b611e5e565b34801561096b57600080fd5b5061041f61097a3660046138aa565b6121c4565b34801561098b57600080fd5b506103ba61099a366004613850565b6121f9565b3480156109ab57600080fd5b5061044e600581565b3480156109c057600080fd5b5061041f6109cf366004613908565b6122c6565b3480156109e057600080fd5b5061044e7f000000000000000000000000000000000000000000000000000000000000157c81565b348015610a1457600080fd5b50610390610a23366004613c1d565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610a5d57600080fd5b5061041f610a6c3660046138aa565b6122eb565b60006001600160e01b03198216637965db0b60e01b1480610a965750610a9682612383565b92915050565b606060028054610aab90613c4b565b80601f0160208091040260200160405190810160405280929190818152602001828054610ad790613c4b565b8015610b245780601f10610af957610100808354040283529160200191610b24565b820191906000526020600020905b815481529060010190602001808311610b0757829003601f168201915b5050505050905090565b6000610b3b826001541190565b610ba25760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b60648201526084015b60405180910390fd5b506000908152600660205260409020546001600160a01b031690565b6000610bc98261138b565b9050806001600160a01b0316836001600160a01b031603610c375760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b6064820152608401610b99565b336001600160a01b0382161480610c535750610c538133610a23565b610cc55760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c000000000000006064820152608401610b99565b610cd08383836123a8565b505050565b60128160048110610ce557600080fd5b0154905081565b610cd0838383612404565b600082815260096020526040902060010154610d12816126e7565b610cd083836126f1565b6000610d27836116d3565b8210610d805760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610b99565b6000610d8b60015490565b905060008060005b83811015610e21576000818152600460209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b03169183019190915215610de557805192505b876001600160a01b0316836001600160a01b031603610e1857868403610e1157509350610a9692505050565b6001909301925b50600101610d93565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b6064820152608401610b99565b6001600160a01b0381163314610ef15760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610b99565b610efb8282612777565b5050565b478015610f1c57600c54610f1c906001600160a01b0316826127de565b50565b6000610f2a816126e7565b610f1c6128f7565b610cd083838360405180602001604052806000815250611e2b565b6000610f5860015490565b8210610fb25760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b6064820152608401610b99565b5090565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610ffd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110219190613c7f565b90506000811161106b5760405162461bcd60e51b81526020600482015260156024820152744e6f20746f6b656e7320746f20776974686472617760581b6044820152606401610b99565b600c54610efb9083906001600160a01b03168361298a565b600061108e816126e7565b50600d55565b600061109f816126e7565b60186110ac838583613ce6565b50505050565b60006110bd816126e7565b6002600a54036110df5760405162461bcd60e51b8152600401610b9990613da5565b6002600a55836111285760405162461bcd60e51b8152602060048201526014602482015273139bc81858d8dbdd5b9d1cc81c1c9bdd9a59195960621b6044820152606401610b99565b8382146111475760405162461bcd60e51b8152600401610b9990613ddc565b60005b8481101561137e57600084848381811061116657611166613e2d565b905060200201359050600081116111bf5760405162461bcd60e51b815260206004820152601f60248201527f5175616e74697479206d7573742062652067726561746572207468616e2030006044820152606401610b99565b6111ca600a82613e59565b156112215760405162461bcd60e51b815260206004820152602160248201527f5175616e74697479206d7573742062652061206d756c7469706c65206f6620316044820152600360fc1b6064820152608401610b99565b7f000000000000000000000000000000000000000000000000000000000000157c8161124c60015490565b6112569190613e83565b11156112745760405162461bcd60e51b8152600401610b9990613e9b565b6000611281600a83613ec6565b905060006112b589898681811061129a5761129a613e2d565b90506020020160208101906112af91906138aa565b836129dc565b9050818151146112d75760405162461bcd60e51b8152600401610b9990613eda565b60005b8281101561133757600a601960008484815181106112fa576112fa613e2d565b60200260200101518152602001908152602001600020600082825461131f9190613e83565b9091555081905061132f81613f2a565b9150506112da565b5061136889898681811061134d5761134d613e2d565b905060200201602081019061136291906138aa565b84612bb2565b505050808061137690613f2a565b91505061114a565b50506001600a5550505050565b600061139682612c1a565b5192915050565b60085460ff16156113c05760405162461bcd60e51b8152600401610b9990613f43565b33803b9081156113e25760405162461bcd60e51b8152600401610b9990613f6d565b3332146114015760405162461bcd60e51b8152600401610b9990613f9b565b600060016114128262015180613fd2565b600d5461141f9190613e83565b42101561143e5760405162461bcd60e51b8152600401610b9990613ff1565b61144b8162015180613fd2565b600d546114589190613e83565b42106114765760405162461bcd60e51b8152600401610b9990614028565b6002600a54036114985760405162461bcd60e51b8152600401610b9990613da5565b6002600a9081556114a99086613e59565b156115005760405162461bcd60e51b815260206004820152602160248201527f7175616e74697479206d7573742062652061206d756c7469706c65206f6620316044820152600360fc1b6064820152608401610b99565b7f000000000000000000000000000000000000000000000000000000000000157c8561152b60015490565b6115359190613e83565b11156115535760405162461bcd60e51b8152600401610b9990613e9b565b6000856016546115639190613fd2565b9050803410156115855760405162461bcd60e51b8152600401610b9990614052565b6000611592600a88613ec6565b905060006115a033836129dc565b9050818151146115c25760405162461bcd60e51b8152600401610b9990613eda565b60005b8281101561162257600a601960008484815181106115e5576115e5613e2d565b60200260200101518152602001908152602001600020600082825461160a9190613e83565b9091555081905061161a81613f2a565b9150506115c5565b5061162d3389612bb2565b61163683612cf0565b50506001600a55505050505050565b6018805461165290613c4b565b80601f016020809104026020016040519081016040528092919081815260200182805461167e90613c4b565b80156116cb5780601f106116a0576101008083540402835291602001916116cb565b820191906000526020600020905b8154815290600101906020018083116116ae57829003601f168201915b505050505081565b60006001600160a01b03821661173f5760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610b99565b506001600160a01b03166000908152600560205260409020546001600160801b031690565b6000546001600160a01b0316331461178e5760405162461bcd60e51b8152600401610b999061407c565b6117986000612d0b565b565b600e8160048110610ce557600080fd5b60006117b5816126e7565b6002600a54036117d75760405162461bcd60e51b8152600401610b9990613da5565b6002600a55836118205760405162461bcd60e51b8152602060048201526014602482015273139bc81858d8dbdd5b9d1cc81c1c9bdd9a59195960621b6044820152606401610b99565b83821461183f5760405162461bcd60e51b8152600401610b9990613ddc565b60005b8481101561137e57600084848381811061185e5761185e613e2d565b9050602002013590507f000000000000000000000000000000000000000000000000000000000000157c8161189260015490565b61189c9190613e83565b11156118ba5760405162461bcd60e51b8152600401610b9990613e9b565b6118ea8787848181106118cf576118cf613e2d565b90506020020160208101906118e491906138aa565b82612bb2565b50806118f581613f2a565b915050611842565b6000611908816126e7565b610f1c612d5b565b600061191b816126e7565b610cd0600e836004613768565b600b546040516370a0823160e01b81526001600160a01b03838116600483015260009283929116906370a0823190602401602060405180830381865afa158015611976573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199a9190613c7f565b90506000805b82811015611a5957600b54604051632f745c5960e01b81526001600160a01b038781166004830152602482018490526000921690632f745c5990604401602060405180830381865afa1580156119fa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1e9190613c7f565b60008181526019602052604090205490915060011115611a4657611a43836001613e83565b92505b5080611a5181613f2a565b9150506119a0565b509392505050565b60009182526009602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060038054610aab90613c4b565b6000546001600160a01b03163314611ac55760405162461bcd60e51b8152600401610b999061407c565b610f1c600082612777565b6000611adb816126e7565b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b336001600160a01b03831603611b565760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c65720000000000006044820152606401610b99565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6000611bcd816126e7565b50600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60085460ff1615611c135760405162461bcd60e51b8152600401610b9990613f43565b33803b908115611c355760405162461bcd60e51b8152600401610b9990613f6d565b333214611c545760405162461bcd60e51b8152600401610b9990613f9b565b60026003611c658262015180613fd2565b600d54611c729190613e83565b421015611c915760405162461bcd60e51b8152600401610b9990613ff1565b611c9e8162015180613fd2565b600d54611cab9190613e83565b4210611cc95760405162461bcd60e51b8152600401610b9990614028565b6002600a5403611ceb5760405162461bcd60e51b8152600401610b9990613da5565b6002600a55336000908152601b6020526040902054600190611d0e908790613e83565b1115611d6e5760405162461bcd60e51b815260206004820152602960248201527f596f752063616e206f6e6c79206765742031204e4654206f6e20746865205075604482015268626c69632053616c6560b81b6064820152608401610b99565b7f000000000000000000000000000000000000000000000000000000000000157c85611d9960015490565b611da39190613e83565b1115611dc15760405162461bcd60e51b8152600401610b9990613e9b565b600085601754611dd19190613fd2565b905080341015611df35760405162461bcd60e51b8152600401610b9990614052565b336000908152601b602052604081208054889290611e12908490613e83565b90915550611e2290503387612db3565b61137e81612cf0565b611e36848484612404565b611e4284848484612dcd565b6110ac5760405162461bcd60e51b8152600401610b99906140b1565b60085460ff1615611e815760405162461bcd60e51b8152600401610b9990613f43565b33803b908115611ea35760405162461bcd60e51b8152600401610b9990613f6d565b333214611ec25760405162461bcd60e51b8152600401610b9990613f9b565b60016002611ed38262015180613fd2565b600d54611ee09190613e83565b421015611eff5760405162461bcd60e51b8152600401610b9990613ff1565b611f0c8162015180613fd2565b600d54611f199190613e83565b4210611f375760405162461bcd60e51b8152600401610b9990614028565b6002600a5403611f595760405162461bcd60e51b8152600401610b9990613da5565b6002600a5561ffff85161580611f7357508461ffff166001145b15611ffe57336000908152601a6020526040902054600190611f96908a90613e83565b1115611ff95760405162461bcd60e51b815260206004820152602c60248201527f596f752063616e206f6e6c79206765742031204e4654206f6e2074686520576860448201526b6974656c6973742053616c6560a01b6064820152608401610b99565b61207f565b336000908152601a602052604090205460029061201c908a90613e83565b111561207f5760405162461bcd60e51b815260206004820152602c60248201527f596f752063616e206f6e6c79206765742032204e4654206f6e2074686520576860448201526b6974656c6973742053616c6560a01b6064820152608401610b99565b7f000000000000000000000000000000000000000000000000000000000000157c886120aa60015490565b6120b49190613e83565b11156120d25760405162461bcd60e51b8152600401610b9990613e9b565b60008860128761ffff16600481106120ec576120ec613e2d565b01546120f89190613fd2565b90508034101561211a5760405162461bcd60e51b8152600401610b9990614052565b61213e8888600e8961ffff166004811061213657612136613e2d565b015433612ecf565b61217c5760405162461bcd60e51b815260206004820152600f60248201526e139bdd0815da1a5d195b1a5cdd1959608a1b6044820152606401610b99565b336000908152601a6020526040812080548b929061219b908490613e83565b909155506121ab9050338a612db3565b6121b481612cf0565b50506001600a5550505050505050565b6000546001600160a01b031633146121ee5760405162461bcd60e51b8152600401610b999061407c565b610f1c6000826126f1565b6060612206826001541190565b61226a5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610b99565b6000612274612f50565b9050805160000361229457604051806020016040528060008152506122bf565b8061229e84612f5f565b6040516020016122af929190614104565b6040516020818303038152906040525b9392505050565b6000828152600960205260409020600101546122e1816126e7565b610cd08383612777565b6000546001600160a01b031633146123155760405162461bcd60e51b8152600401610b999061407c565b6001600160a01b03811661237a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b99565b610f1c81612d0b565b60006001600160e01b03198216637965db0b60e01b1480610a965750610a968261305f565b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600061240f82612c1a565b80519091506000906001600160a01b0316336001600160a01b0316148061244657503361243b84610b2e565b6001600160a01b0316145b80612458575081516124589033610a23565b9050806124c25760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610b99565b846001600160a01b031682600001516001600160a01b0316146125365760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b6064820152608401610b99565b6001600160a01b03841661259a5760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610b99565b6125aa60008484600001516123a8565b6001600160a01b03858116600090815260056020908152604080832080546001600160801b03198082166001600160801b03928316600019018316179092558986168086528386208054938416938316600190810190931693909317909255888552600490935281842080546001600160e01b031916909117600160a01b426001600160401b03160217905590860180835291205490911661269d57612651816001541190565b1561269d57825160008281526004602090815260409091208054918601516001600160401b0316600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b5050505050565b610f1c81336130ca565b6126fb8282611a61565b610efb5760008281526009602090815260408083206001600160a01b03851684529091529020805460ff191660011790556127333390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6127818282611a61565b15610efb5760008281526009602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b8047101561282e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610b99565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461287b576040519150601f19603f3d011682016040523d82523d6000602084013e612880565b606091505b5050905080610cd05760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610b99565b60085460ff166129405760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b99565b6008805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610cd090849061312e565b600b546040516370a0823160e01b81526001600160a01b0384811660048301526060926000929116906370a0823190602401602060405180830381865afa158015612a2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4f9190613c7f565b90506000836001600160401b03811115612a6b57612a6b613ac3565b604051908082528060200260200182016040528015612a94578160200160208202803683370190505b509050600080612aa5600187614133565b905060005b84811015612b9757600b54604051632f745c5960e01b81526001600160a01b038a81166004830152602482018490526000921690632f745c5990604401602060405180830381865afa158015612b04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b289190613c7f565b60008181526019602052604090205490915060011115612b845780858581518110612b5557612b55613e2d565b602002602001018181525050828403612b7657849650505050505050610a96565b612b81846001613e83565b93505b5080612b8f81613f2a565b915050612aaa565b50506040805160008152602081019091529695505050505050565b60058111612bc457610efb8282612db3565b6000612bd1600583613ec6565b90506000612be0600584613e59565b905060005b82811015612c0a57612bf8856005612db3565b80612c0281613f2a565b915050612be5565b81156126e0576126e08583612db3565b6040805180820190915260008082526020820152612c39826001541190565b612c985760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b6064820152608401610b99565b815b6000818152600460209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b03169183019190915215612ce6579392505050565b5060001901612c9a565b80341115610f1c57610f1c33612d068334614133565b6127de565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60085460ff1615612d7e5760405162461bcd60e51b8152600401610b9990613f43565b6008805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861296d3390565b610efb828260405180602001604052806000815250613200565b60006001600160a01b0384163b15612ec357604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612e1190339089908890889060040161414a565b6020604051808303816000875af1925050508015612e4c575060408051601f3d908101601f19168201909252612e4991810190614187565b60015b612ea9573d808015612e7a576040519150601f19603f3d011682016040523d82523d6000602084013e612e7f565b606091505b508051600003612ea15760405162461bcd60e51b8152600401610b99906140b1565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612ec7565b5060015b949350505050565b6000612f478585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051606088901b6bffffffffffffffffffffffff19166020808301919091528251601481840301815260349092019092528051910120879250905061320d565b95945050505050565b606060188054610aab90613c4b565b606081600003612f865750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612fb05780612f9a81613f2a565b9150612fa99050600a83613ec6565b9150612f8a565b6000816001600160401b03811115612fca57612fca613ac3565b6040519080825280601f01601f191660200182016040528015612ff4576020820181803683370190505b5090505b8415612ec757613009600183614133565b9150613016600a86613e59565b613021906030613e83565b60f81b81838151811061303657613036613e2d565b60200101906001600160f81b031916908160001a905350613058600a86613ec6565b9450612ff8565b60006001600160e01b031982166380ac58cd60e01b148061309057506001600160e01b03198216635b5e139f60e01b145b806130ab57506001600160e01b0319821663780e9d6360e01b145b80610a9657506301ffc9a760e01b6001600160e01b0319831614610a96565b6130d48282611a61565b610efb576130ec816001600160a01b03166014613223565b6130f7836020613223565b6040516020016131089291906141a4565b60408051601f198184030181529082905262461bcd60e51b8252610b999160040161383d565b6000613183826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166133be9092919063ffffffff16565b805190915015610cd057808060200190518101906131a19190614219565b610cd05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b99565b610cd083838360016133cd565b60008261321a8584613592565b14949350505050565b60606000613232836002613fd2565b61323d906002613e83565b6001600160401b0381111561325457613254613ac3565b6040519080825280601f01601f19166020018201604052801561327e576020820181803683370190505b509050600360fc1b8160008151811061329957613299613e2d565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106132c8576132c8613e2d565b60200101906001600160f81b031916908160001a90535060006132ec846002613fd2565b6132f7906001613e83565b90505b600181111561336f576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061332b5761332b613e2d565b1a60f81b82828151811061334157613341613e2d565b60200101906001600160f81b031916908160001a90535060049490941c9361336881614236565b90506132fa565b5083156122bf5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610b99565b6060612ec784846000856135fe565b6001546001600160a01b0385166134305760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610b99565b836000036134915760405162461bcd60e51b815260206004820152602860248201527f455243373231413a207175616e74697479206d75737420626520677265617465604482015267072207468616e20360c41b6064820152608401610b99565b6001600160a01b03851660008181526005602090815260408083208054600160801b6001600160801b031982166001600160801b039283168c01831690811782900483168c01909216021790558483526004909152812080546001600160e01b031916909217600160a01b426001600160401b0316021790915581905b858110156135895760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4831561357d576135616000888488612dcd565b61357d5760405162461bcd60e51b8152600401610b99906140b1565b6001918201910161350e565b506001556126e0565b600081815b8451811015611a595760008582815181106135b4576135b4613e2d565b602002602001015190508083116135da57600083815260208290526040902092506135eb565b600081815260208490526040902092505b50806135f681613f2a565b915050613597565b60608247101561365f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610b99565b6001600160a01b0385163b6136b65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b99565b600080866001600160a01b031685876040516136d2919061424d565b60006040518083038185875af1925050503d806000811461370f576040519150601f19603f3d011682016040523d82523d6000602084013e613714565b606091505b509150915061372482828661372f565b979650505050505050565b6060831561373e5750816122bf565b82511561374e5782518084602001fd5b8160405162461bcd60e51b8152600401610b99919061383d565b8260048101928215613796579160200282015b8281111561379657823582559160200191906001019061377b565b50610fb29291505b80821115610fb2576000815560010161379e565b6001600160e01b031981168114610f1c57600080fd5b6000602082840312156137da57600080fd5b81356122bf816137b2565b60005b838110156138005781810151838201526020016137e8565b838111156110ac5750506000910152565b600081518084526138298160208601602086016137e5565b601f01601f19169290920160200192915050565b6020815260006122bf6020830184613811565b60006020828403121561386257600080fd5b5035919050565b6001600160a01b0381168114610f1c57600080fd5b6000806040838503121561389157600080fd5b823561389c81613869565b946020939093013593505050565b6000602082840312156138bc57600080fd5b81356122bf81613869565b6000806000606084860312156138dc57600080fd5b83356138e781613869565b925060208401356138f781613869565b929592945050506040919091013590565b6000806040838503121561391b57600080fd5b82359150602083013561392d81613869565b809150509250929050565b6000806020838503121561394b57600080fd5b82356001600160401b038082111561396257600080fd5b818501915085601f83011261397657600080fd5b81358181111561398557600080fd5b86602082850101111561399757600080fd5b60209290920196919550909350505050565b60008083601f8401126139bb57600080fd5b5081356001600160401b038111156139d257600080fd5b6020830191508360208260051b85010111156139ed57600080fd5b9250929050565b60008060008060408587031215613a0a57600080fd5b84356001600160401b0380821115613a2157600080fd5b613a2d888389016139a9565b90965094506020870135915080821115613a4657600080fd5b50613a53878288016139a9565b95989497509550505050565b600060808284031215613a7157600080fd5b82608083011115613a8157600080fd5b50919050565b8015158114610f1c57600080fd5b60008060408385031215613aa857600080fd5b8235613ab381613869565b9150602083013561392d81613a87565b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215613aef57600080fd5b8435613afa81613869565b93506020850135613b0a81613869565b92506040850135915060608501356001600160401b0380821115613b2d57600080fd5b818701915087601f830112613b4157600080fd5b813581811115613b5357613b53613ac3565b604051601f8201601f19908116603f01168101908382118183101715613b7b57613b7b613ac3565b816040528281528a6020848701011115613b9457600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060008060608587031215613bce57600080fd5b8435935060208501356001600160401b03811115613beb57600080fd5b613bf7878288016139a9565b909450925050604085013561ffff81168114613c1257600080fd5b939692955090935050565b60008060408385031215613c3057600080fd5b8235613c3b81613869565b9150602083013561392d81613869565b600181811c90821680613c5f57607f821691505b602082108103613a8157634e487b7160e01b600052602260045260246000fd5b600060208284031215613c9157600080fd5b5051919050565b601f821115610cd057600081815260208120601f850160051c81016020861015613cbf5750805b601f850160051c820191505b81811015613cde57828155600101613ccb565b505050505050565b6001600160401b03831115613cfd57613cfd613ac3565b613d1183613d0b8354613c4b565b83613c98565b6000601f841160018114613d455760008515613d2d5750838201355b600019600387901b1c1916600186901b1783556126e0565b600083815260209020601f19861690835b82811015613d765786850135825560209485019460019092019101613d56565b5086821015613d935760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526031908201527f4163636f756e747320616e64207175616e746974696573206d757374206861766040820152700ca40e8d0ca40e6c2daca40d8cadccee8d607b1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600082613e6857613e68613e43565b500690565b634e487b7160e01b600052601160045260246000fd5b60008219821115613e9657613e96613e6d565b500190565b60208082526011908201527013585e081cdd5c1c1b1e48195e18d95959607a1b604082015260600190565b600082613ed557613ed5613e43565b500490565b60208082526030908201527f476f6c646d656d62657220646f6573206e6f74206f776e20656e6f756768207660408201526f6572696669656420537461724e46547360801b606082015260800190565b600060018201613f3c57613f3c613e6d565b5060010190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526014908201527318dbdb9d1c9858dd081b9bdd08185b1b1bddd95960621b604082015260600190565b6020808252601a908201527f70726f787920636f6e7472616374206e6f7420616c6c6f776564000000000000604082015260600190565b6000816000190483118215151615613fec57613fec613e6d565b500290565b60208082526018908201527f73616c6520686173206e6f742073746172746564207965740000000000000000604082015260600190565b60208082526010908201526f1cd85b19481a5cc8199a5b9a5cda195960821b604082015260600190565b60208082526010908201526f4e6f7420656e6f7567682066756e647360801b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b600083516141168184602088016137e5565b83519083019061412a8183602088016137e5565b01949350505050565b60008282101561414557614145613e6d565b500390565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061417d90830184613811565b9695505050505050565b60006020828403121561419957600080fd5b81516122bf816137b2565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516141dc8160178501602088016137e5565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161420d8160288401602088016137e5565b01602801949350505050565b60006020828403121561422b57600080fd5b81516122bf81613a87565b60008161424557614245613e6d565b506000190190565b6000825161425f8184602087016137e5565b919091019291505056fea264697066735822122072d7d13f5dea002a0fe190714e265bda9f02b5a6bedc543738ff6a440410b99664736f6c634300080f0033

Verified Source Code Full Match

Compiler: v0.8.15+commit.e14f2714 EVM: london Optimization: Yes (200 runs)
ERC721A.sol 497 lines
// SPDX-License-Identifier: MIT
// Creator: Chiru Labs

pragma solidity ^0.8.0;

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/token/ERC721/extensions/IERC721Enumerable.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';

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints.
 *
 * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..).
 *
 * Does not support burning tokens to address(0).
 *
 * Assumes that an owner cannot have more than the 2**128 - 1 (max value of uint128) of supply
 */
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
    using Address for address;
    using Strings for uint256;

    struct TokenOwnership {
        address addr;
        uint64 startTimestamp;
    }

    struct AddressData {
        uint128 balance;
        uint128 numberMinted;
    }

    uint256 internal currentIndex;

    // 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_;
    }

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

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
     * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
        require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
        uint256 numMintedSoFar = totalSupply();
        uint256 tokenIdsIdx;
        address currOwnershipAddr;

        // Counter overflow is impossible as the loop breaks when uint256 i is equal to another uint256 numMintedSoFar.
        unchecked {
            for (uint256 i; i < numMintedSoFar; i++) {
                TokenOwnership memory ownership = _ownerships[i];
                if (ownership.addr != address(0)) {
                    currOwnershipAddr = ownership.addr;
                }
                if (currOwnershipAddr == owner) {
                    if (tokenIdsIdx == index) {
                        return i;
                    }
                    tokenIdsIdx++;
                }
            }
        }

        revert('ERC721A: unable to get token of owner by index');
    }

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

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

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

    /**
     * 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) {
        require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');

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

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

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view override returns (address) {
        return ownershipOf(tokenId).addr;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');

        string memory baseURI = _baseURI();
        return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : '';
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return '';
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public override {
        address owner = ERC721A.ownerOf(tokenId);
        require(to != owner, 'ERC721A: approval to current owner');

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

        _approve(to, tokenId, owner);
    }

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

        return _tokenApprovals[tokenId];
    }

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

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

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

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

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

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

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

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

    /**
     * @dev 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;
        require(to != address(0), 'ERC721A: mint to the zero address');
        require(quantity != 0, 'ERC721A: quantity must be greater than 0');

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

        // Overflows are incredibly unrealistic.
        // balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1
        // updatedIndex overflows if currentIndex + quantity > 1.56e77 (2**256) - 1
        unchecked {
            _addressData[to].balance += uint128(quantity);
            _addressData[to].numberMinted += uint128(quantity);

            _ownerships[startTokenId].addr = to;
            _ownerships[startTokenId].startTimestamp = uint64(block.timestamp);

            uint256 updatedIndex = startTokenId;

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

                updatedIndex++;
            }

            currentIndex = updatedIndex;
        }

        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) private {
        TokenOwnership memory prevOwnership = ownershipOf(tokenId);

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

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

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

        _beforeTokenTransfers(from, to, tokenId, 1);

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

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

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

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

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

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

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

    /**
     * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
     * minting.
     *
     * startTokenId - the first token id to be transferred
     * quantity - the amount to be transferred
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     */
    function _afterTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}
}
Theirsverse.sol 301 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

// @title Theirsverse NFT
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "erc721a/contracts/ERC721A.sol";

interface IStarNFT is IERC721, IERC721Enumerable {}

contract Theirsverse is Ownable, ERC721A, Pausable, AccessControl, ReentrancyGuard {
    uint256 public immutable maxSupply;
    uint256 public constant MAX_BATCH_SIZE = 5;

    IStarNFT public starNFT;
    address payable public payment;
    uint256 public saleStartTime;
    bytes32[4] public merkleRoots;
    uint256[4] public whitelistPhasePrices;
    uint256 public goldMemberSalePrice;
    uint256 public publicSalePrice;
    string public baseURI;

    mapping(uint256 => uint256) public amountNFTsGoldMemberSale;
    mapping(address => uint256) public amountNFTsPerWhitelistSale;
    mapping(address => uint256) public amountNFTsPerPublicSale;

    constructor(
        uint256[4] memory _whitelistPhasePrices,
        uint256 _goldMemberSalePrice,
        uint256 _publicSalePrice,
        uint256 _saleStartTime,
        uint256 _maxSupply,
        address _owner,
        address _devAdmin,
        address _starNFTAddress,
        address _paymentAddress
    ) ERC721A("Theirsverse Official", "THEIRS") {
        whitelistPhasePrices = _whitelistPhasePrices;
        goldMemberSalePrice = _goldMemberSalePrice;
        publicSalePrice = _publicSalePrice;
        saleStartTime = _saleStartTime;
        maxSupply = _maxSupply;
        starNFT = IStarNFT(_starNFTAddress);
        payment = payable(_paymentAddress);
        _setupRole(DEFAULT_ADMIN_ROLE, _devAdmin);
        _setupRole(DEFAULT_ADMIN_ROLE, _owner);
        transferOwnership(_owner);
    }

    modifier _notContract() {
        uint256 size;
        address addr = msg.sender;
        assembly {
            size := extcodesize(addr)
        }
        require(size == 0, "contract not allowed");
        require(msg.sender == tx.origin, "proxy contract not allowed");
        _;
    }

    modifier _saleBetweenPeriod(uint256 _start, uint256 _end) {
        require(currentTime() >= saleStartTime + _start * 1 days, "sale has not started yet");
        require(currentTime() < saleStartTime + _end * 1 days, "sale is finished");
        _;
    }

    function goldMemberMint(uint256 _quantity)
        external
        payable
        whenNotPaused
        _notContract
        _saleBetweenPeriod(0, 1)
        nonReentrant
    {
        require(_quantity % 10 == 0, "quantity must be a multiple of 10");
        require(totalSupply() + _quantity <= maxSupply, "Max supply exceed");
        uint256 totalPrice = goldMemberSalePrice * _quantity;
        require(msg.value >= totalPrice, "Not enough funds");
        uint256 neededNFTs = _quantity / 10;
        uint256[] memory nfts = verifiedStarNFT(msg.sender, neededNFTs);
        require(nfts.length == neededNFTs, "Goldmember does not own enough verified StarNFTs");
        for (uint256 i = 0; i < neededNFTs; i++) {
            amountNFTsGoldMemberSale[nfts[i]] += 10;
        }
        _batchMint(msg.sender, _quantity);
        refundIfOver(totalPrice);
    }

    function whitelistMint(
        uint256 _quantity,
        bytes32[] calldata _proof,
        uint16 phase
    ) external payable whenNotPaused _notContract _saleBetweenPeriod(1, 2) nonReentrant {
        if (phase == 0 || phase == 1) {
            require(
                amountNFTsPerWhitelistSale[msg.sender] + _quantity <= 1,
                "You can only get 1 NFT on the Whitelist Sale"
            );
        } else {
            require(
                amountNFTsPerWhitelistSale[msg.sender] + _quantity <= 2,
                "You can only get 2 NFT on the Whitelist Sale"
            );
        }
        require(totalSupply() + _quantity <= maxSupply, "Max supply exceed");
        uint256 totalPrice = whitelistPhasePrices[phase] * _quantity;
        require(msg.value >= totalPrice, "Not enough funds");
        require(isWhiteListed(_proof, merkleRoots[phase], msg.sender), "Not Whitelisted");
        amountNFTsPerWhitelistSale[msg.sender] += _quantity;
        _safeMint(msg.sender, _quantity);
        refundIfOver(totalPrice);
    }

    function publicSaleMint(uint256 _quantity)
        external
        payable
        whenNotPaused
        _notContract
        _saleBetweenPeriod(2, 3)
        nonReentrant
    {
        require(amountNFTsPerPublicSale[msg.sender] + _quantity <= 1, "You can only get 1 NFT on the Public Sale");
        require(totalSupply() + _quantity <= maxSupply, "Max supply exceed");
        uint256 totalPrice = publicSalePrice * _quantity;
        require(msg.value >= totalPrice, "Not enough funds");
        amountNFTsPerPublicSale[msg.sender] += _quantity;
        _safeMint(msg.sender, _quantity);
        refundIfOver(totalPrice);
    }

    function goldMemberAirdrop(address[] calldata _accounts, uint256[] calldata _quantity)
        external
        onlyRole(DEFAULT_ADMIN_ROLE)
        nonReentrant
    {
        require(_accounts.length > 0, "No accounts provided");
        require(_accounts.length == _quantity.length, "Accounts and quantities must have the same length");
        for (uint256 i = 0; i < _accounts.length; i++) {
            uint256 quantity = _quantity[i];
            require(quantity > 0, "Quantity must be greater than 0");
            require(quantity % 10 == 0, "Quantity must be a multiple of 10");
            require(totalSupply() + quantity <= maxSupply, "Max supply exceed");
            uint256 neededNFT = quantity / 10;
            uint256[] memory nfts = verifiedStarNFT(_accounts[i], neededNFT);
            require(nfts.length == neededNFT, "Goldmember does not own enough verified StarNFTs");
            for (uint256 j = 0; j < neededNFT; j++) {
                amountNFTsGoldMemberSale[nfts[j]] += 10;
            }
            _batchMint(_accounts[i], quantity);
        }
    }

    function batchClaim(address[] calldata _accounts, uint256[] calldata _quantity)
        external
        onlyRole(DEFAULT_ADMIN_ROLE)
        nonReentrant
    {
        require(_accounts.length > 0, "No accounts provided");
        require(_accounts.length == _quantity.length, "Accounts and quantities must have the same length");
        for (uint256 i = 0; i < _accounts.length; i++) {
            uint256 quantity = _quantity[i];
            require(totalSupply() + quantity <= maxSupply, "Max supply exceed");
            _batchMint(_accounts[i], quantity);
        }
    }

    function goldMemberMaxCount(address account) public view returns (uint256) {
        uint256 starNFTCounts = starNFT.balanceOf(account);
        uint256 count = 0;
        for (uint256 i = 0; i < starNFTCounts; i++) {
            uint256 tokenId = starNFT.tokenOfOwnerByIndex(account, i);
            if (amountNFTsGoldMemberSale[tokenId] < 1) {
                count = count + 1;
            }
        }
        return count;
    }

    function withdraw() public {
        uint256 amount = address(this).balance;
        if (amount > 0) {
            Address.sendValue(payment, amount);
        }
    }

    function withdraw(IERC20 token) public {
        uint256 amount = token.balanceOf(address(this));
        require(amount > 0, "No tokens to withdraw");
        SafeERC20.safeTransfer(token, payment, amount);
    }

    function supportsInterface(bytes4 interfaceId) public view override(AccessControl, ERC721A) returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    function setPayment(address _paymentAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
        payment = payable(_paymentAddress);
    }

    function setStarNFT(address _starNFTAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
        starNFT = IStarNFT(_starNFTAddress);
    }

    function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _pause();
    }

    function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _unpause();
    }

    function currentTime() private view returns (uint256) {
        return block.timestamp;
    }

    function setBaseURI(string calldata uri) external onlyRole(DEFAULT_ADMIN_ROLE) {
        baseURI = uri;
    }

    function setMerkleRoot(bytes32[4] calldata _merkleRoots) external onlyRole(DEFAULT_ADMIN_ROLE) {
        merkleRoots = _merkleRoots;
    }

    function setSaleStartTime(uint256 _saleStartTime) external onlyRole(DEFAULT_ADMIN_ROLE) {
        saleStartTime = _saleStartTime;
    }

    function grantAdminRole(address account) external onlyOwner {
        _grantRole(DEFAULT_ADMIN_ROLE, account);
    }

    function revokeAdminRole(address account) external onlyOwner {
        _revokeRole(DEFAULT_ADMIN_ROLE, account);
    }

    function refundIfOver(uint256 price) private {
        if (msg.value > price) {
            Address.sendValue(payable(msg.sender), msg.value - price);
        }
    }

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

    function verifiedStarNFT(address account, uint256 quantity) private view returns (uint256[] memory) {
        uint256 starNFTCounts = starNFT.balanceOf(account);
        uint256[] memory verified = new uint256[](quantity);
        uint256 verifiedIndex = 0;
        uint256 lastIndex = quantity - 1;
        for (uint256 i = 0; i < starNFTCounts; i++) {
            uint256 tokenId = starNFT.tokenOfOwnerByIndex(account, i);
            if (amountNFTsGoldMemberSale[tokenId] < 1) {
                verified[verifiedIndex] = tokenId;
                if (verifiedIndex == lastIndex) {
                    return verified;
                }
                verifiedIndex = verifiedIndex + 1;
            }
        }
        return new uint256[](0);
    }

    function _batchMint(address _account, uint256 _quantity) internal {
        if (_quantity <= MAX_BATCH_SIZE) {
            _safeMint(_account, _quantity);
        } else {
            uint256 batchNumber = _quantity / MAX_BATCH_SIZE;
            uint256 remainder = _quantity % MAX_BATCH_SIZE;
            uint256 i = 0;
            while (i < batchNumber) {
                _safeMint(_account, MAX_BATCH_SIZE);
                i++;
            }
            if (remainder > 0) {
                _safeMint(_account, remainder);
            }
        }
    }

    function isWhiteListed(
        bytes32[] calldata _proof,
        bytes32 _merkleRoot,
        address _account
    ) private pure returns (bool) {
        return MerkleProof.verify(_proof, _merkleRoot, leaf(_account));
    }

    function leaf(address _account) private pure returns (bytes32) {
        return keccak256(abi.encodePacked(_account));
    }
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

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

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

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

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}
AccessControl.sol 235 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

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

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.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 be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev 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);
}
IAccessControl.sol 88 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
SafeERC20.sol 99 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}
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 65 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Trees proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 *
 * 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 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++) {
            bytes32 proofElement = proof[i];
            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = _efficientHash(computedHash, proofElement);
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = _efficientHash(proofElement, computedHash);
            }
        }
        return computedHash;
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

Read Contract

DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MAX_BATCH_SIZE 0xcfdbf254 → uint256
amountNFTsGoldMemberSale 0x76e8687c → uint256
amountNFTsPerPublicSale 0x1a914389 → uint256
amountNFTsPerWhitelistSale 0x17957f84 → uint256
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
getApproved 0x081812fc → address
getRoleAdmin 0x248a9ca3 → bytes32
goldMemberMaxCount 0x91c15246 → uint256
goldMemberSalePrice 0xa7f949b1 → uint256
hasRole 0x91d14854 → bool
isApprovedForAll 0xe985e9c5 → bool
maxSupply 0xd5abeb01 → uint256
merkleRoots 0x71c5ecb1 → bytes32
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
payment 0x42f6487a → address
publicSalePrice 0x9b6860c8 → uint256
saleStartTime 0x1cbaee2d → uint256
starNFT 0x70dca974 → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
whitelistPhasePrices 0x1deede8f → uint256

Write Contract 26 functions

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

approve 0x095ea7b3
address to
uint256 tokenId
batchClaim 0x79f67c5a
address[] _accounts
uint256[] _quantity
goldMemberAirdrop 0x568af081
address[] _accounts
uint256[] _quantity
goldMemberMint 0x673ef0a7
uint256 _quantity
grantAdminRole 0xc634b78e
address account
grantRole 0x2f2ff15d
bytes32 role
address account
pause 0x8456cb59
No parameters
publicSaleMint 0xb3ab66b0
uint256 _quantity
renounceOwnership 0x715018a6
No parameters
renounceRole 0x36568abe
bytes32 role
address account
revokeAdminRole 0x9a19c7b0
address account
revokeRole 0xd547741f
bytes32 role
address account
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 uri
setMerkleRoot 0x8975ede2
bytes32[4] _merkleRoots
setPayment 0x9ab06fcb
address _paymentAddress
setSaleStartTime 0x525f8a5c
uint256 _saleStartTime
setStarNFT 0xb0bf74e3
address _starNFTAddress
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
whitelistMint 0xc0612b7b
uint256 _quantity
bytes32[] _proof
uint16 phase
withdraw 0x3ccfd60b
No parameters
withdraw 0x51cff8d9
address token

Recent Transactions

No transactions found for this address