Address Contract Verified
Address
0x415D66A89497ce04eb40E647ea937689859Ad8D6
Balance
0 ETH
Nonce
1
Code Size
13208 bytes
Creator
0xaBd31691...0B34 at tx 0x7896c542...145891
Indexed Transactions
0
Contract Bytecode
13208 bytes
0x6080604052600436106103595760003560e01c806370a08231116101bb578063b88d4fde116100f7578063dc2f869c11610095578063e9a7484c1161006f578063e9a7484c14610993578063f14210a6146109b3578063f2fde38b146109d3578063fcfff16f146109f357600080fd5b8063dc2f869c14610914578063dea8905614610934578063e985e9c51461094a57600080fd5b8063c87b56dd116100d1578063c87b56dd146108ab578063d5abeb01146108cb578063d657bc23146108e1578063d6d12c401461090157600080fd5b8063b88d4fde14610862578063ba1e960c14610875578063c040e6b81461089557600080fd5b80638da5cb5b11610164578063a22cb4651161013e578063a22cb465146107f4578063a2309ff814610814578063a607a8d91461082d578063afc3cb491461084257600080fd5b80638da5cb5b146107ab57806395d643a8146107c957806395d89b41146107df57600080fd5b80637b789204116101955780637b7892041461074957806385b4bb53146107695780638ba4cc3c1461078b57600080fd5b806370a08231146106f4578063715018a61461071457806373de18c51461072957600080fd5b806342842e0e116102955780636352211e116102335780636c19e7831161020d5780636c19e783146106745780636d278b29146106945780636f8b44b0146106b45780636fdca5e0146106d457600080fd5b80636352211e146106295780636619aa86146106495780636c0360eb1461065f57600080fd5b806355f804b31161026f57806355f804b3146105a957806358bd7d0d146105c95780635b8d02d7146105e9578063608006f21461060957600080fd5b806342842e0e1461056057806342966c68146105735780634d1555611461059357600080fd5b806318160ddd1161030257806333ea51a8116102dc57806333ea51a8146104ec57806335db70b51461050c5780633d9287fa146105215780633eb1d7771461054057600080fd5b806318160ddd1461049c578063238ac933146104b957806323b872dd146104d957600080fd5b8063081812fc11610333578063081812fc1461042f578063095ea7b314610467578063147d959a1461047c57600080fd5b806301ffc9a71461039d57806303e8697e146103d257806306fdde031461040d57600080fd5b3661039857604080513381523460208201527f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f88525874910160405180910390a1005b600080fd5b3480156103a957600080fd5b506103bd6103b83660046129fb565b610a0d565b60405190151581526020015b60405180910390f35b3480156103de57600080fd5b506103ff6103ed366004612a34565b60166020526000908152604090205481565b6040519081526020016103c9565b34801561041957600080fd5b50610422610a5f565b6040516103c99190612a9f565b34801561043b57600080fd5b5061044f61044a366004612ab2565b610af1565b6040516001600160a01b0390911681526020016103c9565b61047a610475366004612acb565b610b35565b005b34801561048857600080fd5b5061047a610497366004612ab2565b610bf2565b3480156104a857600080fd5b5060015460005403600019016103ff565b3480156104c557600080fd5b5060135461044f906001600160a01b031681565b61047a6104e7366004612af5565b610c9b565b3480156104f857600080fd5b5061047a610507366004612a34565b610e5b565b34801561051857600080fd5b506103ff610f0e565b34801561052d57600080fd5b506015546103bd90610100900460ff1681565b34801561054c57600080fd5b5061047a61055b366004612ab2565b610fc8565b61047a61056e366004612af5565b611057565b34801561057f57600080fd5b5061047a61058e366004612ab2565b611077565b34801561059f57600080fd5b506103ff60105481565b3480156105b557600080fd5b5061047a6105c4366004612bd4565b611083565b3480156105d557600080fd5b50600d5461044f906001600160a01b031681565b3480156105f557600080fd5b5060125461044f906001600160a01b031681565b34801561061557600080fd5b5061047a610624366004612a34565b611133565b34801561063557600080fd5b5061044f610644366004612ab2565b6111ab565b34801561065557600080fd5b506103ff60115481565b34801561066b57600080fd5b506104226111b6565b34801561068057600080fd5b5061047a61068f366004612a34565b611244565b3480156106a057600080fd5b5061047a6106af366004612ab2565b6112b2565b3480156106c057600080fd5b5061047a6106cf366004612ab2565b611341565b3480156106e057600080fd5b5061047a6106ef366004612c19565b6113a4565b34801561070057600080fd5b506103ff61070f366004612a34565b6113bf565b34801561072057600080fd5b5061047a61140e565b34801561073557600080fd5b5061047a610744366004612c34565b611422565b34801561075557600080fd5b5061047a610764366004612c19565b6114c1565b34801561077557600080fd5b5061077e6114e3565b6040516103c99190612cb2565b34801561079757600080fd5b5061047a6107a6366004612acb565b611708565b3480156107b757600080fd5b506008546001600160a01b031661044f565b3480156107d557600080fd5b506103ff600b5481565b3480156107eb57600080fd5b5061042261185b565b34801561080057600080fd5b5061047a61080f366004612e08565b61186a565b34801561082057600080fd5b50600054600019016103ff565b34801561083957600080fd5b506103ff6118d6565b34801561084e57600080fd5b5061047a61085d366004612ab2565b61195b565b61047a610870366004612e3b565b6119ea565b34801561088157600080fd5b506015546103bd9062010000900460ff1681565b3480156108a157600080fd5b506103ff60145481565b3480156108b757600080fd5b506104226108c6366004612ab2565b611a34565b3480156108d757600080fd5b506103ff600f5481565b3480156108ed57600080fd5b5061047a6108fc366004612c19565b611c36565b61047a61090f366004612ea3565b611c5a565b34801561092057600080fd5b50600c5461044f906001600160a01b031681565b34801561094057600080fd5b506103ff600e5481565b34801561095657600080fd5b506103bd610965366004612ef7565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b34801561099f57600080fd5b5061047a6109ae366004612a34565b611f84565b3480156109bf57600080fd5b5061047a6109ce366004612ab2565b612004565b3480156109df57600080fd5b5061047a6109ee366004612a34565b612157565b3480156109ff57600080fd5b506015546103bd9060ff1681565b60006301ffc9a760e01b6001600160e01b031983161480610a3e57506380ac58cd60e01b6001600160e01b03198316145b80610a595750635b5e139f60e01b6001600160e01b03198316145b92915050565b606060028054610a6e90612f21565b80601f0160208091040260200160405190810160405280929190818152602001828054610a9a90612f21565b8015610ae75780601f10610abc57610100808354040283529160200191610ae7565b820191906000526020600020905b815481529060010190602001808311610aca57829003601f168201915b5050505050905090565b6000610afc826121e4565b610b19576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b6000610b40826111ab565b9050336001600160a01b03821614610b96576001600160a01b038116600090815260076020908152604080832033845290915290205460ff16610b96576040516367d9dca160e11b815260040160405180910390fd5b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b610bfa612219565b600260095403610c3f5760405162461bcd60e51b815260206004820152601f602482015260008051602061334383398151915260448201526064015b60405180910390fd5b600260095580610c915760405162461bcd60e51b815260206004820152600860248201527f31303a70726963650000000000000000000000000000000000000000000000006044820152606401610c36565b6011556001600955565b6000610ca682612273565b9050836001600160a01b0316816001600160a01b031614610cd95760405162a1148160e81b815260040160405180910390fd5b60008281526006602052604090208054610d058187335b6001600160a01b039081169116811491141790565b610d4d576001600160a01b038616600090815260076020908152604080832033845290915290205460ff16610d4d57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b038516610d7457604051633a954ecd60e21b815260040160405180910390fd5b8015610d7f57600082555b6001600160a01b038681166000908152600560205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260046020526040812091909155600160e11b84169003610e1157600184016000818152600460205260408120549003610e0f576000548114610e0f5760008181526004602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b806001600160a01b038116610e9e5760405162461bcd60e51b815260206004820152600960248201526818981d39b4b3b732b960b91b6044820152606401610c36565b610ea6612219565b600260095403610ee65760405162461bcd60e51b815260206004820152601f60248201526000805160206133438339815191526044820152606401610c36565b50601280546001600160a01b0319166001600160a01b03929092169190911790556001600955565b6000610f186118d6565b600c60009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f6b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8f9190612f5b565b610f9a90600a613078565b601154610faf90670de0b6b3a7640000613087565b610fb99190613087565b610fc391906130b4565b905090565b610fd0612219565b6002600954036110105760405162461bcd60e51b815260206004820152601f60248201526000805160206133438339815191526044820152606401610c36565b60026009558061104d5760405162461bcd60e51b81526020600482015260086024820152670c4c0e9b1a5b5a5d60c21b6044820152606401610c36565b6014556001600955565b611072838383604051806020016040528060008152506119ea565b505050565b611080816122e9565b50565b61108b612219565b6002600954036110cb5760405162461bcd60e51b815260206004820152601f60248201526000805160206133438339815191526044820152606401610c36565b6002600955805161111e5760405162461bcd60e51b815260206004820152600660248201527f31303a75726c00000000000000000000000000000000000000000000000000006044820152606401610c36565b600a61112a828261310e565b50506001600955565b806001600160a01b0381166111765760405162461bcd60e51b815260206004820152600960248201526818981d39b4b3b732b960b91b6044820152606401610c36565b61117e612219565b50600c80546001600160a01b039092166001600160a01b03199283168117909155600d8054909216179055565b6000610a5982612273565b600a80546111c390612f21565b80601f01602080910402602001604051908101604052809291908181526020018280546111ef90612f21565b801561123c5780601f106112115761010080835404028352916020019161123c565b820191906000526020600020905b81548152906001019060200180831161121f57829003601f168201915b505050505081565b61124c612219565b806001600160a01b03811661128f5760405162461bcd60e51b815260206004820152600960248201526818981d39b4b3b732b960b91b6044820152606401610c36565b50601380546001600160a01b0319166001600160a01b0392909216919091179055565b6112ba612219565b6002600954036112fa5760405162461bcd60e51b815260206004820152601f60248201526000805160206133438339815191526044820152606401610c36565b6002600955806113375760405162461bcd60e51b81526020600482015260086024820152670c4c0e9b1a5b5a5d60c21b6044820152606401610c36565b600e556001600955565b611349612219565b6000546000190181101561139f5760405162461bcd60e51b815260206004820152601460248201527f546f74616c20737570706c7920746f6f206c6f770000000000000000000000006044820152606401610c36565b600f55565b6113ac612219565b6015805460ff1916911515919091179055565b60006001600160a01b0382166113e8576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b031660009081526005602052604090205467ffffffffffffffff1690565b611416612219565b61142060006122f4565b565b61142a612219565b60005460001901871161147f5760405162461bcd60e51b815260206004820152601460248201527f546f74616c20737570706c7920746f6f206c6f770000000000000000000000006044820152606401610c36565b600f87905560118690556010859055600e84905560148390556015805461ff00191661010084151502179055600a6114b7828261310e565b5050505050505050565b6114c9612219565b601580549115156101000261ff0019909216919091179055565b611590604051806102400160405280606081526020016060815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000151581526020016000815260200160006001600160a01b03168152602001606081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581526020016000815260200160008152602001600081525090565b60006040518061024001604052806115a6610a5f565b81526020016115b361185b565b81526013546001600160a01b0390811660208301526012548116604083015260155460ff16151560608301526014546080830152600d541660a0820152600a805460c09092019161160390612f21565b80601f016020809104026020016040519081016040528092919081815260200182805461162f90612f21565b801561167c5780601f106116515761010080835404028352916020019161167c565b820191906000526020600020905b81548152906001019060200180831161165f57829003601f168201915b50505050508152602001600b548152602001611696610f0e565b81526011546020820152600e546040820152600f5460608201526010546080820152601554610100900460ff16151560a082015260c0016116da6000546000190190565b81526020016116e860015490565b81526020016117006001546000546000199190030190565b905292915050565b611710612219565b816001600160a01b0381166117535760405162461bcd60e51b815260206004820152600960248201526818981d39b4b3b732b960b91b6044820152606401610c36565b6002600954036117935760405162461bcd60e51b815260206004820152601f60248201526000805160206133438339815191526044820152606401610c36565b6002600955816117e55760405162461bcd60e51b815260206004820152600f60248201527f32303a6d696e74696e674c696d697400000000000000000000000000000000006044820152606401610c36565b600054600019016117f690836131ce565b600f5410156118475760405162461bcd60e51b815260206004820152600c60248201527f32303a6d6178537570706c7900000000000000000000000000000000000000006044820152606401610c36565b6118518383612346565b5050600160095550565b606060038054610a6e90612f21565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600080600c60009054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa15801561192c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195091906131fb565b509195945050505050565b611963612219565b6002600954036119a35760405162461bcd60e51b815260206004820152601f60248201526000805160206133438339815191526044820152606401610c36565b6002600955806119e05760405162461bcd60e51b81526020600482015260086024820152670c4c0e9b1a5b5a5d60c21b6044820152606401610c36565b6010556001600955565b6119f5848484610c9b565b6001600160a01b0383163b15611a2e57611a1184848484612354565b611a2e576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6060611a3f826121e4565b611ab15760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610c36565b60008281526017602052604081208054611aca90612f21565b80601f0160208091040260200160405190810160405280929190818152602001828054611af690612f21565b8015611b435780601f10611b1857610100808354040283529160200191611b43565b820191906000526020600020905b815481529060010190602001808311611b2657829003601f168201915b505050505090506000600a8054611b5990612f21565b80601f0160208091040260200160405190810160405280929190818152602001828054611b8590612f21565b8015611bd25780601f10611ba757610100808354040283529160200191611bd2565b820191906000526020600020905b815481529060010190602001808311611bb557829003601f168201915b505050505090508051600003611be9575092915050565b815115611c1b578082604051602001611c0392919061324b565b60405160208183030381529060405292505050919050565b80611c2585612440565b604051602001611c0392919061324b565b611c3e612219565b60158054911515620100000262ff000019909216919091179055565b600260095403611c9a5760405162461bcd60e51b815260206004820152601f60248201526000805160206133438339815191526044820152606401610c36565b600260095560155460ff16611cf15760405162461bcd60e51b815260206004820152600f60248201527f436f6e747261637420636c6f73656400000000000000000000000000000000006044820152606401610c36565b82611cfa610f0e565b611d049190613087565b341015611d535760405162461bcd60e51b815260206004820152600960248201527f33303a616d6f756e7400000000000000000000000000000000000000000000006044820152606401610c36565b60005460001901611d6490846131ce565b600f541015611db55760405162461bcd60e51b815260206004820152600c60248201527f537570706c79206c696d697400000000000000000000000000000000000000006044820152606401610c36565b33600090815260166020526040902054611dd09084906131ce565b600e541015611e215760405162461bcd60e51b815260206004820152600d60248201527f486f6c64696e67206c696d6974000000000000000000000000000000000000006044820152606401610c36565b826010541015611e735760405162461bcd60e51b815260206004820152600f60248201527f546f6f206d616e7920746f6b656e7300000000000000000000000000000000006044820152606401610c36565b611e7f84848484612559565b611ecb5760405162461bcd60e51b815260206004820152601960248201527f57616c6c6574206973206e6f742077686974656c6973746564000000000000006044820152606401610c36565b601554610100900460ff1615611f2c576014548214611f2c5760405162461bcd60e51b815260206004820152601160248201527f54696572206973206e6f742076616c69640000000000000000000000000000006044820152606401610c36565b3360009081526016602052604081208054859290611f4b9084906131ce565b909155505060155462010000900460ff1615611f6f57611f6c600284613087565b92505b611f793384612346565b505060016009555050565b611f8c612219565b6001600160a01b038116611fe25760405162461bcd60e51b815260206004820152601060248201527f3230303a5a45524f5f41444452455353000000000000000000000000000000006044820152606401610c36565b601380546001600160a01b0319166001600160a01b0392909216919091179055565b6002600954036120445760405162461bcd60e51b815260206004820152601f60248201526000805160206133438339815191526044820152606401610c36565b6002600955612051612219565b478111156120a15760405162461bcd60e51b815260206004820152601260248201527f496e73756666696369656e742066756e647300000000000000000000000000006044820152606401610c36565b6012546001600160a01b03166120f95760405162461bcd60e51b815260206004820152600f60248201527f496e76616c6964206164647265737300000000000000000000000000000000006044820152606401610c36565b6012546040516000916001600160a01b03169083908381818185875af1925050503d8060008114612146576040519150601f19603f3d011682016040523d82523d6000602084013e61214b565b606091505b50506001600955505050565b61215f612219565b6001600160a01b0381166121db5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610c36565b611080816122f4565b6000816001111580156121f8575060005482105b8015610a59575050600090815260046020526040902054600160e01b161590565b6008546001600160a01b031633146114205760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c36565b600081806001116122d0576000548110156122d05760008181526004602052604081205490600160e01b821690036122ce575b806000036122c75750600019016000818152600460205260409020546122a6565b9392505050565b505b604051636f96cda160e11b815260040160405180910390fd5b61108081600061261b565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6123508282612782565b5050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a029061238990339089908890889060040161327a565b6020604051808303816000875af19250505080156123c4575060408051601f3d908101601f191682019092526123c1918101906132b6565b60015b612422573d8080156123f2576040519150601f19603f3d011682016040523d82523d6000602084013e6123f7565b606091505b50805160000361241a576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b6060816000036124675750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612491578061247b816132d3565b915061248a9050600a836130b4565b915061246b565b60008167ffffffffffffffff8111156124ac576124ac612b31565b6040519080825280601f01601f1916602001820160405280156124d6576020820181803683370190505b5090505b8415612438576124eb6001836132ec565b91506124f8600a866132ff565b6125039060306131ce565b60f81b81838151811061251857612518613313565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612552600a866130b4565b94506124da565b601554600090610100900460ff1661257357506001612438565b60408051336020820152908101859052606081018490526080810183905260009060a0016040516020818303038152906040528051906020012090506000816040516020016125ee91907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b604051602081830303815290604052805190602001209050612610818861279c565b979650505050505050565b600061262683612273565b90508060008061264486600090815260066020526040902080549091565b9150915084156126a157612659818433610cf0565b6126a1576001600160a01b038316600090815260076020908152604080832033845290915290205460ff166126a157604051632ce44b5f60e11b815260040160405180910390fd5b80156126ac57600082555b6001600160a01b038316600081815260056020526040902080546fffffffffffffffffffffffffffffffff0190554260a01b17600360e01b17600087815260046020526040812091909155600160e11b8516900361273a576001860160008181526004602052604081205490036127385760005481146127385760008181526004602052604090208590555b505b60405186906000906001600160a01b038616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050600180548101905550505050565b61235082826040518060200160405280600081525061287a565b60008060008084516041146127b75760009350505050610a59565b50505060208201516040830151606084015160001a601b8110156127e3576127e0601b82613329565b90505b60008160ff16601b14806127fa57508160ff16601c145b1561285f5760408051600081526020810180835289905260ff841691810191909152606081018590526080810184905260019060a0016020604051602081039080840390855afa158015612852573d6000803e3d6000fd5b5050506020604051035190505b6013546001600160a01b039182169116149695505050505050565b61288483836128e7565b6001600160a01b0383163b15611072576000548281035b6128ae6000868380600101945086612354565b6128cb576040516368d2bf6b60e11b815260040160405180910390fd5b81811061289b5781600054146128e057600080fd5b5050505050565b600080549082900361290c5760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b03831660008181526005602090815260408083208054680100000000000000018802019055848352600490915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b8181146129bb57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600101612983565b50816000036129dc57604051622e076360e81b815260040160405180910390fd5b60005550505050565b6001600160e01b03198116811461108057600080fd5b600060208284031215612a0d57600080fd5b81356122c7816129e5565b80356001600160a01b0381168114612a2f57600080fd5b919050565b600060208284031215612a4657600080fd5b6122c782612a18565b60005b83811015612a6a578181015183820152602001612a52565b50506000910152565b60008151808452612a8b816020860160208601612a4f565b601f01601f19169290920160200192915050565b6020815260006122c76020830184612a73565b600060208284031215612ac457600080fd5b5035919050565b60008060408385031215612ade57600080fd5b612ae783612a18565b946020939093013593505050565b600080600060608486031215612b0a57600080fd5b612b1384612a18565b9250612b2160208501612a18565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b600082601f830112612b5857600080fd5b813567ffffffffffffffff80821115612b7357612b73612b31565b604051601f8301601f19908116603f01168101908282118183101715612b9b57612b9b612b31565b81604052838152866020858801011115612bb457600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215612be657600080fd5b813567ffffffffffffffff811115612bfd57600080fd5b61243884828501612b47565b80358015158114612a2f57600080fd5b600060208284031215612c2b57600080fd5b6122c782612c09565b600080600080600080600060e0888a031215612c4f57600080fd5b8735965060208801359550604088013594506060880135935060808801359250612c7b60a08901612c09565b915060c088013567ffffffffffffffff811115612c9757600080fd5b612ca38a828b01612b47565b91505092959891949750929550565b6020815260008251610240806020850152612cd1610260850183612a73565b91506020850151601f1980868503016040870152612cef8483612a73565b935060408701519150612d0d60608701836001600160a01b03169052565b60608701516001600160a01b03811660808801529150608087015180151560a0880152915060a087015160c087015260c08701519150612d5860e08701836001600160a01b03169052565b60e08701519150610100818786030181880152612d758584612a73565b90880151610120888101919091528801516101408089019190915288015161016080890191909152880151610180808901919091528801516101a0808901919091528801516101c08089019190915288015190945091506101e09050612dde8187018315159052565b86015161020086810191909152860151610220808701919091529095015193019290925250919050565b60008060408385031215612e1b57600080fd5b612e2483612a18565b9150612e3260208401612c09565b90509250929050565b60008060008060808587031215612e5157600080fd5b612e5a85612a18565b9350612e6860208601612a18565b925060408501359150606085013567ffffffffffffffff811115612e8b57600080fd5b612e9787828801612b47565b91505092959194509250565b60008060008060808587031215612eb957600080fd5b843567ffffffffffffffff811115612ed057600080fd5b612edc87828801612b47565b97602087013597506040870135966060013595509350505050565b60008060408385031215612f0a57600080fd5b612f1383612a18565b9150612e3260208401612a18565b600181811c90821680612f3557607f821691505b602082108103612f5557634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215612f6d57600080fd5b815160ff811681146122c757600080fd5b634e487b7160e01b600052601160045260246000fd5b600181815b80851115612fcf578160001904821115612fb557612fb5612f7e565b80851615612fc257918102915b93841c9390800290612f99565b509250929050565b600082612fe657506001610a59565b81612ff357506000610a59565b816001811461300957600281146130135761302f565b6001915050610a59565b60ff84111561302457613024612f7e565b50506001821b610a59565b5060208310610133831016604e8410600b8410161715613052575081810a610a59565b61305c8383612f94565b806000190482111561307057613070612f7e565b029392505050565b60006122c760ff841683612fd7565b8082028115828204841417610a5957610a59612f7e565b634e487b7160e01b600052601260045260246000fd5b6000826130c3576130c361309e565b500490565b601f82111561107257600081815260208120601f850160051c810160208610156130ef5750805b601f850160051c820191505b81811015610e53578281556001016130fb565b815167ffffffffffffffff81111561312857613128612b31565b61313c816131368454612f21565b846130c8565b602080601f83116001811461317157600084156131595750858301515b600019600386901b1c1916600185901b178555610e53565b600085815260208120601f198616915b828110156131a057888601518255948401946001909101908401613181565b50858210156131be5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b80820180821115610a5957610a59612f7e565b805169ffffffffffffffffffff81168114612a2f57600080fd5b600080600080600060a0868803121561321357600080fd5b61321c866131e1565b945060208601519350604086015192506060860151915061323f608087016131e1565b90509295509295909350565b6000835161325d818460208801612a4f565b835190830190613271818360208801612a4f565b01949350505050565b60006001600160a01b038087168352808616602084015250836040830152608060608301526132ac6080830184612a73565b9695505050505050565b6000602082840312156132c857600080fd5b81516122c7816129e5565b6000600182016132e5576132e5612f7e565b5060010190565b81810381811115610a5957610a59612f7e565b60008261330e5761330e61309e565b500690565b634e487b7160e01b600052603260045260246000fd5b60ff8181168382160190811115610a5957610a59612f7e56fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00a26469706673582212201a2ce32e47cc6a0e0ccec7da249f17e0e1d9e30c87b3c54233cd65964d4b0db664736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (800 runs)
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;
}
}
PreviewMembership.sol 346 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.12;
import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract PreviewMembership is Context, ERC721A, Ownable, ReentrancyGuard {
using Strings for uint256;
string public baseURI;
uint256 public earnings;
AggregatorV3Interface public eth2usd;
address public chainlinkTarget;
uint256 public holdMax;
uint256 public maxSupply;
uint256 public mintMax;
uint256 public usdPrice;
address public payoutAddress;
address public signer;
uint256 public stage;
bool public open;
bool public whitelisted;
bool public airdropFreeToken;
mapping(address => uint256) public walletHoldings;
mapping(uint256 => string) private _tokenURIs;
event Received(address, uint256);
event WithdrawalSuccess(uint256 amount);
struct SettingsStruct {
string name;
string symbol;
address signer;
address payoutAddress;
bool open;
uint256 stage;
address chainlinkTarget;
string baseURI;
uint256 earnings;
uint256 mintPrice;
uint256 usdPrice;
uint256 holdMax;
uint256 maxSupply;
uint256 mintMax;
bool whitelisted;
uint256 totalMinted;
uint256 totalBurned;
uint256 totalSupply;
}
modifier noZeroAddress(address _address) {
require(_address != address(0), "10:signer");
_;
}
constructor(
string memory _name,
string memory _symbol,
uint256 _maxSupply,
uint256 _usdPrice,
uint256 _mintMax,
uint256 _holdMax,
address _signer,
address _payoutAddress,
address _chainlinkTarget
)
ERC721A(_name, _symbol)
noZeroAddress(_signer)
noZeroAddress(_payoutAddress)
{
usdPrice = _usdPrice;
maxSupply = _maxSupply;
mintMax = _mintMax;
holdMax = _holdMax;
signer = _signer;
payoutAddress = _payoutAddress;
open = false;
whitelisted = true;
airdropFreeToken = true;
stage = 1;
eth2usd = AggregatorV3Interface(_chainlinkTarget);
chainlinkTarget = _chainlinkTarget;
}
receive() external payable {
emit Received(msg.sender, msg.value);
}
function airdrop(
address receiver,
uint256 amount
) public onlyOwner noZeroAddress(receiver) nonReentrant {
require(amount > 0, "20:mintingLimit");
require(maxSupply >= amount + _totalMinted(), "20:maxSupply");
_buy(receiver, amount);
}
function burn(uint256 tokenId) public virtual {
super._burn(tokenId);
}
/**
* Returns the latest price
*/
function getETHPrice() public view returns (uint256) {
(, int256 price, , , ) = eth2usd.latestRoundData();
return uint256(price);
}
function mintingPrice() public view returns (uint256) {
return
(1000000000000000000 * usdPrice * 10 ** eth2usd.decimals()) /
getETHPrice();
}
function _startTokenId() internal view virtual override returns (uint256) {
return 1;
}
function totalMinted() public view returns (uint256) {
return _totalMinted();
}
function setPayoutAddress(
address _payoutAddress
) external noZeroAddress(_payoutAddress) onlyOwner nonReentrant {
payoutAddress = _payoutAddress;
}
function setBaseURI(string memory newURI) external onlyOwner nonReentrant {
require(bytes(newURI).length > 0, "10:url");
baseURI = newURI;
}
function tokenURI(
uint256 tokenId
) public view virtual override returns (string memory) {
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory _tokenURI = _tokenURIs[tokenId];
string memory base = baseURI;
// If there is no base URI, return the token URI.
if (bytes(base).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(base, _tokenURI));
}
// If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
return string(abi.encodePacked(base, tokenId.toString()));
}
function setAggregatorInterface(
address _chainlinkTarget
) external noZeroAddress(_chainlinkTarget) onlyOwner {
eth2usd = AggregatorV3Interface(_chainlinkTarget);
chainlinkTarget = _chainlinkTarget;
}
function setSigner(
address _signer
) external onlyOwner noZeroAddress(_signer) {
signer = _signer;
}
function setUSDPrice(uint256 price) public onlyOwner nonReentrant {
require(price > 0, "10:price");
usdPrice = price;
}
function setMintMax(uint256 limit) public onlyOwner nonReentrant {
require(limit > 0, "10:limit");
mintMax = limit;
}
function setStage(uint256 _stage) public onlyOwner nonReentrant {
require(_stage > 0, "10:limit");
stage = _stage;
}
function setHoldMax(uint256 limit) public onlyOwner nonReentrant {
require(limit > 0, "10:limit");
holdMax = limit;
}
function mint(
bytes memory signature,
uint256 tokenAmount,
uint256 tier,
uint256 walletLimit
) public payable nonReentrant {
require(open, "Contract closed");
require(msg.value >= mintingPrice() * tokenAmount, "30:amount");
require(maxSupply >= tokenAmount + _totalMinted(), "Supply limit");
require(
holdMax >= walletHoldings[msg.sender] + tokenAmount,
"Holding limit"
);
require(mintMax >= tokenAmount, "Too many tokens");
require(
_verify(signature, tokenAmount, tier, walletLimit),
"Wallet is not whitelisted"
);
if (whitelisted) {
require(tier == stage, "Tier is not valid");
}
walletHoldings[msg.sender] += tokenAmount;
if (airdropFreeToken) {
tokenAmount *= 2;
}
_buy(msg.sender, tokenAmount);
}
function setWhitelisted(bool _whitelisted) external onlyOwner {
whitelisted = _whitelisted;
}
function setAirdropFreeToken(bool _airdropFreeToken) external onlyOwner {
airdropFreeToken = _airdropFreeToken;
}
function setMaxSupply(uint256 _totalSupply) external onlyOwner {
require(_totalSupply >= _totalMinted(), "Total supply too low");
maxSupply = _totalSupply;
}
function setMultiple(
uint256 _maxSupply,
uint256 _usdPrice,
uint256 _mintMax,
uint256 _holdMax,
uint256 _newStage,
bool _whitelisted,
string memory _newBaseURI
) external onlyOwner {
require(_maxSupply > _totalMinted(), "Total supply too low");
maxSupply = _maxSupply;
usdPrice = _usdPrice;
mintMax = _mintMax;
holdMax = _holdMax;
stage = _newStage;
whitelisted = _whitelisted;
baseURI = _newBaseURI;
}
function withdrawETH(uint256 amount) public nonReentrant onlyOwner {
require(amount <= address(this).balance, "Insufficient funds");
require(payoutAddress != address(0), "Invalid address");
(bool success, ) = payoutAddress.call{ value: amount }("");
}
function setSecret(address _secret) external onlyOwner {
require(_secret != address(0), "200:ZERO_ADDRESS");
signer = _secret;
}
function setOpen(bool _open) external onlyOwner {
open = _open;
}
function getSettings() public view returns (SettingsStruct memory) {
SettingsStruct memory settings = SettingsStruct({
name: name(),
symbol: symbol(),
signer: signer,
payoutAddress: payoutAddress,
open: open,
stage: stage,
chainlinkTarget: chainlinkTarget,
baseURI: baseURI,
earnings: earnings,
mintPrice: mintingPrice(),
usdPrice: usdPrice,
holdMax: holdMax,
maxSupply: maxSupply,
mintMax: mintMax,
whitelisted: whitelisted,
totalMinted: _totalMinted(),
totalBurned: _totalBurned(),
totalSupply: totalSupply()
});
return settings;
}
function _buy(address to, uint256 quantity) internal {
_safeMint(to, quantity);
}
function _verifyHashSignature(
bytes32 hash,
bytes memory signature
) internal view returns (bool) {
bytes32 r;
bytes32 s;
uint8 v;
if (signature.length != 65) {
return false;
}
assembly {
r := mload(add(signature, 32))
s := mload(add(signature, 64))
v := byte(0, mload(add(signature, 96)))
}
if (v < 27) {
v += 27;
}
address recoverySigner = address(0);
// If the version is correct, gather info
if (v == 27 || v == 28) {
// solium-disable-next-line arg-overflow
recoverySigner = ecrecover(hash, v, r, s);
}
return signer == recoverySigner;
}
function _verify(
bytes memory signature,
uint256 tokenAmount,
uint256 tier,
uint256 walletLimit
) internal view returns (bool) {
if (!whitelisted) {
return true;
}
bytes32 freshHash = keccak256(
abi.encode(msg.sender, tokenAmount, tier, walletLimit)
);
bytes32 candidateHash = keccak256(
abi.encodePacked("\x19Ethereum Signed Message:\n32", freshHash)
);
return _verifyHashSignature(candidateHash, signature);
}
}
ERC721A.sol 1091 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import './IERC721A.sol';
/**
* @dev Interface of ERC721 token receiver.
*/
interface ERC721A__IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
/**
* @title ERC721A
*
* @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
* Non-Fungible Token Standard, including the Metadata extension.
* Optimized for lower gas during batch mints.
*
* Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
* starting from `_startTokenId()`.
*
* Assumptions:
*
* - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
* - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is IERC721A {
// Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).
struct TokenApprovalRef {
address value;
}
// =============================================================
// CONSTANTS
// =============================================================
// Mask of an entry in packed address data.
uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;
// The bit position of `numberMinted` in packed address data.
uint256 private constant _BITPOS_NUMBER_MINTED = 64;
// The bit position of `numberBurned` in packed address data.
uint256 private constant _BITPOS_NUMBER_BURNED = 128;
// The bit position of `aux` in packed address data.
uint256 private constant _BITPOS_AUX = 192;
// Mask of all 256 bits in packed address data except the 64 bits for `aux`.
uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;
// The bit position of `startTimestamp` in packed ownership.
uint256 private constant _BITPOS_START_TIMESTAMP = 160;
// The bit mask of the `burned` bit in packed ownership.
uint256 private constant _BITMASK_BURNED = 1 << 224;
// The bit position of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;
// The bit mask of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;
// The bit position of `extraData` in packed ownership.
uint256 private constant _BITPOS_EXTRA_DATA = 232;
// Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;
// The mask of the lower 160 bits for addresses.
uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;
// The maximum `quantity` that can be minted with {_mintERC2309}.
// This limit is to prevent overflows on the address data entries.
// For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
// is required to cause an overflow, which is unrealistic.
uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;
// The `Transfer` event signature is given by:
// `keccak256(bytes("Transfer(address,address,uint256)"))`.
bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
// =============================================================
// STORAGE
// =============================================================
// The next token ID to be minted.
uint256 private _currentIndex;
// The number of tokens burned.
uint256 private _burnCounter;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned.
// See {_packedOwnershipOf} implementation for details.
//
// Bits Layout:
// - [0..159] `addr`
// - [160..223] `startTimestamp`
// - [224] `burned`
// - [225] `nextInitialized`
// - [232..255] `extraData`
mapping(uint256 => uint256) private _packedOwnerships;
// Mapping owner address to address data.
//
// Bits Layout:
// - [0..63] `balance`
// - [64..127] `numberMinted`
// - [128..191] `numberBurned`
// - [192..255] `aux`
mapping(address => uint256) private _packedAddressData;
// Mapping from token ID to approved address.
mapping(uint256 => TokenApprovalRef) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// =============================================================
// CONSTRUCTOR
// =============================================================
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
}
// =============================================================
// TOKEN COUNTING OPERATIONS
// =============================================================
/**
* @dev Returns the starting token ID.
* To change the starting token ID, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev Returns the next token ID to be minted.
*/
function _nextTokenId() internal view virtual returns (uint256) {
return _currentIndex;
}
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() public view virtual override returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than `_currentIndex - _startTokenId()` times.
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
/**
* @dev Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view virtual returns (uint256) {
// Counter underflow is impossible as `_currentIndex` does not decrement,
// and it is initialized to `_startTokenId()`.
unchecked {
return _currentIndex - _startTokenId();
}
}
/**
* @dev Returns the total number of tokens burned.
*/
function _totalBurned() internal view virtual returns (uint256) {
return _burnCounter;
}
// =============================================================
// ADDRESS DATA OPERATIONS
// =============================================================
/**
* @dev Returns the number of tokens in `owner`'s account.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
}
/**
* Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
* If there are multiple variables, please pack them into a uint64.
*/
function _setAux(address owner, uint64 aux) internal virtual {
uint256 packed = _packedAddressData[owner];
uint256 auxCasted;
// Cast `aux` with assembly to avoid redundant masking.
assembly {
auxCasted := aux
}
packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
_packedAddressData[owner] = packed;
}
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
// The interface IDs are constants representing the first 4 bytes
// of the XOR of all function selectors in the interface.
// See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
// (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
return
interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
}
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @dev Returns the token collection name.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the token collection symbol.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, it can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
// =============================================================
// OWNERSHIPS OPERATIONS
// =============================================================
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
return address(uint160(_packedOwnershipOf(tokenId)));
}
/**
* @dev Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around over time.
*/
function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnershipOf(tokenId));
}
/**
* @dev Returns the unpacked `TokenOwnership` struct at `index`.
*/
function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnerships[index]);
}
/**
* @dev Initializes the ownership slot minted at `index` for efficiency purposes.
*/
function _initializeOwnershipAt(uint256 index) internal virtual {
if (_packedOwnerships[index] == 0) {
_packedOwnerships[index] = _packedOwnershipOf(index);
}
}
/**
* Returns the packed ownership data of `tokenId`.
*/
function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr)
if (curr < _currentIndex) {
uint256 packed = _packedOwnerships[curr];
// If not burned.
if (packed & _BITMASK_BURNED == 0) {
// Invariant:
// There will always be an initialized ownership slot
// (i.e. `ownership.addr != address(0) && ownership.burned == false`)
// before an unintialized ownership slot
// (i.e. `ownership.addr == address(0) && ownership.burned == false`)
// Hence, `curr` will not underflow.
//
// We can directly compare the packed value.
// If the address is zero, packed will be zero.
while (packed == 0) {
packed = _packedOwnerships[--curr];
}
return packed;
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev Returns the unpacked `TokenOwnership` struct from `packed`.
*/
function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
ownership.addr = address(uint160(packed));
ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
ownership.burned = packed & _BITMASK_BURNED != 0;
ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
}
/**
* @dev Packs ownership data into a single uint256.
*/
function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
}
}
/**
* @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
*/
function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
// For branchless setting of the `nextInitialized` flag.
assembly {
// `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
}
}
// =============================================================
// APPROVAL OPERATIONS
// =============================================================
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the
* zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) public payable virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId].value;
}
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom}
* for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_operatorApprovals[_msgSenderERC721A()][operator] = approved;
emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
}
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted. See {_mint}.
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return
_startTokenId() <= tokenId &&
tokenId < _currentIndex && // If within bounds,
_packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
}
/**
* @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
*/
function _isSenderApprovedOrOwner(
address approvedAddress,
address owner,
address msgSender
) private pure returns (bool result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
msgSender := and(msgSender, _BITMASK_ADDRESS)
// `msgSender == owner || msgSender == approvedAddress`.
result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
}
}
/**
* @dev Returns the storage slot and value for the approved address of `tokenId`.
*/
function _getApprovedSlotAndAddress(uint256 tokenId)
private
view
returns (uint256 approvedAddressSlot, address approvedAddress)
{
TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
// The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.
assembly {
approvedAddressSlot := tokenApproval.slot
approvedAddress := sload(approvedAddressSlot)
}
}
// =============================================================
// TRANSFER OPERATIONS
// =============================================================
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token
* by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public payable virtual override {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
unchecked {
// We can directly increment and decrement the balances.
--_packedAddressData[from]; // Updates: `balance -= 1`.
++_packedAddressData[to]; // Updates: `balance += 1`.
// Updates:
// - `address` to the next owner.
// - `startTimestamp` to the timestamp of transfering.
// - `burned` to `false`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
to,
_BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public payable virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token
* by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement
* {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public payable virtual override {
transferFrom(from, to, tokenId);
if (to.code.length != 0)
if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Hook that is called before a set of serially-ordered token IDs
* are about to be transferred. This includes minting.
* And also called before burning one token.
*
* `startTokenId` - the first token ID to be transferred.
* `quantity` - the amount to be transferred.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token IDs
* have been transferred. This includes minting.
* And also called after one token has been burned.
*
* `startTokenId` - the first token ID to be transferred.
* `quantity` - the amount to be transferred.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
* transferred to `to`.
* - When `from` is zero, `tokenId` has been minted for `to`.
* - When `to` is zero, `tokenId` has been burned by `from`.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* `from` - Previous owner of the given token ID.
* `to` - Target address that will receive the token.
* `tokenId` - Token ID to be transferred.
* `_data` - Optional data to send along with the call.
*
* Returns whether the call correctly returned the expected magic value.
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
bytes4 retval
) {
return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
// =============================================================
// MINT OPERATIONS
// =============================================================
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event for each mint.
*/
function _mint(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// `balance` and `numberMinted` have a maximum limit of 2**64.
// `tokenId` has a maximum limit of 2**256.
unchecked {
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
uint256 toMasked;
uint256 end = startTokenId + quantity;
// Use assembly to loop and emit the `Transfer` event for gas savings.
// The duplicated `log4` removes an extra check and reduces stack juggling.
// The assembly, together with the surrounding Solidity code, have been
// delicately arranged to nudge the compiler into producing optimized opcodes.
assembly {
// Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
toMasked := and(to, _BITMASK_ADDRESS)
// Emit the `Transfer` event.
log4(
0, // Start of data (0, since no data).
0, // End of data (0, since no data).
_TRANSFER_EVENT_SIGNATURE, // Signature.
0, // `address(0)`.
toMasked, // `to`.
startTokenId // `tokenId`.
)
// The `iszero(eq(,))` check ensures that large values of `quantity`
// that overflows uint256 will make the loop run out of gas.
// The compiler will optimize the `iszero` away for performance.
for {
let tokenId := add(startTokenId, 1)
} iszero(eq(tokenId, end)) {
tokenId := add(tokenId, 1)
} {
// Emit the `Transfer` event. Similar to above.
log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
}
}
if (toMasked == 0) revert MintToZeroAddress();
_currentIndex = end;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* This function is intended for efficient minting only during contract creation.
*
* It emits only one {ConsecutiveTransfer} as defined in
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
* instead of a sequence of {Transfer} event(s).
*
* Calling this function outside of contract creation WILL make your contract
* non-compliant with the ERC721 standard.
* For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
* {ConsecutiveTransfer} event is only permissible during contract creation.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {ConsecutiveTransfer} event.
*/
function _mintERC2309(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are unrealistic due to the above check for `quantity` to be below the limit.
unchecked {
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);
_currentIndex = startTokenId + quantity;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement
* {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* See {_mint}.
*
* Emits a {Transfer} event for each mint.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
_mint(to, quantity);
unchecked {
if (to.code.length != 0) {
uint256 end = _currentIndex;
uint256 index = end - quantity;
do {
if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (index < end);
// Reentrancy protection.
if (_currentIndex != end) revert();
}
}
}
/**
* @dev Equivalent to `_safeMint(to, quantity, '')`.
*/
function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, '');
}
// =============================================================
// BURN OPERATIONS
// =============================================================
/**
* @dev Equivalent to `_burn(tokenId, false)`.
*/
function _burn(uint256 tokenId) internal virtual {
_burn(tokenId, false);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
address from = address(uint160(prevOwnershipPacked));
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
if (approvalCheck) {
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
unchecked {
// Updates:
// - `balance -= 1`.
// - `numberBurned += 1`.
//
// We can directly decrement the balance, and increment the number burned.
// This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
_packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;
// Updates:
// - `address` to the last owner.
// - `startTimestamp` to the timestamp of burning.
// - `burned` to `true`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
from,
(_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
// =============================================================
// EXTRA DATA OPERATIONS
// =============================================================
/**
* @dev Directly sets the extra data for the ownership data `index`.
*/
function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
uint256 packed = _packedOwnerships[index];
if (packed == 0) revert OwnershipNotInitializedForExtraData();
uint256 extraDataCasted;
// Cast `extraData` with assembly to avoid redundant masking.
assembly {
extraDataCasted := extraData
}
packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
_packedOwnerships[index] = packed;
}
/**
* @dev Called during each token transfer to set the 24bit `extraData` field.
* Intended to be overridden by the cosumer contract.
*
* `previousExtraData` - the value of `extraData` before transfer.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _extraData(
address from,
address to,
uint24 previousExtraData
) internal view virtual returns (uint24) {}
/**
* @dev Returns the next extra data for the packed ownership data.
* The returned result is shifted into position.
*/
function _nextExtraData(
address from,
address to,
uint256 prevOwnershipPacked
) private view returns (uint256) {
uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
}
// =============================================================
// OTHER OPERATIONS
// =============================================================
/**
* @dev Returns the message sender (defaults to `msg.sender`).
*
* If you are writing GSN compatible contracts, you need to override this function.
*/
function _msgSenderERC721A() internal view virtual returns (address) {
return msg.sender;
}
/**
* @dev Converts a uint256 to its ASCII string decimal representation.
*/
function _toString(uint256 value) internal pure virtual returns (string memory str) {
assembly {
// The maximum value of a uint256 contains 78 digits (1 byte per digit), but
// we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
// We will need 1 word for the trailing zeros padding, 1 word for the length,
// and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
let m := add(mload(0x40), 0xa0)
// Update the free memory pointer to allocate.
mstore(0x40, m)
// Assign the `str` to the end.
str := sub(m, 0x20)
// Zeroize the slot after the string.
mstore(str, 0)
// Cache the end of the memory to calculate the length later.
let end := str
// We write the string from rightmost digit to leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
// prettier-ignore
for { let temp := value } 1 {} {
str := sub(str, 1)
// Write the character to the pointer.
// The ASCII index of the '0' character is 48.
mstore8(str, add(48, mod(temp, 10)))
// Keep dividing `temp` until zero.
temp := div(temp, 10)
// prettier-ignore
if iszero(temp) { break }
}
let length := sub(end, str)
// Move the pointer 32 bytes leftwards to make room for the length.
str := sub(str, 0x20)
// Store the length.
mstore(str, length)
}
}
}
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);
}
}
AggregatorV3Interface.sol 32 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function getRoundData(uint80 _roundId)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}
IERC721A.sol 282 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs
pragma solidity ^0.8.4;
/**
* @dev Interface of ERC721A.
*/
interface IERC721A {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* Cannot query the balance for the zero address.
*/
error BalanceQueryForZeroAddress();
/**
* Cannot mint to the zero address.
*/
error MintToZeroAddress();
/**
* The quantity of tokens minted must be more than zero.
*/
error MintZeroQuantity();
/**
* The token does not exist.
*/
error OwnerQueryForNonexistentToken();
/**
* The caller must own the token or be an approved operator.
*/
error TransferCallerNotOwnerNorApproved();
/**
* The token must be owned by `from`.
*/
error TransferFromIncorrectOwner();
/**
* Cannot safely transfer to a contract that does not implement the
* ERC721Receiver interface.
*/
error TransferToNonERC721ReceiverImplementer();
/**
* Cannot transfer to the zero address.
*/
error TransferToZeroAddress();
/**
* The token does not exist.
*/
error URIQueryForNonexistentToken();
/**
* The `quantity` minted with ERC2309 exceeds the safety limit.
*/
error MintERC2309QuantityExceedsLimit();
/**
* The `extraData` cannot be set on an unintialized ownership slot.
*/
error OwnershipNotInitializedForExtraData();
// =============================================================
// STRUCTS
// =============================================================
struct TokenOwnership {
// The address of the owner.
address addr;
// Stores the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
// Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
uint24 extraData;
}
// =============================================================
// TOKEN COUNTERS
// =============================================================
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() external view returns (uint256);
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
// =============================================================
// IERC721
// =============================================================
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables
* (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in `owner`'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`,
* checking first that contract recipients are aware of the ERC721 protocol
* to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move
* this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement
* {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external payable;
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom}
* whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token
* by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the
* zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external payable;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom}
* for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
// =============================================================
// IERC2309
// =============================================================
/**
* @dev Emitted when tokens in `fromTokenId` to `toTokenId`
* (inclusive) is transferred from `from` to `to`, as defined in the
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
*
* See {_mintERC2309} for more details.
*/
event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}
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);
}
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
Read Contract
airdropFreeToken 0xba1e960c → bool
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
chainlinkTarget 0x58bd7d0d → address
earnings 0x95d643a8 → uint256
eth2usd 0xdc2f869c → address
getApproved 0x081812fc → address
getETHPrice 0xa607a8d9 → uint256
getSettings 0x85b4bb53 → tuple
holdMax 0xdea89056 → uint256
isApprovedForAll 0xe985e9c5 → bool
maxSupply 0xd5abeb01 → uint256
mintMax 0x4d155561 → uint256
mintingPrice 0x35db70b5 → uint256
name 0x06fdde03 → string
open 0xfcfff16f → bool
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
payoutAddress 0x5b8d02d7 → address
signer 0x238ac933 → address
stage 0xc040e6b8 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalMinted 0xa2309ff8 → uint256
totalSupply 0x18160ddd → uint256
usdPrice 0x6619aa86 → uint256
walletHoldings 0x03e8697e → uint256
whitelisted 0x3d9287fa → bool
Write Contract 25 functions
These functions modify contract state and require a wallet transaction to execute.
airdrop 0x8ba4cc3c
address receiver
uint256 amount
approve 0x095ea7b3
address to
uint256 tokenId
burn 0x42966c68
uint256 tokenId
mint 0xd6d12c40
bytes signature
uint256 tokenAmount
uint256 tier
uint256 walletLimit
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setAggregatorInterface 0x608006f2
address _chainlinkTarget
setAirdropFreeToken 0xd657bc23
bool _airdropFreeToken
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string newURI
setHoldMax 0x6d278b29
uint256 limit
setMaxSupply 0x6f8b44b0
uint256 _totalSupply
setMintMax 0xafc3cb49
uint256 limit
setMultiple 0x73de18c5
uint256 _maxSupply
uint256 _usdPrice
uint256 _mintMax
uint256 _holdMax
uint256 _newStage
bool _whitelisted
string _newBaseURI
setOpen 0x6fdca5e0
bool _open
setPayoutAddress 0x33ea51a8
address _payoutAddress
setSecret 0xe9a7484c
address _secret
setSigner 0x6c19e783
address _signer
setStage 0x3eb1d777
uint256 _stage
setUSDPrice 0x147d959a
uint256 price
setWhitelisted 0x7b789204
bool _whitelisted
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdrawETH 0xf14210a6
uint256 amount
Recent Transactions
No transactions found for this address