Address Contract Partially Verified
Address
0x9b7E68482B20D7843201eBf6715B5E86e0114625
Balance
0.314713 ETH
Nonce
1
Code Size
14550 bytes
Creator
0xE668Aad7...2A83 at tx 0x0b66aab7...fde54f
Indexed Transactions
0
Contract Bytecode
14550 bytes
0x6080604052600436106102cd5760003560e01c8063715018a611610175578063c5ea3c65116100dc578063ddc150c311610095578063e985e9c51161006f578063e985e9c514610933578063ebcea3db1461097c578063f0e7ac181461099c578063f2fde38b146109bc57600080fd5b8063ddc150c3146108eb578063e33b7de3146108fe578063e58306f91461091357600080fd5b8063c5ea3c6514610809578063c87b56dd1461081f578063ce7c2ac21461083f578063d5a5b14014610875578063d79779b214610895578063da72c1e8146108cb57600080fd5b8063a22cb4651161012e578063a22cb4651461073c578063a3f8eace1461075c578063a9b4b0b71461077c578063abff93931461079c578063b88d4fde146107c9578063c45ac050146107e957600080fd5b8063715018a6146106895780638456cb591461069e5780638b83209b146106b35780638da5cb5b146106d357806395d89b41146106f15780639852595c1461070657600080fd5b806339843ba91161023457806348b75044116101ed5780635c975abb116101c75780635c975abb1461061b5780636352211e146106335780636817c76c1461065357806370a082311461066957600080fd5b806348b75044146105a957806349072f12146105c9578063492d306b146105fb57600080fd5b806339843ba9146104c95780633a98ef39146104f95780633f4ba83a1461050e578063406072a91461052357806342842e0e1461056957806342966c681461058957600080fd5b806318160ddd1161028657806318160ddd1461040c578063191655871461043357806323b872dd146104535780632c8615b11461047357806333f569c51461049357806334d722c9146104a957600080fd5b806301ffc9a71461031b57806306fdde0314610350578063081812fc14610372578063095ea7b3146103aa5780630b5a0e2e146103cc5780630e89341c146103ec57600080fd5b36610316577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033604080516001600160a01b0390921682523460208301520160405180910390a1005b600080fd5b34801561032757600080fd5b5061033b610336366004612f87565b6109dc565b60405190151581526020015b60405180910390f35b34801561035c57600080fd5b50610365610a2e565b6040516103479190612ff4565b34801561037e57600080fd5b5061039261038d366004613007565b610ac0565b6040516001600160a01b039091168152602001610347565b3480156103b657600080fd5b506103ca6103c5366004613035565b610b04565b005b3480156103d857600080fd5b506103ca6103e7366004613007565b610be9565b3480156103f857600080fd5b50610365610407366004613007565b610c72565b34801561041857600080fd5b5060025460015403600019015b604051908152602001610347565b34801561043f57600080fd5b506103ca61044e366004613061565b610cf9565b34801561045f57600080fd5b506103ca61046e36600461307e565b610df2565b34801561047f57600080fd5b506103ca61048e366004613061565b610dfd565b34801561049f57600080fd5b5061042560155481565b3480156104b557600080fd5b50601854610392906001600160a01b031681565b3480156104d557600080fd5b5061033b6104e43660046130d7565b60166020526000908152604090205460ff1681565b34801561050557600080fd5b50600a54610425565b34801561051a57600080fd5b506103ca610e90565b34801561052f57600080fd5b5061042561053e3660046130f2565b6001600160a01b03918216600090815260106020908152604080832093909416825291909152205490565b34801561057557600080fd5b506103ca61058436600461307e565b610ea2565b34801561059557600080fd5b506103ca6105a4366004613007565b610ebd565b3480156105b557600080fd5b506103ca6105c43660046130f2565b610f9c565b3480156105d557600080fd5b506013546105e69063ffffffff1681565b60405163ffffffff9091168152602001610347565b34801561060757600080fd5b506103ca6106163660046131c8565b6110bf565b34801561062757600080fd5b5060095460ff1661033b565b34801561063f57600080fd5b5061039261064e366004613007565b611185565b34801561065f57600080fd5b5061042560145481565b34801561067557600080fd5b50610425610684366004613061565b611197565b34801561069557600080fd5b506103ca6111e5565b3480156106aa57600080fd5b506103ca6111f7565b3480156106bf57600080fd5b506103926106ce366004613007565b611207565b3480156106df57600080fd5b506000546001600160a01b0316610392565b3480156106fd57600080fd5b50610365611237565b34801561071257600080fd5b50610425610721366004613061565b6001600160a01b03166000908152600d602052604090205490565b34801561074857600080fd5b506103ca61075736600461321e565b611246565b34801561076857600080fd5b50610425610777366004613061565b6112db565b34801561078857600080fd5b506103ca610797366004613007565b611323565b3480156107a857600080fd5b506104256107b7366004613061565b60176020526000908152604090205481565b3480156107d557600080fd5b506103ca6107e436600461324c565b6113a7565b3480156107f557600080fd5b506104256108043660046130f2565b6113f8565b34801561081557600080fd5b5061042560195481565b34801561082b57600080fd5b5061036561083a366004613007565b6114c3565b34801561084b57600080fd5b5061042561085a366004613061565b6001600160a01b03166000908152600c602052604090205490565b34801561088157600080fd5b506103ca610890366004613007565b611553565b3480156108a157600080fd5b506104256108b0366004613061565b6001600160a01b03166000908152600f602052604090205490565b3480156108d757600080fd5b506103ca6108e636600461307e565b6115d7565b6103ca6108f93660046132df565b6117c4565b34801561090a57600080fd5b50600b54610425565b34801561091f57600080fd5b506103ca61092e366004613035565b611c0d565b34801561093f57600080fd5b5061033b61094e3660046130f2565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205460ff1690565b34801561098857600080fd5b506103ca610997366004613007565b611dea565b3480156109a857600080fd5b506103ca6109b73660046133c2565b611e5d565b3480156109c857600080fd5b506103ca6109d7366004613061565b611f04565b60006001600160e01b031982166380ac58cd60e01b1480610a0d57506001600160e01b03198216635b5e139f60e01b145b80610a2857506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060038054610a3d906133dd565b80601f0160208091040260200160405190810160405280929190818152602001828054610a69906133dd565b8015610ab65780601f10610a8b57610100808354040283529160200191610ab6565b820191906000526020600020905b815481529060010190602001808311610a9957829003601f168201915b5050505050905090565b6000610acb82611f7a565b610ae8576040516333d1c03960e21b815260040160405180910390fd5b506000908152600760205260409020546001600160a01b031690565b6040516331a9108f60e11b8152600481018290526000903090636352211e90602401602060405180830381865afa158015610b43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b679190613417565b9050806001600160a01b0316836001600160a01b031603610b9b5760405163250fdee360e21b815260040160405180910390fd5b336001600160a01b03821614801590610bbb5750610bb9813361094e565b155b15610bd9576040516367d9dca160e11b815260040160405180910390fd5b610be4838383611fb3565b505050565b610bf161200f565b8060155403610c6d5760405162461bcd60e51b815260206004820152603f60248201527f5350544e3a204d696e204554482050726963652073686f756c6420626520646960448201527f66666572656e74207468616e207468652070726576696f75732070726963650060648201526084015b60405180910390fd5b601555565b6060610c7d82611f7a565b610c9a57604051630a14c4b560e41b815260040160405180910390fd5b6019548211610cf4576011610cae83612069565b60405180604001604052806005815260200164173539b7b760d91b815250604051602001610cde939291906134a7565b6040516020818303038152906040529050919050565b919050565b6001600160a01b0381166000908152600c6020526040902054610d2e5760405162461bcd60e51b8152600401610c64906134e0565b6000610d39826112db565b905080600003610d5b5760405162461bcd60e51b8152600401610c6490613526565b6001600160a01b0382166000908152600d602052604081208054839290610d83908490613587565b9250508190555080600b6000828254610d9c9190613587565b90915550610dac90508282612169565b604080516001600160a01b0384168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a15050565b610be4838383612282565b610e0561200f565b6018546001600160a01b03808316911603610e6e5760405162461bcd60e51b8152602060048201526024808201527f5350544e3a204d696e74657220616464726573732063616e206e6f742062652060448201526373616d6560e01b6064820152608401610c64565b601880546001600160a01b0319166001600160a01b0392909216919091179055565b610e9861200f565b610ea061245e565b565b610be4838383604051806020016040528060008152506113a7565b33610eda5760405162461bcd60e51b8152600401610c649061359a565b610ee381611f7a565b610f2f5760405162461bcd60e51b815260206004820152601d60248201527f5350544e3a20546f6b656e20496420646f6573206e6f742065786973740000006044820152606401610c64565b33610f39826124b0565b516001600160a01b031614610f905760405162461bcd60e51b815260206004820152601f60248201527f5350544e3a20596f7520646f206e6f74206f776e207468697320746f6b656e006044820152606401610c64565b610f99816125d7565b50565b6001600160a01b0381166000908152600c6020526040902054610fd15760405162461bcd60e51b8152600401610c64906134e0565b6000610fdd83836113f8565b905080600003610fff5760405162461bcd60e51b8152600401610c6490613526565b6001600160a01b03808416600090815260106020908152604080832093861683529290529081208054839290611036908490613587565b90915550506001600160a01b0383166000908152600f602052604081208054839290611063908490613587565b9091555061107490508383836125e2565b604080516001600160a01b038481168252602082018490528516917f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a910160405180910390a2505050565b6110c761200f565b60116040516020016110d991906135d1565b604051602081830303815290604052805190602001208160405160200161110091906135dd565b60405160208183030381529060405280519060200120036111755760405162461bcd60e51b815260206004820152602960248201527f5350544e3a2042617365205552492063616e6e6f742062652073616d652061736044820152682070726576696f757360b81b6064820152608401610c64565b60116111818282613647565b5050565b6000611190826124b0565b5192915050565b60006001600160a01b0382166111c0576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600660205260409020546001600160401b031690565b6111ed61200f565b610ea06000612634565b6111ff61200f565b610ea0612684565b6000600e828154811061121c5761121c613706565b6000918252602090912001546001600160a01b031692915050565b606060048054610a3d906133dd565b336001600160a01b0383160361126f5760405163b06307db60e01b815260040160405180910390fd5b3360008181526008602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6000806112e7600b5490565b6112f19047613587565b905061131c8382611317866001600160a01b03166000908152600d602052604090205490565b6126c1565b9392505050565b61132b61200f565b60145481036113a25760405162461bcd60e51b815260206004820152603c60248201527f5350544e3a204d696e742050726963652073686f756c6420626520646966666560448201527f72656e74207468616e207468652070726576696f7573207072696365000000006064820152608401610c64565b601455565b6113b2848484612282565b6001600160a01b0383163b151580156113d457506113d2848484846126ff565b155b156113f2576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6001600160a01b0382166000908152600f602052604081205481906040516370a0823160e01b81523060048201526001600160a01b038616906370a0823190602401602060405180830381865afa158015611457573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147b919061371c565b6114859190613587565b6001600160a01b038086166000908152601060209081526040808320938816835292905220549091506114bb90849083906126c1565b949350505050565b60606114ce82611f7a565b6114eb57604051630a14c4b560e41b815260040160405180910390fd5b600061150260408051602081019091526000815290565b90508051600003611522576040518060200160405280600081525061131c565b8061152c84612069565b60405160200161153d929190613735565b6040516020818303038152906040529392505050565b61155b61200f565b60195481036115d25760405162461bcd60e51b815260206004820152603d60248201527f5350544e3a204d617820537570706c792073686f756c6420626520646966666560448201527f72656e74207468616e207468652070726576696f757320737570706c790000006064820152608401610c64565b601955565b6115df61200f565b6115e881611f7a565b6116345760405162461bcd60e51b815260206004820152601d60248201527f5350544e3a20546f6b656e20496420646f6573206e6f742065786973740000006044820152606401610c64565b826001600160a01b0316611647826124b0565b516001600160a01b0316146116ac5760405162461bcd60e51b815260206004820152602560248201527f5350544e3a204164647265737320646f6573206e6f74206f776e2074686973206044820152643a37b5b2b760d91b6064820152608401610c64565b60006116b7826124b0565b90506001600160a01b038481166000908152600660209081526040808320805467ffffffffffffffff198082166001600160401b0392831660001901831617909255888616808652838620805493841693831660019081018416949094179055888652600590945282852080546001600160e01b031916909417600160a01b4290921691909102178355860180845292208054919390911661178d57600154821461178d57805460208501516001600160401b0316600160a01b026001600160e01b03199091166001600160a01b038916171781555b50505081836001600160a01b0316856001600160a01b031660008051602061388183398151915260405160405180910390a46113f2565b6117cc6127ea565b60145434906000906117e59063ffffffff881690613764565b905060006117f4606483613791565b6117fe90836137a5565b9050600061180d606484613791565b6118179084613587565b90506001600160a01b03891661183f5760405162461bcd60e51b8152600401610c649061359a565b6015548510156118915760405162461bcd60e51b815260206004820152601760248201527f5350544e3a20496e76616c6964204554482050726963650000000000000000006044820152606401610c64565b670de0b6b3a76400006118a48686613764565b6118ae9190613791565b8211156119115760405162461bcd60e51b815260206004820152602b60248201527f5350544e3a20446f6c6c6172732073656e74206973206c657373207468616e2060448201526a746865206d696e696d756d60a81b6064820152608401610c64565b80670de0b6b3a76400006119258787613764565b61192f9190613791565b11156119915760405162461bcd60e51b815260206004820152602b60248201527f5350544e3a20446f6c6c6172732073656e74206973206d6f7265207468616e2060448201526a746865206d6178696d756d60a81b6064820152608401610c64565b60195461199f60018a6137b8565b63ffffffff166001546119b29190613587565b1115611a0f5760405162461bcd60e51b815260206004820152602660248201527f5350544e3a206d6178205350415254414e20746f6b656e206c696d697420657860448201526518d95959195960d21b6064820152608401610c64565b6013546001600160a01b038a1660009081526017602052604090205463ffffffff91821691611a4191908b1690613587565b1115611a9a5760405162461bcd60e51b815260206004820152602260248201527f5350544e3a204d6178204e465420706572206164647265737320657863656564604482015261195960f21b6064820152608401610c64565b6001600160801b0319861660009081526016602052604090205460ff1615611b045760405162461bcd60e51b815260206004820152601a60248201527f5350544e3a206d696e7420696420616c726561647920757365640000000000006044820152606401610c64565b60125415801590611b1a5750611b1a8787612830565b506001600160a01b0389166000908152601760205260408120805463ffffffff8b169290611b49908490613587565b90915550506001600160801b031986166000908152601660205260409020805460ff1916600190811790915554611b868a63ffffffff8b166128cf565b60405163ffffffff8a16815281906001600160a01b038c16907f25b428dfde728ccfaddad7e29e4ac23c24ed7fd1a6e3e3f91894a9a073f5dfff9060200160405180910390a36040516001600160801b03198816907f029a9b686036657dfaebf15952273022dc590b8fcb479f56dd71a9aa72325f6f90600090a250505050505050505050565b611c156127ea565b33611c286000546001600160a01b031690565b6001600160a01b03161480611c4757506018546001600160a01b031633145b611cb95760405162461bcd60e51b815260206004820152603e60248201527f5468652063616c6c6572206f662074686520636f6e7472616374206973206e6560448201527f697468657220746865206f776e6572206e6f7220746865206d696e74657200006064820152608401610c64565b6001600160a01b038216611cdf5760405162461bcd60e51b8152600401610c649061359a565b6019546001541115611d335760405162461bcd60e51b815260206004820152601760248201527f5350544e3a20546f6b656e206964206d69736d617463680000000000000000006044820152606401610c64565b601954611d41906001613587565b600154611d4e9083613587565b1115611d945760405162461bcd60e51b81526020600482015260156024820152740a6a0a89c744082dadeeadce840dad2e6dac2e8c6d605b1b6044820152606401610c64565b600154611da183836128cf565b80836001600160a01b03167f9ea69fe563383aa6c77c5d921052ea81ff8e9bbdcc9aa2bfebfa25a014d3a7f084604051611ddd91815260200190565b60405180910390a3505050565b611df261200f565b6012548103611e585760405162461bcd60e51b815260206004820152602c60248201527f5350544e3a204d65726b6c6520726f6f742063616e6e6f742062652073616d6560448201526b2061732070726576696f757360a01b6064820152608401610c64565b601255565b611e6561200f565b60135463ffffffff90811690821603611ee8576040805162461bcd60e51b81526020600482015260248101919091527f5350544e3a204d696e74696e67206c696d69742073686f756c6420626520646960448201527f66666572656e742066726f6d207468652070726576696f75732076616c75652e6064820152608401610c64565b6013805463ffffffff191663ffffffff92909216919091179055565b611f0c61200f565b6001600160a01b038116611f715760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c64565b610f9981612634565b600081600111158015611f8e575060015482105b8015610a28575050600090815260056020526040902054600160e01b900460ff161590565b60008281526007602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000546001600160a01b03163314610ea05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c64565b6060816000036120905750506040805180820190915260018152600360fc1b602082015290565b8160005b81156120ba57806120a4816137dc565b91506120b39050600a83613791565b9150612094565b6000816001600160401b038111156120d4576120d461312b565b6040519080825280601f01601f1916602001820160405280156120fe576020820181803683370190505b5090505b84156114bb576121136001836137a5565b9150612120600a866137f5565b61212b906030613587565b60f81b81838151811061214057612140613706565b60200101906001600160f81b031916908160001a905350612162600a86613791565b9450612102565b804710156121b95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610c64565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612206576040519150601f19603f3d011682016040523d82523d6000602084013e61220b565b606091505b5050905080610be45760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610c64565b600061228d826124b0565b9050836001600160a01b031681600001516001600160a01b0316146122c45760405162a1148160e81b815260040160405180910390fd5b6000336001600160a01b03861614806122e257506122e2853361094e565b806122fd5750336122f284610ac0565b6001600160a01b0316145b90508061231d57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b03841661234457604051633a954ecd60e21b815260040160405180910390fd5b61235060008487611fb3565b6001600160a01b038581166000908152600660209081526040808320805467ffffffffffffffff198082166001600160401b0392831660001901831617909255898616808652838620805493841693831660019081018416949094179055898652600590945282852080546001600160e01b031916909417600160a01b4290921691909102178355870180845292208054919390911661242457600154821461242457805460208601516001600160401b0316600160a01b026001600160e01b03199091166001600160a01b038a16171781555b50505082846001600160a01b0316866001600160a01b031660008051602061388183398151915260405160405180910390a45b5050505050565b6124666128e9565b6009805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b604080516060810182526000808252602082018190529181019190915281806001111580156124e0575060015481105b156125be57600081815260056020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff161515918101829052906125bc5780516001600160a01b031615612553579392505050565b5060001901600081815260056020908152604091829020825160608101845290546001600160a01b038116808352600160a01b82046001600160401b031693830193909352600160e01b900460ff16151592810192909252156125b7579392505050565b612553565b505b604051636f96cda160e11b815260040160405180910390fd5b610f99816000612932565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610be4908490612ae6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61268c6127ea565b6009805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586124933390565b600a546001600160a01b0384166000908152600c6020526040812054909183916126eb9086613764565b6126f59190613791565b6114bb91906137a5565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612734903390899088908890600401613809565b6020604051808303816000875af192505050801561276f575060408051601f3d908101601f1916820190925261276c91810190613846565b60015b6127cd573d80801561279d576040519150601f19603f3d011682016040523d82523d6000602084013e6127a2565b606091505b5080516000036127c5576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b60095460ff1615610ea05760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c64565b6012546040516001600160801b03198316602082015260009161286e9185919060300160405160208183030381529060405280519060200120612bb8565b6128c65760405162461bcd60e51b8152602060048201526024808201527f5350544e3a20506c65617365207265676973746572206265666f7265206d696e60448201526374696e6760e01b6064820152608401610c64565b50600192915050565b611181828260405180602001604052806000815250612bce565b60095460ff16610ea05760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c64565b600061293d836124b0565b805190915082156129a3576000336001600160a01b03831614806129665750612966823361094e565b8061298157503361297686610ac0565b6001600160a01b0316145b9050806129a157604051632ce44b5f60e11b815260040160405180910390fd5b505b6129af60008583611fb3565b6001600160a01b0380821660008181526006602090815260408083208054600160801b6000196001600160401b0380841691909101811667ffffffffffffffff198416811783900482166001908101831690930277ffffffffffffffff0000000000000000ffffffffffffffff19909416179290921783558b86526005909452828520805460ff60e01b1942909316600160a01b026001600160e01b03199091169097179690961716600160e01b178555918901808452922080549194909116612aad576001548214612aad57805460208701516001600160401b0316600160a01b026001600160e01b03199091166001600160a01b038716171781555b5050604051869250600091506001600160a01b03841690600080516020613881833981519152908390a450506002805460010190555050565b6000612b3b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612bdb9092919063ffffffff16565b805190915015610be45780806020019051810190612b599190613863565b610be45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610c64565b600082612bc58584612bea565b14949350505050565b610be48383836001612c37565b60606114bb8484600085612ddb565b600081815b8451811015612c2f57612c1b82868381518110612c0e57612c0e613706565b6020026020010151612f0c565b915080612c27816137dc565b915050612bef565b509392505050565b6001546001600160a01b038516612c6057604051622e076360e81b815260040160405180910390fd5b83600003612c815760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b038516600081815260066020908152604080832080546001600160801b031981166001600160401b038083168c0181169182176801000000000000000067ffffffffffffffff1990941690921783900481168c01811690920217909155858452600590925290912080546001600160e01b031916909217600160a01b429092169190910217905580808501838015612d2957506001600160a01b0387163b15155b15612d9f575b60405182906001600160a01b03891690600090600080516020613881833981519152908290a4612d6860008884806001019550886126ff565b612d85576040516368d2bf6b60e11b815260040160405180910390fd5b808203612d2f578260015414612d9a57600080fd5b612dd2565b5b6040516001830192906001600160a01b03891690600090600080516020613881833981519152908290a4808203612da0575b50600155612457565b606082471015612e3c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610c64565b6001600160a01b0385163b612e935760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c64565b600080866001600160a01b03168587604051612eaf91906135dd565b60006040518083038185875af1925050503d8060008114612eec576040519150601f19603f3d011682016040523d82523d6000602084013e612ef1565b606091505b5091509150612f01828286612f38565b979650505050505050565b6000818310612f2857600082815260208490526040902061131c565b5060009182526020526040902090565b60608315612f4757508161131c565b825115612f575782518084602001fd5b8160405162461bcd60e51b8152600401610c649190612ff4565b6001600160e01b031981168114610f9957600080fd5b600060208284031215612f9957600080fd5b813561131c81612f71565b60005b83811015612fbf578181015183820152602001612fa7565b50506000910152565b60008151808452612fe0816020860160208601612fa4565b601f01601f19169290920160200192915050565b60208152600061131c6020830184612fc8565b60006020828403121561301957600080fd5b5035919050565b6001600160a01b0381168114610f9957600080fd5b6000806040838503121561304857600080fd5b823561305381613020565b946020939093013593505050565b60006020828403121561307357600080fd5b813561131c81613020565b60008060006060848603121561309357600080fd5b833561309e81613020565b925060208401356130ae81613020565b929592945050506040919091013590565b80356001600160801b031981168114610cf457600080fd5b6000602082840312156130e957600080fd5b61131c826130bf565b6000806040838503121561310557600080fd5b823561311081613020565b9150602083013561312081613020565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156131695761316961312b565b604052919050565b60006001600160401b0383111561318a5761318a61312b565b61319d601f8401601f1916602001613141565b90508281528383830111156131b157600080fd5b828260208301376000602084830101529392505050565b6000602082840312156131da57600080fd5b81356001600160401b038111156131f057600080fd5b8201601f8101841361320157600080fd5b6114bb84823560208401613171565b8015158114610f9957600080fd5b6000806040838503121561323157600080fd5b823561323c81613020565b9150602083013561312081613210565b6000806000806080858703121561326257600080fd5b843561326d81613020565b9350602085013561327d81613020565b92506040850135915060608501356001600160401b0381111561329f57600080fd5b8501601f810187136132b057600080fd5b6132bf87823560208401613171565b91505092959194509250565b803563ffffffff81168114610cf457600080fd5b600080600080600060a086880312156132f757600080fd5b853561330281613020565b945060206133118782016132cb565b945060408701356001600160401b038082111561332d57600080fd5b818901915089601f83011261334157600080fd5b8135818111156133535761335361312b565b8060051b9150613364848301613141565b818152918301840191848101908c84111561337e57600080fd5b938501935b8385101561339c57843582529385019390850190613383565b8098505050505050506133b1606087016130bf565b949793965091946080013592915050565b6000602082840312156133d457600080fd5b61131c826132cb565b600181811c908216806133f157607f821691505b60208210810361341157634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561342957600080fd5b815161131c81613020565b60008154613441816133dd565b60018281168015613459576001811461346e5761349d565b60ff198416875282151583028701945061349d565b8560005260208060002060005b858110156134945781548a82015290840190820161347b565b50505082870194505b5050505092915050565b60006134b38286613434565b84516134c3818360208901612fa4565b84519101906134d6818360208801612fa4565b0195945050505050565b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610a2857610a28613571565b60208082526019908201527f5350544e3a20416464726573732063616e6e6f74206265203000000000000000604082015260600190565b600061131c8284613434565b600082516135ef818460208701612fa4565b9190910192915050565b601f821115610be457600081815260208120601f850160051c810160208610156136205750805b601f850160051c820191505b8181101561363f5782815560010161362c565b505050505050565b81516001600160401b038111156136605761366061312b565b6136748161366e84546133dd565b846135f9565b602080601f8311600181146136a957600084156136915750858301515b600019600386901b1c1916600185901b17855561363f565b600085815260208120601f198616915b828110156136d8578886015182559484019460019091019084016136b9565b50858210156136f65787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561372e57600080fd5b5051919050565b60008351613747818460208801612fa4565b83519083019061375b818360208801612fa4565b01949350505050565b8082028115828204841417610a2857610a28613571565b634e487b7160e01b600052601260045260246000fd5b6000826137a0576137a061377b565b500490565b81810381811115610a2857610a28613571565b63ffffffff8281168282160390808211156137d5576137d5613571565b5092915050565b6000600182016137ee576137ee613571565b5060010190565b6000826138045761380461377b565b500690565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061383c90830184612fc8565b9695505050505050565b60006020828403121561385857600080fd5b815161131c81612f71565b60006020828403121561387557600080fd5b815161131c8161321056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa264697066735822122091f96c3750ffae32698a89a28025e58dc2ed4175026e47a232f2866ef3de318b64736f6c63430008110033
Verified Source Code Partial Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (200 runs)
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
ERC721A.sol 681 lines
// SPDX-License-Identifier: MIT
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
error ApprovalCallerNotOwnerNorApproved();
error ApprovalQueryForNonexistentToken();
error ApproveToCaller();
error ApprovalToCurrentOwner();
error BalanceQueryForZeroAddress();
error MintToZeroAddress();
error MintZeroQuantity();
error OwnerQueryForNonexistentToken();
error TransferCallerNotOwnerNorApproved();
error TransferFromIncorrectOwner();
error TransferToNonERC721ReceiverImplementer();
error TransferToZeroAddress();
error URIQueryForNonexistentToken();
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension. Built to optimize for lower gas during batch mints.
*
* Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..).
*
* Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
*
* Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Compiler will pack this into a single 256bit word.
struct TokenOwnership {
// The address of the owner.
address addr;
// Keeps track of the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
}
// Compiler will pack this into a single 256bit word.
struct AddressData {
// Realistically, 2**64-1 is more than enough.
uint64 balance;
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
// For miscellaneous variable(s) pertaining to the address
// (e.g. number of whitelist mint slots used).
// If there are multiple variables, please pack them into a uint64.
uint64 aux;
}
// The tokenId of the next token to be minted.
uint256 internal _currentIndex;
// The number of tokens burned.
uint256 internal _burnCounter;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) internal _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
}
/**
* To change the starting tokenId, please override this function.
*/
function _startTokenId() internal pure virtual returns (uint256) {
return 1;
}
/**
* @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens.
*/
function totalSupply() public view returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than _currentIndex - _startTokenId() times
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
/**
* Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view returns (uint256) {
// Counter underflow is impossible as _currentIndex does not decrement,
// and it is initialized to _startTokenId()
unchecked {
return _currentIndex - _startTokenId();
}
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165, IERC165)
returns (bool)
{
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return uint256(_addressData[owner].balance);
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return uint256(_addressData[owner].numberMinted);
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return uint256(_addressData[owner].numberBurned);
}
/**
* Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return _addressData[owner].aux;
}
/**
* Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
* If there are multiple variables, please pack them into a uint64.
*/
function _setAux(address owner, uint64 aux) internal {
_addressData[owner].aux = aux;
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function _ownershipOf(uint256 tokenId)
internal
view
returns (TokenOwnership memory)
{
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr && curr < _currentIndex) {
TokenOwnership memory ownership = _ownerships[curr];
if (!ownership.burned) {
if (ownership.addr != address(0)) {
return ownership;
}
// Invariant:
// There will always be an ownership that has an address and is not burned
// before an ownership that does not have an address and is not burned.
// Hence, curr will not underflow.
while (true) {
curr--;
ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return _ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return
bytes(baseURI).length != 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = ERC721A(this).ownerOf(tokenId);
if (to == owner) revert ApprovalToCurrentOwner();
if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId)
public
view
override
returns (address)
{
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved)
public
virtual
override
{
if (operator == _msgSender()) revert ApproveToCaller();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator)
public
view
virtual
override
returns (bool)
{
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
_transfer(from, to, tokenId);
if (
to.isContract() &&
!_checkContractOnERC721Received(from, to, tokenId, _data)
) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return
_startTokenId() <= tokenId &&
tokenId < _currentIndex &&
!_ownerships[tokenId].burned;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, "");
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
uint256 end = updatedIndex + quantity;
if (safe && to.isContract()) {
do {
emit Transfer(address(0), to, updatedIndex);
if (
!_checkContractOnERC721Received(
address(0),
to,
updatedIndex++,
_data
)
) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (updatedIndex != end);
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
} else {
do {
emit Transfer(address(0), to, updatedIndex++);
} while (updatedIndex != end);
}
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, from);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = to;
currSlot.startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev This is equivalent to _burn(tokenId, false)
*/
function _burn(uint256 tokenId) internal virtual {
_burn(tokenId, false);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
address from = prevOwnership.addr;
if (approvalCheck) {
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, from);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
unchecked {
AddressData storage addressData = _addressData[from];
addressData.balance -= 1;
addressData.numberBurned += 1;
// Keep track of who burned the token, and the timestamp of burning.
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = from;
currSlot.startTimestamp = uint64(block.timestamp);
currSlot.burned = true;
// If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try
IERC721Receiver(to).onERC721Received(
_msgSender(),
from,
tokenId,
_data
)
returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
* And also called before burning one token.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
* And also called after one token has been burned.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
* transferred to `to`.
* - When `from` is zero, `tokenId` has been minted for `to`.
* - When `to` is zero, `tokenId` has been burned by `from`.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
}
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);
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
ERC721.sol 454 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: address zero is not a valid owner");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
_requireMinted(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not token owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_safeTransfer(from, to, tokenId, data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Reverts if the `tokenId` has not been minted yet.
*/
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (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 Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
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());
}
}
draft-IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
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);
}
PaymentSplitter.sol 205 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (finance/PaymentSplitter.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/utils/SafeERC20.sol";
import "../utils/Address.sol";
import "../utils/Context.sol";
/**
* @title PaymentSplitter
* @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware
* that the Ether will be split in this way, since it is handled transparently by the contract.
*
* The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each
* account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim
* an amount proportional to the percentage of total shares they were assigned. The distribution of shares is set at the
* time of contract deployment and can't be updated thereafter.
*
* `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the
* accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function.
*
* NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and
* tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you
* to run tests before sending real value to this contract.
*/
contract PaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
mapping(IERC20 => uint256) private _erc20TotalReleased;
mapping(IERC20 => mapping(address => uint256)) private _erc20Released;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor(address[] memory payees, uint256[] memory shares_) payable {
require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
/**
* @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
* reliability of the events, and not the actual splitting of Ether.
*
* To learn more about this see the Solidity documentation for
* https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
* functions].
*/
receive() external payable virtual {
emit PaymentReceived(_msgSender(), msg.value);
}
/**
* @dev Getter for the total shares held by payees.
*/
function totalShares() public view returns (uint256) {
return _totalShares;
}
/**
* @dev Getter for the total amount of Ether already released.
*/
function totalReleased() public view returns (uint256) {
return _totalReleased;
}
/**
* @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20
* contract.
*/
function totalReleased(IERC20 token) public view returns (uint256) {
return _erc20TotalReleased[token];
}
/**
* @dev Getter for the amount of shares held by an account.
*/
function shares(address account) public view returns (uint256) {
return _shares[account];
}
/**
* @dev Getter for the amount of Ether already released to a payee.
*/
function released(address account) public view returns (uint256) {
return _released[account];
}
/**
* @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an
* IERC20 contract.
*/
function released(IERC20 token, address account) public view returns (uint256) {
return _erc20Released[token][account];
}
/**
* @dev Getter for the address of the payee number `index`.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Getter for the amount of payee's releasable Ether.
*/
function releasable(address account) public view returns (uint256) {
uint256 totalReceived = address(this).balance + totalReleased();
return _pendingPayment(account, totalReceived, released(account));
}
/**
* @dev Getter for the amount of payee's releasable `token` tokens. `token` should be the address of an
* IERC20 contract.
*/
function releasable(IERC20 token, address account) public view returns (uint256) {
uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token);
return _pendingPayment(account, totalReceived, released(token, account));
}
/**
* @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
* total shares and their previous withdrawals.
*/
function release(address payable account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 payment = releasable(account);
require(payment != 0, "PaymentSplitter: account is not due payment");
_released[account] += payment;
_totalReleased += payment;
Address.sendValue(account, payment);
emit PaymentReleased(account, payment);
}
/**
* @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their
* percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20
* contract.
*/
function release(IERC20 token, address account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 payment = releasable(token, account);
require(payment != 0, "PaymentSplitter: account is not due payment");
_erc20Released[token][account] += payment;
_erc20TotalReleased[token] += payment;
SafeERC20.safeTransfer(token, account, payment);
emit ERC20PaymentReleased(token, account, payment);
}
/**
* @dev internal logic for computing the pending payment of an `account` given the token historical balances and
* already released amounts.
*/
function _pendingPayment(
address account,
uint256 totalReceived,
uint256 alreadyReleased
) private view returns (uint256) {
return (totalReceived * _shares[account]) / _totalShares - alreadyReleased;
}
/**
* @dev Add a new payee to the contract.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) private {
require(account != address(0), "PaymentSplitter: account is the zero address");
require(shares_ > 0, "PaymentSplitter: shares are 0");
require(_shares[account] == 0, "PaymentSplitter: account already has shares");
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
}
Spartan721A.sol 379 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
///@notice access control
import "@openzeppelin/contracts/access/Ownable.sol";
/// @notice libraries & utils
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/finance/PaymentSplitter.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
/// @notice ERC721, extensions & interfaces
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
/// @notice ERC721
import "./ERC721A.sol";
/*
@title Spartan Pass
@notice ERC721-ready Spartan contract
@author cryptoware.eth | Spartan
*/
contract Spartan721A is Ownable, ERC721A, Pausable, PaymentSplitter {
/// @notice using Strings for uints conversions such as => tokenId
using Strings for uint256;
/// @notice using Address for addresses extended functionality
using Address for address;
/// @notice using MerkleProof library to verify Merkle proofs
using MerkleProof for bytes32[];
/// This is a Uniform Resource Identifier, distinct used to identify each unique nft from the other.
string private _baseTokenURI;
/// @notice root of the new Merkle tree
bytes32 private _merkleRoot;
/// @notice the max supply fot SFTs and NFTs, metadata file type
string private constant _METADATA_EXTENSION = ".json";
/// @notice max amount of nfts that can be minted per wallet address
uint32 public mintingLimit;
/// @notice the mint price of each NFT
uint256 public mintPrice;
///@notice the minimum price of ethereum in dollars
uint256 public minEthPriceInDollars;
/// @notice Indicates if the mint id has been already used
mapping(bytes16 => bool) public mintId;
/// @notice indicates the amount of mints per user
mapping(address => uint256) public mintsPerUser;
///@notice Minter address that can mint to custodial
address public minterAddress;
///@notice Max token Id that can be minted;
uint256 public maxId;
/// @notice Admin mint event to be emitted when an Admin mints
event AdminMinted(
address indexed to,
uint256 indexed startToken,
uint256 quantity
);
/// @notice Mint event to be emitted upon NFT mint
event Minted(
address indexed to,
uint256 indexed startToken,
uint256 quantity
);
/// @notice Event that indicates which mint id has been used during minting
event MintIdUsed(bytes16 indexed mintId);
modifier onlyOwnerOrMinter() {
require ((owner() == msg.sender) || (minterAddress == msg.sender), "The caller of the contract is neither the owner nor the minter");
_;
}
/**
* @notice constructor
* @param name_ the token name
* @param symbol_ the token symbol
* @param uri_ token metadata URI
**/
constructor(
string memory name_,
string memory symbol_,
string memory uri_,
uint32 mintingLimit_,
uint32 maxId_,
uint256 mintPrice_,
uint256 minEthPriceInDollars_,
bytes32 root_,
address minterAddress_,
address[] memory payees_,
uint256[] memory shares_
) ERC721A(name_, symbol_) Ownable() PaymentSplitter(payees_, shares_) {
_merkleRoot = root_;
mintingLimit = mintingLimit_;
mintPrice = mintPrice_;
maxId = maxId_;
_baseTokenURI = uri_;
minterAddress = minterAddress_;
minEthPriceInDollars = minEthPriceInDollars_;
}
/// @notice pauses the contract (minting and transfers)
function pause() external virtual onlyOwner {
_pause();
}
/// @notice unpauses the contract (minting and transfers)
function unpause() external virtual onlyOwner {
_unpause();
}
/**
* @notice changes the mint amount per wallet address
* @param mintingLimit_ number of mints per wallet address
**/
function changeMintingLimitPerUser(uint32 mintingLimit_)
external
onlyOwner
{
require(
mintingLimit_ != mintingLimit,
"SPTN: Minting limit should be different from the previous value."
);
mintingLimit = mintingLimit_;
}
/**
* @notice changes the minEthPrice
* @param minterAddress_ min price of eth
**/
function changeMinterAddress (address minterAddress_) external onlyOwner{
require(
minterAddress != minterAddress_,
"SPTN: Minter address can not be same"
);
minterAddress = minterAddress_;
}
/**
* @notice changes the minEthPrice in dollars
* @param minEthPrice_ min price of eth
**/
function changeMinEthPrice(uint256 minEthPrice_) external onlyOwner {
require(
minEthPriceInDollars != minEthPrice_,
"SPTN: Min ETH Price should be different than the previous price"
);
minEthPriceInDollars = minEthPrice_;
}
/**
* @notice changes the mint price of an already existing token ID
* @param mintPrice_ new mint price of token
**/
function changeMintPriceOfToken(uint256 mintPrice_) external onlyOwner {
require(
mintPrice_ != mintPrice,
"SPTN: Mint Price should be different than the previous price"
);
mintPrice = mintPrice_;
}
/**
* @notice changes the max supply of an already existing token ID
* @param maxId_ id of token
**/
function changeMaxSupplyOfToken(uint256 maxId_) public onlyOwner {
require(
maxId_ != maxId,
"SPTN: Max Supply should be different than the previous supply"
);
maxId = maxId_;
}
/**
* @notice gets the URI per token ID
* @param tokenId token type ID to return proper URI
**/
function uri(uint256 tokenId) public view virtual returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
if (tokenId <= maxId) {
return
string(
abi.encodePacked(
_baseTokenURI,
tokenId.toString(),
_METADATA_EXTENSION
)
);
}
}
function changeBaseUri(string memory newBaseUri_) public onlyOwner{
require(
(keccak256(abi.encodePacked((newBaseUri_))) !=
keccak256(abi.encodePacked((_baseTokenURI)))),
"SPTN: Base URI cannot be same as previous"
);
_baseTokenURI = newBaseUri_;
}
/**
* @notice mints tokens based on parameters
* @param to address of the user minting
* @param amount amount of tokens to be minted
* @param proof_ verify if msg.sender is allowed to mint
* @param mintId_ mint id used to mint
**/
function mint(
address to,
uint32 amount,
bytes32[] memory proof_,
bytes16 mintId_,
uint256 currentEthPrice
) external payable whenNotPaused {
uint256 received = msg.value; //Wei
uint256 dollarsExpected = mintPrice*amount; //Dollar
uint256 minDollarsExpected = dollarsExpected-(dollarsExpected/100); //Dollar
uint256 maxDollarsExpected = dollarsExpected+(dollarsExpected/100); //Dollar
require(to != address(0), "SPTN: Address cannot be 0");
require(currentEthPrice>=minEthPriceInDollars, "SPTN: Invalid ETH Price");
require(
minDollarsExpected<= (received*currentEthPrice/1000000000000000000), //Dollar
"SPTN: Dollars sent is less than the minimum"
);
require(
(received*currentEthPrice/1000000000000000000)<=maxDollarsExpected, //Dollar
"SPTN: Dollars sent is more than the maximum"
);
require(
_currentIndex + (amount - (1)) <= maxId,
"SPTN: max SPARTAN token limit exceeded"
);
require(
mintsPerUser[to] + amount <= mintingLimit,
"SPTN: Max NFT per address exceeded"
);
require(!mintId[mintId_], "SPTN: mint id already used");
_merkleRoot > bytes32(0) && isAllowedToMint(proof_, mintId_);
mintsPerUser[to] += amount;
mintId[mintId_] = true;
uint256 startToken = _currentIndex;
_safeMint(to, amount);
emit Minted(to, startToken, amount);
emit MintIdUsed(mintId_);
}
/**
* @notice a function for admins to mint cost-free
* @param to the address to send the minted token to
* @param amount amount of tokens to be minted
**/
function adminMint(address to, uint256 amount)
external
whenNotPaused
onlyOwnerOrMinter
{
require(to != address(0), "SPTN: Address cannot be 0");
require(_currentIndex <= maxId, "SPTN: Token id mismatch");
require(amount + _currentIndex <= maxId + 1, "SPTN: Amount mismatch");
uint256 startToken = _currentIndex;
_safeMint(to, amount);
emit AdminMinted(to, startToken, amount);
}
/**
* @notice the public function validating addresses
* @param proof_ hashes validating that a leaf exists inside merkle tree aka _merkleRoot
* @param mintId_ Id sent from the db to check it this token number is minted or not
**/
function isAllowedToMint(bytes32[] memory proof_, bytes16 mintId_)
internal
view
returns (bool)
{
require(
MerkleProof.verify(
proof_,
_merkleRoot,
keccak256(abi.encodePacked(mintId_))
),
"SPTN: Please register before minting"
);
return true;
}
/**
* @notice changes merkleRoot in case whitelist list updated
* @param merkleRoot_ root of the Merkle tree
**/
function changeMerkleRoot(bytes32 merkleRoot_) external onlyOwner {
require(
merkleRoot_ != _merkleRoot,
"SPTN: Merkle root cannot be same as previous"
);
_merkleRoot = merkleRoot_;
}
/**
* @notice a burn function for burning specific tokenId
* @param tokenId Id of the Token
**/
function burn(uint256 tokenId) external {
require(_msgSender() != address(0), "SPTN: Address cannot be 0");
require(_exists(tokenId), "SPTN: Token Id does not exist");
require(
_ownershipOf(tokenId).addr == _msgSender(),
"SPTN: You do not own this token"
);
_burn(tokenId);
}
/**
* @notice a function for admins to transfer tokens
* @param from current owner of the token
* @param to new owner of the token
* @param tokenId Id of the Token
**/
function adminTransfer(
address from,
address to,
uint256 tokenId
) public onlyOwner {
require(_exists(tokenId), "SPTN: Token Id does not exist");
require(
_ownershipOf(tokenId).addr == from,
"SPTN: Address does not own this token"
);
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
_beforeTokenTransfers(from, to, tokenId, 1);
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = to;
currSlot.startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
}
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;
}
}
MerkleProof.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the merkle tree could be reinterpreted as a leaf value.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*
* _Available since v4.7._
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*
* _Available since v4.7._
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be proved to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* _Available since v4.7._
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* _Available since v4.7._
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and the sibling nodes in `proof`,
* consuming from one or the other at each step according to the instructions given by
* `proofFlags`.
*
* _Available since v4.7._
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}
*
* _Available since v4.7._
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
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);
}
SafeERC20.sol 116 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.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));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @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");
}
}
}
Strings.sol 75 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
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;
}
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
ERC721Burnable.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "../../../utils/Context.sol";
/**
* @title ERC721 Burnable Token
* @dev ERC721 Token that can be burned (destroyed).
*/
abstract contract ERC721Burnable is Context, ERC721 {
/**
* @dev Burns `tokenId`. See {ERC721-_burn}.
*
* Requirements:
*
* - The caller must own `tokenId` or be an approved operator.
*/
function burn(uint256 tokenId) public virtual {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_burn(tokenId);
}
}
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);
}
Read Contract
balanceOf 0x70a08231 → uint256
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
maxId 0xc5ea3c65 → uint256
minEthPriceInDollars 0x33f569c5 → uint256
mintId 0x39843ba9 → bool
mintPrice 0x6817c76c → uint256
minterAddress 0x34d722c9 → address
mintingLimit 0x49072f12 → uint32
mintsPerUser 0xabff9393 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
payee 0x8b83209b → address
releasable 0xa3f8eace → uint256
releasable 0xc45ac050 → uint256
released 0x406072a9 → uint256
released 0x9852595c → uint256
shares 0xce7c2ac2 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalReleased 0xd79779b2 → uint256
totalReleased 0xe33b7de3 → uint256
totalShares 0x3a98ef39 → uint256
totalSupply 0x18160ddd → uint256
uri 0x0e89341c → string
Write Contract 22 functions
These functions modify contract state and require a wallet transaction to execute.
adminMint 0xe58306f9
address to
uint256 amount
adminTransfer 0xda72c1e8
address from
address to
uint256 tokenId
approve 0x095ea7b3
address to
uint256 tokenId
burn 0x42966c68
uint256 tokenId
changeBaseUri 0x492d306b
string newBaseUri_
changeMaxSupplyOfToken 0xd5a5b140
uint256 maxId_
changeMerkleRoot 0xebcea3db
bytes32 merkleRoot_
changeMinEthPrice 0x0b5a0e2e
uint256 minEthPrice_
changeMintPriceOfToken 0xa9b4b0b7
uint256 mintPrice_
changeMinterAddress 0x2c8615b1
address minterAddress_
changeMintingLimitPerUser 0xf0e7ac18
uint32 mintingLimit_
mint 0xddc150c3
address to
uint32 amount
bytes32[] proof_
bytes16 mintId_
uint256 currentEthPrice
pause 0x8456cb59
No parameters
release 0x19165587
address account
release 0x48b75044
address token
address account
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
Recent Transactions
No transactions found for this address