Address Contract Verified
Address
0x8Ff2e72f8FAF05384aEB501Ba9644C9759d2Fd5F
Balance
0 ETH
Nonce
1
Code Size
20516 bytes
Creator
0x1657C495...4760 at tx 0xa65ca364...4f6610
Last Active
Indexed Transactions
2 (24,314,580 → 24,314,753)
Gas Used (indexed)
75,232
Contract Bytecode
20516 bytes
0x6080604052600436106103605760003560e01c806358834f01116101c657806398c2fa07116100f7578063c87b56dd11610095578063de210ab31161006f578063de210ab314610a81578063e985e9c514610a96578063e9bd993a14610adf578063f2fde38b14610aff57600080fd5b8063c87b56dd14610a13578063d207a9db14610a33578063d5abeb0114610a4857600080fd5b8063a32dced4116100d1578063a32dced41461099d578063aa1b103f146109be578063b88d4fde146109d3578063c1230ecf146109f357600080fd5b806398c2fa071461092d5780639ac2a0111461094d578063a22cb4651461097d57600080fd5b8063715018a61161016457806382f691051161013e57806382f69105146108d25780638c33d544146108e75780638da5cb5b146108fa57806395d89b411461091857600080fd5b8063715018a61461087d578063751c3f51146108925780637530fbec146108b257600080fd5b8063645bef2d116101a0578063645bef2d146107fb57806366868aad1461081a5780636c0360eb1461083a57806370a082311461084f57600080fd5b806358834f01146107845780635bfac41f146107a45780636352211e146107db57600080fd5b80632e37eef6116102a05780634c1003211161023e5780635437988d116102185780635437988d14610704578063544267bd1461072457806355f804b314610744578063562e438b1461076457600080fd5b80634c100321146106aa5780634e49e193146106ca57806351830227146106ea57600080fd5b80633d6a57451161027a5780633d6a5745146106375780633f84ac0e1461065757806342842e0e1461066a57806348ed94b61461068a57600080fd5b80632e37eef61461057057806330301b31146106025780633ccfd60b1461062257600080fd5b80631080a0b21161030d5780632af80c51116102e75780632af80c51146104e85780632b7ac3f3146105085780632ca4b209146105305780632cf9c1861461055057600080fd5b80631080a0b21461046957806323b872dd146104895780632a55205a146104a957600080fd5b8063081812fc1161033e578063081812fc146103de578063095ea7b3146104165780630c394aac1461043657600080fd5b806301ffc9a714610365578063030420d51461039a57806306fdde03146103bc575b600080fd5b34801561037157600080fd5b50610385610380366004614240565b610b1f565b60405190151581526020015b60405180910390f35b3480156103a657600080fd5b506103ba6103b53660046142a6565b610b30565b005b3480156103c857600080fd5b506103d1610bbb565b6040516103919190614338565b3480156103ea57600080fd5b506103fe6103f936600461434b565b610c4d565b6040516001600160a01b039091168152602001610391565b34801561042257600080fd5b506103ba610431366004614380565b610c74565b34801561044257600080fd5b506104566104513660046143aa565b610d6a565b60405161ffff9091168152602001610391565b34801561047557600080fd5b506103ba61048436600461441b565b610e06565b34801561049557600080fd5b506103ba6104a4366004614487565b610f68565b3480156104b557600080fd5b506104c96104c43660046144c3565b611073565b604080516001600160a01b039093168352602083019190915201610391565b3480156104f457600080fd5b506103ba6105033660046142a6565b611152565b34801561051457600080fd5b506009546103fe9064010000000090046001600160a01b031681565b34801561053c57600080fd5b506103ba61054b3660046142a6565b6111d3565b34801561055c57600080fd5b506103ba61056b366004614501565b611254565b34801561057c57600080fd5b5061059061058b36600461434b565b6112d3565b60408051845161ffff90811682526020808701518216908301528583015163ffffffff90811693830193909352606080870151909316928201929092526080948501516fffffffffffffffffffffffffffffffff169481019490945291821660a08401521660c082015260e001610391565b34801561060e57600080fd5b506103ba61061d366004614556565b61137e565b34801561062e57600080fd5b506103ba6113be565b34801561064357600080fd5b506103ba610652366004614380565b61140d565b6103ba610665366004614583565b61146f565b34801561067657600080fd5b506103ba610685366004614487565b61179e565b34801561069657600080fd5b506103ba6106a536600461434b565b61189e565b3480156106b657600080fd5b506103ba6106c5366004614556565b611926565b3480156106d657600080fd5b506103ba6106e53660046145ba565b61195f565b3480156106f657600080fd5b506009546103859060ff1681565b34801561071057600080fd5b506103ba61071f3660046145e4565b6119dd565b34801561073057600080fd5b506009546103859062010000900460ff1681565b34801561075057600080fd5b506103ba61075f3660046142a6565b611a7d565b34801561077057600080fd5b506103ba61077f3660046145ff565b611afe565b34801561079057600080fd5b506103ba61079f366004614556565b611baf565b3480156107b057600080fd5b50600954610456907801000000000000000000000000000000000000000000000000900461ffff1681565b3480156107e757600080fd5b506103fe6107f636600461434b565b611bf0565b34801561080757600080fd5b5060095461038590610100900460ff1681565b34801561082657600080fd5b506103ba610835366004614634565b611c55565b34801561084657600080fd5b506103d1611d74565b34801561085b57600080fd5b5061086f61086a3660046145e4565b611e02565b604051908152602001610391565b34801561088957600080fd5b506103ba611e9c565b34801561089e57600080fd5b506103d16108ad36600461434b565b611eb0565b3480156108be57600080fd5b506103ba6108cd366004614658565b611ec9565b3480156108de57600080fd5b506103d1611f4b565b6103ba6108f5366004614674565b611f58565b34801561090657600080fd5b506000546001600160a01b03166103fe565b34801561092457600080fd5b506103d161236d565b34801561093957600080fd5b5061059061094836600461434b565b61237c565b34801561095957600080fd5b506103856109683660046145e4565b60106020526000908152604090205460ff1681565b34801561098957600080fd5b506103ba6109983660046146e7565b6124b2565b3480156109a957600080fd5b50600954610385906301000000900460ff1681565b3480156109ca57600080fd5b506103ba6125a8565b3480156109df57600080fd5b506103ba6109ee366004614773565b612626565b3480156109ff57600080fd5b506103ba610a0e366004614556565b61272d565b348015610a1f57600080fd5b506103d1610a2e36600461434b565b61276c565b348015610a3f57600080fd5b506103d1612927565b348015610a5457600080fd5b50600954610456907a010000000000000000000000000000000000000000000000000000900461ffff1681565b348015610a8d57600080fd5b506103d1612934565b348015610aa257600080fd5b50610385610ab1366004614833565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b348015610aeb57600080fd5b506103ba610afa36600461485d565b612941565b348015610b0b57600080fd5b506103ba610b1a3660046145e4565b6129ce565b6000610b2a82612a5b565b92915050565b3360009081526010602052604090205460ff1680610b5857506000546001600160a01b031633145b610ba95760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f776564206f70657261746f7200000000000000000000000060448201526064015b60405180910390fd5b600d610bb68284836149b7565b505050565b606060018054610bca9061491c565b80601f0160208091040260200160405190810160405280929190818152602001828054610bf69061491c565b8015610c435780601f10610c1857610100808354040283529160200191610c43565b820191906000526020600020905b815481529060010190602001808311610c2657829003601f168201915b5050505050905090565b6000610c5882612ab1565b506000908152600560205260409020546001600160a01b031690565b816daaeb6d7670e522a718067333cd4e3b15610d60576040517fc61711340000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03821660248201526daaeb6d7670e522a718067333cd4e9063c617113490604401602060405180830381865afa158015610cfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1f9190614a77565b610d60576040517fede71dcc0000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610ba0565b610bb68383612b15565b600f546000908310610dbe5760405162461bcd60e51b815260206004820152601060248201527f496e76616c6964207068617365206964000000000000000000000000000000006044820152606401610ba0565b600f8381548110610dd157610dd1614a94565b600091825260208083206001600160a01b03861684526002600390930201919091019052604090205461ffff16905092915050565b3360009081526010602052604090205460ff1680610e2e57506000546001600160a01b031633145b610e7a5760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f776564206f70657261746f720000000000000000000000006044820152606401610ba0565b828114610ec95760405162461bcd60e51b815260206004820152600e60248201527f496e707574206d69736d617463680000000000000000000000000000000000006044820152606401610ba0565b60005b61ffff8116841115610f615782828261ffff16818110610eee57610eee614a94565b9050602002810190610f009190614ac3565b600e600088888661ffff16818110610f1a57610f1a614a94565b9050602002016020810190610f2f91906145ff565b61ffff1681526020019081526020016000209182610f4e9291906149b7565b5080610f5981614b57565b915050610ecc565b5050505050565b826daaeb6d7670e522a718067333cd4e3b1561106257336001600160a01b03821603610f9e57610f99848484612c41565b61106d565b6040517fc61711340000000000000000000000000000000000000000000000000000000081523060048201523360248201526daaeb6d7670e522a718067333cd4e9063c617113490604401602060405180830381865afa158015611006573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102a9190614a77565b611062576040517fede71dcc000000000000000000000000000000000000000000000000000000008152336004820152602401610ba0565b61106d848484612c41565b50505050565b60008281526008602090815260408083208151808301909252546001600160a01b038116808352740100000000000000000000000000000000000000009091046bffffffffffffffffffffffff169282019290925282916111145750604080518082019091526007546001600160a01b03811682527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1660208201525b602081015160009061271090611138906bffffffffffffffffffffffff1687614b78565b6111429190614b8f565b91519350909150505b9250929050565b3360009081526010602052604090205460ff168061117a57506000546001600160a01b031633145b6111c65760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f776564206f70657261746f720000000000000000000000006044820152606401610ba0565b600c610bb68284836149b7565b3360009081526010602052604090205460ff16806111fb57506000546001600160a01b031633145b6112475760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f776564206f70657261746f720000000000000000000000006044820152606401610ba0565b600a610bb68284836149b7565b3360009081526010602052604090205460ff168061127c57506000546001600160a01b031633145b6112c85760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f776564206f70657261746f720000000000000000000000006044820152606401610ba0565b610bb6838383612cc8565b600f81815481106112e357600080fd5b60009182526020918290206040805160a0810182526003909302909101805461ffff80821685526201000080830482169686019690965263ffffffff640100000000830481169486019490945268010000000000000000820490931660608501526fffffffffffffffffffffffffffffffff6c0100000000000000000000000090910416608084015260010154919350818116929091041683565b611386612e04565b6009805491151562010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff909216919091179055565b6113c6612e04565b604051479073961e3f37ce55799e27c1e8cee24305fccfe7591c9082156108fc029083906000818181858888f19350505050158015611409573d6000803e3d6000fd5b5050565b611415612e04565b600081116114655760405162461bcd60e51b815260206004820152600e60248201527f496e76616c696420616d6f756e740000000000000000000000000000000000006044820152606401610ba0565b6114098282612e5e565b6000600f60008154811061148557611485614a94565b9060005260206000209060030201905060008261ffff16116114e95760405162461bcd60e51b815260206004820152600e60248201527f496e76616c696420616d6f756e740000000000000000000000000000000000006044820152606401610ba0565b600181015461150390839062010000900461ffff16614bca565b815461ffff9182169116101561155b5760405162461bcd60e51b815260206004820152600f60248201527f457863656564207175616e7469747900000000000000000000000000000000006044820152606401610ba0565b80544264010000000090910463ffffffff1611156115bb5760405162461bcd60e51b815260206004820152600b60248201527f4e6f7420737461727465640000000000000000000000000000000000000000006044820152606401610ba0565b8054426801000000000000000090910463ffffffff16101561161f5760405162461bcd60e51b815260206004820152600560248201527f456e6465640000000000000000000000000000000000000000000000000000006044820152606401610ba0565b805461ffff8084166201000090920416101561167d5760405162461bcd60e51b815260206004820152601260248201527f457863656564206d6178207065722074786e00000000000000000000000000006044820152606401610ba0565b805434906116b29061ffff8516906c0100000000000000000000000090046fffffffffffffffffffffffffffffffff16614bec565b6fffffffffffffffffffffffffffffffff16146117115760405162461bcd60e51b815260206004820152600d60248201527f496e76616c6964207072696365000000000000000000000000000000000000006044820152606401610ba0565b818160010160028282829054906101000a900461ffff166117329190614bca565b82546101009290920a61ffff8181021990931691831602179091556001600160a01b038516600090815260028401602052604081208054869450909261177a91859116614bca565b92506101000a81548161ffff021916908361ffff160217905550610bb68383612e5e565b826daaeb6d7670e522a718067333cd4e3b1561189357336001600160a01b038216036117cf57610f99848484612f8e565b6040517fc61711340000000000000000000000000000000000000000000000000000000081523060048201523360248201526daaeb6d7670e522a718067333cd4e9063c617113490604401602060405180830381865afa158015611837573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185b9190614a77565b611893576040517fede71dcc000000000000000000000000000000000000000000000000000000008152336004820152602401610ba0565b61106d848484612f8e565b3360009081526010602052604090205460ff16806118c657506000546001600160a01b031633145b6119125760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f776564206f70657261746f720000000000000000000000006044820152606401610ba0565b600090815260086020526040812055565b50565b61192e612e04565b600980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b3360009081526010602052604090205460ff168061198757506000546001600160a01b031633145b6119d35760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f776564206f70657261746f720000000000000000000000006044820152606401610ba0565b6114098282612fa9565b6119e5612e04565b6001600160a01b038116611a3b5760405162461bcd60e51b815260206004820152601060248201527f496e76616c6964207665726966696572000000000000000000000000000000006044820152606401610ba0565b600980546001600160a01b03909216640100000000027fffffffffffffffff0000000000000000000000000000000000000000ffffffff909216919091179055565b3360009081526010602052604090205460ff1680611aa557506000546001600160a01b031633145b611af15760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f776564206f70657261746f720000000000000000000000006044820152606401610ba0565b600b610bb68284836149b7565b611b06612e04565b6115b38161ffff161115611b5c5760405162461bcd60e51b815260206004820152601260248201527f496e76616c6964206d617820737570706c7900000000000000000000000000006044820152606401610ba0565b6009805461ffff9092167a010000000000000000000000000000000000000000000000000000027fffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179055565b611bb7612e04565b600980549115156301000000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffff909216919091179055565b6000818152600360205260408120546001600160a01b031680610b2a5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610ba0565b611c5d612e04565b600f548210611cae5760405162461bcd60e51b815260206004820152601060248201527f496e76616c6964207068617365206964000000000000000000000000000000006044820152606401610ba0565b611cb7816130d4565b80600f8381548110611ccb57611ccb614a94565b60009182526020909120600390910201611ce58282614c5d565b905050600f8281548110611cfb57611cfb614a94565b600091825260208220600160039092020101805461ffff1691611d1d83614b57565b91906101000a81548161ffff021916908361ffff16021790555050817f73da8dc029e8d1af33de96857b35387bfbcedd281ee27e08c798a454a69eeb5982604051611d689190614dd3565b60405180910390a25050565b600b8054611d819061491c565b80601f0160208091040260200160405190810160405280929190818152602001828054611dad9061491c565b8015611dfa5780601f10611dcf57610100808354040283529160200191611dfa565b820191906000526020600020905b815481529060010190602001808311611ddd57829003601f168201915b505050505081565b60006001600160a01b038216611e805760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152608401610ba0565b506001600160a01b031660009081526004602052604090205490565b611ea4612e04565b611eae6000613275565b565b600e6020526000908152604090208054611d819061491c565b611ed1612e04565b611eda816130d4565b600f80546001810180835560008390529091839183908110611efe57611efe614a94565b60009182526020909120600390910201611f188282614c5d565b905050807f73da8dc029e8d1af33de96857b35387bfbcedd281ee27e08c798a454a69eeb5983604051611d689190614dd3565b600c8054611d819061491c565b33328114611fa85760405162461bcd60e51b815260206004820152600b60248201527f4e6f7420616c6c6f7765640000000000000000000000000000000000000000006044820152606401610ba0565b6000600f8781548110611fbd57611fbd614a94565b9060005260206000209060030201905060008661ffff16116120215760405162461bcd60e51b815260206004820152600e60248201527f496e76616c696420616d6f756e740000000000000000000000000000000000006044820152606401610ba0565b600181015461203b90879062010000900461ffff16614bca565b815461ffff918216911610156120935760405162461bcd60e51b815260206004820152600f60248201527f457863656564207175616e7469747900000000000000000000000000000000006044820152606401610ba0565b80544264010000000090910463ffffffff1611156120f35760405162461bcd60e51b815260206004820152600b60248201527f4e6f7420737461727465640000000000000000000000000000000000000000006044820152606401610ba0565b8054426801000000000000000090910463ffffffff1610156121575760405162461bcd60e51b815260206004820152600560248201527f456e6465640000000000000000000000000000000000000000000000000000006044820152606401610ba0565b805461ffff808816620100009092041610156121b55760405162461bcd60e51b815260206004820152601260248201527f457863656564206d6178207065722074786e00000000000000000000000000006044820152606401610ba0565b6001600160a01b03821660009081526002820160205260409020546121df90879061ffff16614bca565b61ffff168561ffff1610156122365760405162461bcd60e51b815260206004820152601560248201527f457863656564206d6178207065722077616c6c657400000000000000000000006044820152606401610ba0565b8054349061226b9061ffff8916906c0100000000000000000000000090046fffffffffffffffffffffffffffffffff16614bec565b6fffffffffffffffffffffffffffffffff16146122ca5760405162461bcd60e51b815260206004820152600d60248201527f496e76616c6964207072696365000000000000000000000000000000000000006044820152606401610ba0565b6122d787838787876132dd565b858160010160028282829054906101000a900461ffff166122f89190614bca565b82546101009290920a61ffff8181021990931691831602179091556001600160a01b0384166000908152600284016020526040812080548a9450909261234091859116614bca565b92506101000a81548161ffff021916908361ffff1602179055506123648287612e5e565b50505050505050565b606060028054610bca9061491c565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152600f54600090819084106123fd5760405162461bcd60e51b815260206004820152601060248201527f496e76616c6964207068617365206964000000000000000000000000000000006044820152606401610ba0565b6000600f858154811061241257612412614a94565b60009182526020918290206003919091020160018101546040805160a081018252925461ffff808216855262010000808304821696860196909652640100000000820463ffffffff9081169386019390935268010000000000000000820490921660608501526c0100000000000000000000000090046fffffffffffffffffffffffffffffffff1660808401529198828216985092900416945092505050565b816daaeb6d7670e522a718067333cd4e3b1561259e576040517fc61711340000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03821660248201526daaeb6d7670e522a718067333cd4e9063c617113490604401602060405180830381865afa158015612539573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061255d9190614a77565b61259e576040517fede71dcc0000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610ba0565b610bb68383613439565b3360009081526010602052604090205460ff16806125d057506000546001600160a01b031633145b61261c5760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f776564206f70657261746f720000000000000000000000006044820152606401610ba0565b611eae6000600755565b836daaeb6d7670e522a718067333cd4e3b1561272157336001600160a01b0382160361265d5761265885858585613444565b610f61565b6040517fc61711340000000000000000000000000000000000000000000000000000000081523060048201523360248201526daaeb6d7670e522a718067333cd4e9063c617113490604401602060405180830381865afa1580156126c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e99190614a77565b612721576040517fede71dcc000000000000000000000000000000000000000000000000000000008152336004820152602401610ba0565b610f6185858585613444565b612735612e04565b60098054911515610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909216919091179055565b6000818152600360205260409020546060906001600160a01b03166127d35760405162461bcd60e51b815260206004820152600f60248201527f4e6f6e20657869737420746f6b656e00000000000000000000000000000000006044820152606401610ba0565b60095460ff1661286f57600a80546127ea9061491c565b80601f01602080910402602001604051908101604052809291908181526020018280546128169061491c565b80156128635780601f1061283857610100808354040283529160200191612863565b820191906000526020600020905b81548152906001019060200180831161284657829003601f168201915b50505050509050919050565b6000828152600e6020526040812080546128889061491c565b905011801561289e5750600954610100900460ff165b156128bc576000828152600e6020526040902080546127ea9061491c565b60095462010000900460ff16156128ff57600c6128d8836134cc565b6040516020016128e9929190614e5c565b6040516020818303038152906040529050919050565b6009546301000000900460ff161561291c57600d6128d8836134cc565b600b6128d8836134cc565b600d8054611d819061491c565b600a8054611d819061491c565b612949612e04565b60005b8251811015610bb657816010600085848151811061296c5761296c614a94565b6020908102919091018101516001600160a01b0316825281019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055806129c681614f01565b91505061294c565b6129d6612e04565b6001600160a01b038116612a525760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610ba0565b61192381613275565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f2a55205a000000000000000000000000000000000000000000000000000000001480610b2a5750610b2a8261356c565b6000818152600360205260409020546001600160a01b03166119235760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610ba0565b6000612b2082611bf0565b9050806001600160a01b0316836001600160a01b031603612ba95760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610ba0565b336001600160a01b0382161480612bc55750612bc58133610ab1565b612c375760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610ba0565b610bb6838361364f565b612c4b33826136d5565b612cbd5760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610ba0565b610bb6838383613754565b6127106bffffffffffffffffffffffff82161115612d4e5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c2065786365656460448201527f2073616c655072696365000000000000000000000000000000000000000000006064820152608401610ba0565b6001600160a01b038216612da45760405162461bcd60e51b815260206004820152601b60248201527f455243323938313a20496e76616c696420706172616d657465727300000000006044820152606401610ba0565b6040805180820182526001600160a01b0393841681526bffffffffffffffffffffffff9283166020808301918252600096875260089052919094209351905190911674010000000000000000000000000000000000000000029116179055565b6000546001600160a01b03163314611eae5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610ba0565b60095461ffff7a0100000000000000000000000000000000000000000000000000008204811691600191612eb1918591780100000000000000000000000000000000000000000000000090910416614bca565b612ebb9190614f1b565b61ffff161115612f0d5760405162461bcd60e51b815260206004820152601160248201527f457863656564206d617820737570706c790000000000000000000000000000006044820152606401610ba0565b600980547801000000000000000000000000000000000000000000000000900461ffff169082906018612f408385614bca565b92506101000a81548161ffff021916908361ffff16021790555060005b8261ffff1681101561106d57612f7c84612f778385614f36565b613995565b80612f8681614f01565b915050612f5d565b610bb683838360405180602001604052806000815250612626565b6127106bffffffffffffffffffffffff8216111561302f5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c2065786365656460448201527f2073616c655072696365000000000000000000000000000000000000000000006064820152608401610ba0565b6001600160a01b0382166130855760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c6964207265636569766572000000000000006044820152606401610ba0565b604080518082019091526001600160a01b039092168083526bffffffffffffffffffffffff90911660209092018290527401000000000000000000000000000000000000000090910217600755565b60006130e360208301836145ff565b61ffff16116131345760405162461bcd60e51b815260206004820152601060248201527f496e76616c6964207175616e74697479000000000000000000000000000000006044820152606401610ba0565b600061314660408301602084016145ff565b61ffff16116131975760405162461bcd60e51b815260206004820152601360248201527f496e76616c6964206d6178207065722074786e000000000000000000000000006044820152606401610ba0565b60006131a96060830160408401614f49565b63ffffffff16116131fc5760405162461bcd60e51b815260206004820152601260248201527f496e76616c69642073746172742074696d6500000000000000000000000000006044820152606401610ba0565b61320c6060820160408301614f49565b63ffffffff166132226080830160608401614f49565b63ffffffff16116119235760405162461bcd60e51b815260206004820152601060248201527f496e76616c696420656e642074696d65000000000000000000000000000000006044820152606401610ba0565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60004686600f88815481106132f4576132f4614a94565b60009182526020918290206003919091020160010154604080519283019390935261ffff908116928201929092526001600160a01b0388166060820152908616608082015260a0016040516020818303038152906040528051906020012060405160200161336c929190918252602082015260400190565b60405160208183030381529060405280519060200120905060006133d184848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506133cb9250869150613b389050565b90613b8b565b6009549091506001600160a01b0380831664010000000090920416146123645760405162461bcd60e51b815260206004820152600d60248201527f496e76616c69642070726f6f66000000000000000000000000000000000000006044820152606401610ba0565b611409338383613baf565b61344e33836136d5565b6134c05760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610ba0565b61106d84848484613c9b565b606060006134d983613d24565b600101905060008167ffffffffffffffff8111156134f9576134f9614713565b6040519080825280601f01601f191660200182016040528015613523576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461352d57509392505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd0000000000000000000000000000000000000000000000000000000014806135ff57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b80610b2a57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610b2a565b600081815260056020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038416908117909155819061369c82611bf0565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806136e183611bf0565b9050806001600160a01b0316846001600160a01b0316148061372857506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b8061374c5750836001600160a01b031661374184610c4d565b6001600160a01b0316145b949350505050565b826001600160a01b031661376782611bf0565b6001600160a01b0316146137e35760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610ba0565b6001600160a01b03821661385e5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610ba0565b826001600160a01b031661387182611bf0565b6001600160a01b0316146138ed5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610ba0565b600081815260056020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556001600160a01b0387811680865260048552838620805460001901905590871680865283862080546001019055868652600390945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6001600160a01b0382166139eb5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610ba0565b6000818152600360205260409020546001600160a01b031615613a505760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610ba0565b6000818152600360205260409020546001600160a01b031615613ab55760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610ba0565b6001600160a01b038216600081815260046020908152604080832080546001019055848352600390915280822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b6000806000613b9a8585613e06565b91509150613ba781613e48565b509392505050565b816001600160a01b0316836001600160a01b031603613c105760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610ba0565b6001600160a01b0383811660008181526006602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b613ca6848484613754565b613cb284848484613fad565b61106d5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610ba0565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310613d6d577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310613d99576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310613db757662386f26fc10000830492506010015b6305f5e1008310613dcf576305f5e100830492506008015b6127108310613de357612710830492506004015b60648310613df5576064830492506002015b600a8310610b2a5760010192915050565b6000808251604103613e3c5760208301516040840151606085015160001a613e308782858561414e565b9450945050505061114b565b5060009050600261114b565b6000816004811115613e5c57613e5c614f66565b03613e645750565b6001816004811115613e7857613e78614f66565b03613ec55760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610ba0565b6002816004811115613ed957613ed9614f66565b03613f265760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610ba0565b6003816004811115613f3a57613f3a614f66565b036119235760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610ba0565b60006001600160a01b0384163b15614143576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a029061400a903390899088908890600401614f95565b6020604051808303816000875af1925050508015614045575060408051601f3d908101601f1916820190925261404291810190614fd1565b60015b6140f8573d808015614073576040519150601f19603f3d011682016040523d82523d6000602084013e614078565b606091505b5080516000036140f05760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610ba0565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a020000000000000000000000000000000000000000000000000000000014905061374c565b506001949350505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156141855750600090506003614209565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156141d9573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661420257600060019250925050614209565b9150600090505b94509492505050565b7fffffffff000000000000000000000000000000000000000000000000000000008116811461192357600080fd5b60006020828403121561425257600080fd5b813561425d81614212565b9392505050565b60008083601f84011261427657600080fd5b50813567ffffffffffffffff81111561428e57600080fd5b60208301915083602082850101111561114b57600080fd5b600080602083850312156142b957600080fd5b823567ffffffffffffffff8111156142d057600080fd5b6142dc85828601614264565b90969095509350505050565b60005b838110156143035781810151838201526020016142eb565b50506000910152565b600081518084526143248160208601602086016142e8565b601f01601f19169290920160200192915050565b60208152600061425d602083018461430c565b60006020828403121561435d57600080fd5b5035919050565b80356001600160a01b038116811461437b57600080fd5b919050565b6000806040838503121561439357600080fd5b61439c83614364565b946020939093013593505050565b600080604083850312156143bd57600080fd5b823591506143cd60208401614364565b90509250929050565b60008083601f8401126143e857600080fd5b50813567ffffffffffffffff81111561440057600080fd5b6020830191508360208260051b850101111561114b57600080fd5b6000806000806040858703121561443157600080fd5b843567ffffffffffffffff8082111561444957600080fd5b614455888389016143d6565b9096509450602087013591508082111561446e57600080fd5b5061447b878288016143d6565b95989497509550505050565b60008060006060848603121561449c57600080fd5b6144a584614364565b92506144b360208501614364565b9150604084013590509250925092565b600080604083850312156144d657600080fd5b50508035926020909101359150565b80356bffffffffffffffffffffffff8116811461437b57600080fd5b60008060006060848603121561451657600080fd5b8335925061452660208501614364565b9150614534604085016144e5565b90509250925092565b801515811461192357600080fd5b803561437b8161453d565b60006020828403121561456857600080fd5b813561425d8161453d565b61ffff8116811461192357600080fd5b6000806040838503121561459657600080fd5b61459f83614364565b915060208301356145af81614573565b809150509250929050565b600080604083850312156145cd57600080fd5b6145d683614364565b91506143cd602084016144e5565b6000602082840312156145f657600080fd5b61425d82614364565b60006020828403121561461157600080fd5b813561425d81614573565b600060a0828403121561462e57600080fd5b50919050565b60008060c0838503121561464757600080fd5b823591506143cd846020850161461c565b600060a0828403121561466a57600080fd5b61425d838361461c565b60008060008060006080868803121561468c57600080fd5b85359450602086013561469e81614573565b935060408601356146ae81614573565b9250606086013567ffffffffffffffff8111156146ca57600080fd5b6146d688828901614264565b969995985093965092949392505050565b600080604083850312156146fa57600080fd5b61470383614364565b915060208301356145af8161453d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561476b5761476b614713565b604052919050565b6000806000806080858703121561478957600080fd5b61479285614364565b935060206147a1818701614364565b935060408601359250606086013567ffffffffffffffff808211156147c557600080fd5b818801915088601f8301126147d957600080fd5b8135818111156147eb576147eb614713565b6147fd84601f19601f84011601614742565b9150808252898482850101111561481357600080fd5b808484018584013760008482840101525080935050505092959194509250565b6000806040838503121561484657600080fd5b61484f83614364565b91506143cd60208401614364565b6000806040838503121561487057600080fd5b823567ffffffffffffffff8082111561488857600080fd5b818501915085601f83011261489c57600080fd5b81356020828211156148b0576148b0614713565b8160051b92506148c1818401614742565b82815292840181019281810190898511156148db57600080fd5b948201945b84861015614900576148f186614364565b825294820194908201906148e0565b965061490f905087820161454b565b9450505050509250929050565b600181811c9082168061493057607f821691505b60208210810361462e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b601f821115610bb657600081815260208120601f850160051c810160208610156149905750805b601f850160051c820191505b818110156149af5782815560010161499c565b505050505050565b67ffffffffffffffff8311156149cf576149cf614713565b6149e3836149dd835461491c565b83614969565b6000601f841160018114614a1757600085156149ff5750838201355b600019600387901b1c1916600186901b178355610f61565b600083815260209020601f19861690835b82811015614a485786850135825560209485019460019092019101614a28565b5086821015614a655760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b600060208284031215614a8957600080fd5b815161425d8161453d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112614af857600080fd5b83018035915067ffffffffffffffff821115614b1357600080fd5b60200191503681900382131561114b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061ffff808316818103614b6e57614b6e614b28565b6001019392505050565b8082028115828204841417610b2a57610b2a614b28565b600082614bc5577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b61ffff818116838216019080821115614be557614be5614b28565b5092915050565b6fffffffffffffffffffffffffffffffff818116838216028082169190828114614c1857614c18614b28565b505092915050565b63ffffffff8116811461192357600080fd5b6fffffffffffffffffffffffffffffffff8116811461192357600080fd5b60008135610b2a81614c32565b8135614c6881614573565b61ffff811690508154817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000082161783556020840135614ca681614573565b63ffff00008160101b16905080837fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000008416171784556040850135614ce981614c20565b67ffffffff000000008160201b169050837fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000084161793508084831717855560608601359250614d3783614c20565b6bffffffff00000000000000008360401b167fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff85168317821717855550505050611409614d8660808401614c50565b82547fffffffff00000000000000000000000000000000ffffffffffffffffffffffff1660609190911b7bffffffffffffffffffffffffffffffff00000000000000000000000016178255565b60a081018235614de281614573565b61ffff9081168352602084013590614df982614573565b1660208301526040830135614e0d81614c20565b63ffffffff9081166040840152606084013590614e2982614c20565b1660608301526080830135614e3d81614c32565b6fffffffffffffffffffffffffffffffff811660808401525092915050565b6000808454614e6a8161491c565b60018281168015614e825760018114614eb557614ee4565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0084168752821515830287019450614ee4565b8860005260208060002060005b85811015614edb5781548a820152908401908201614ec2565b50505082870194505b505050508351614ef88183602088016142e8565b01949350505050565b60006000198203614f1457614f14614b28565b5060010190565b61ffff828116828216039080821115614be557614be5614b28565b80820180821115610b2a57610b2a614b28565b600060208284031215614f5b57600080fd5b813561425d81614c20565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60006001600160a01b03808716835280861660208401525083604083015260806060830152614fc7608083018461430c565b9695505050505050565b600060208284031215614fe357600080fd5b815161425d8161421256fea26469706673582212208ea98070cb68adbaa8cdcb7591fc1b25bfca21bba26c5845aa1caeb970c3f8a264736f6c63430008130033
Verified Source Code Full Match
Compiler: v0.8.19+commit.7dd6d404
EVM: paris
Optimization: Yes (9999 runs)
Genesis.sol 317 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
// Openzepplin ERC2981
import "@openzeppelin/contracts/token/common/ERC2981.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "./royalty/DefaultOperatorFilterer.sol";
// :::: :::: ::::::::::: ::::::::::: ::::::::::: ::: ::::::::: ::::::::::: :::
// +:+:+: :+:+:+ :+: :+: :+: :+: :+: :+: :+: :+: :+: :+:
// +:+ +:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+
// +#+ +:+ +#+ +#+ +#+ +#+ +#++:++#++: +#++:++#: +#+ +#++:++#++:
// +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+
// #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+#
// ### ### ########### ### ### ### ### ### ### ########### ### ###
// ADVENTURE, EXPLORE & DISCOVER
// Mittaria & Pellar 2023
contract MittariaGenesis is
Ownable,
ERC721,
ERC2981,
DefaultOperatorFilterer
{
using ECDSA for bytes32;
// struct
struct Configs {
uint16 quantity;
uint16 maxPerTxn;
uint32 startTime;
uint32 endTime;
uint128 price;
}
struct Phase {
Configs configs;
uint16 version;
uint16 totalMinted;
mapping(address => uint16) minted;
}
// vars
bool public revealed;
bool public enableTokenURI;
bool public enableBackupURI;
bool public enableHtmlURI;
address public verifier = 0x9f6B54d48AD2175e56a1BA9bFc74cd077213B68D;
uint16 public currentIdx = 1;
uint16 public maxSupply = 5555;
string public preRevealedURI;
string public baseURI;
string public backupURI;
string public htmlURI;
mapping(uint256 => string) public token2URI;
Phase[] public phases;
mapping(address => bool) public executors;
event PhaseModified(uint256 indexed phaseId, Configs configs);
constructor() ERC721("Mittaria Genesis", "MTG") {
// 7.5%
setPrimaryRoyalty(0x90252481a9D8e3E85dFA9cE1e402c3Ffe22803e5, 750);
// init public phase
phases.push();
preRevealedURI = "ipfs://QmWGFEEYcYQ5HkV5SrYB1PMVbFbzsdMPrUTEz7bStuJvXf";
}
modifier onlyAllowedExecutor() {
require(executors[_msgSender()] || owner() == _msgSender(), "Not allowed operator");
_;
}
/* View */
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
require(_exists(_tokenId), "Non exist token");
if (!revealed) {
return preRevealedURI;
}
if (bytes(token2URI[_tokenId]).length > 0 && enableTokenURI) {
return token2URI[_tokenId];
}
if (enableBackupURI) {
return string(abi.encodePacked(backupURI, Strings.toString(_tokenId)));
}
if (enableHtmlURI) {
return string(abi.encodePacked(htmlURI, Strings.toString(_tokenId)));
}
return string(abi.encodePacked(baseURI, Strings.toString(_tokenId)));
}
// verifed
function getPhaseInfo(uint256 _phaseId) external view returns (Configs memory configs, uint16 version, uint16 totalMinted) {
require(_phaseId < phases.length, "Invalid phase id");
Phase storage phase = phases[_phaseId];
return (phase.configs, phase.version, phase.totalMinted);
}
// verifed
function getTokenMintedByAccount(uint256 _phaseId, address _account) external view returns (uint16) {
require(_phaseId < phases.length, "Invalid phase id");
return phases[_phaseId].minted[_account];
}
/* User */
// verifed
function mint(uint256 _phaseId, uint16 _amount, uint16 _maxAmount, bytes calldata _signature) external payable {
address account = msg.sender;
require(tx.origin == account, "Not allowed");
Phase storage phase = phases[_phaseId];
require(_amount > 0, "Invalid amount");
require(phase.configs.quantity >= phase.totalMinted + _amount, "Exceed quantity");
require(phase.configs.startTime <= block.timestamp, "Not started");
require(phase.configs.endTime >= block.timestamp, "Ended");
require(phase.configs.maxPerTxn >= _amount, "Exceed max per txn");
require(_maxAmount >= phase.minted[account] + _amount, "Exceed max per wallet");
require(phase.configs.price * _amount == msg.value, "Invalid price");
_verifySignature(_phaseId, account, _maxAmount, _signature);
phase.totalMinted += _amount;
phase.minted[account] += _amount;
_mintToken(account, _amount);
}
function mintTo(address _to, uint16 _amount) external payable {
Phase storage phase = phases[0];
require(_amount > 0, "Invalid amount");
require(phase.configs.quantity >= phase.totalMinted + _amount, "Exceed quantity");
require(phase.configs.startTime <= block.timestamp, "Not started");
require(phase.configs.endTime >= block.timestamp, "Ended");
require(phase.configs.maxPerTxn >= _amount, "Exceed max per txn");
require(phase.configs.price * _amount == msg.value, "Invalid price");
phase.totalMinted += _amount;
phase.minted[_to] += _amount;
_mintToken(_to, _amount);
}
// verifed
function _mintToken(address _account, uint16 _amount) internal {
require(currentIdx + _amount - 1 <= maxSupply, "Exceed max supply");
uint256 _currentIdx = currentIdx;
currentIdx += _amount;
for (uint256 i = 0; i < _amount; i++) {
_mint(_account, _currentIdx + i);
}
}
// verifed
function _verifySignature(uint256 _phaseId, address _account, uint16 _maxAmount, bytes calldata _signature) internal view {
bytes32 messageHash = keccak256(abi.encodePacked(block.chainid, keccak256(abi.encode(_phaseId, phases[_phaseId].version, _account, _maxAmount))));
address signer = messageHash.toEthSignedMessageHash().recover(_signature);
require(verifier == signer, "Invalid proof");
}
/* Admin */
function setTotalSupply(uint16 _maxSupply) external onlyOwner {
require(_maxSupply <= 5555, "Invalid max supply");
maxSupply = _maxSupply;
}
// verifed
function _validateMintingPhase(Configs calldata _configs) internal pure {
require(_configs.quantity > 0, "Invalid quantity");
require(_configs.maxPerTxn > 0, "Invalid max per txn");
require(_configs.startTime > 0, "Invalid start time");
require(_configs.endTime > _configs.startTime, "Invalid end time");
}
// verifed
function createMintingPhase(Configs calldata _configs) external onlyOwner {
_validateMintingPhase(_configs);
uint256 phaseId = phases.length;
phases.push();
phases[phaseId].configs = _configs;
emit PhaseModified(phaseId, _configs);
}
// verifed
function updateMintingPhase(uint256 _phaseId, Configs calldata _configs) external onlyOwner {
require(_phaseId < phases.length, "Invalid phase id");
_validateMintingPhase(_configs);
phases[_phaseId].configs = _configs;
phases[_phaseId].version++;
emit PhaseModified(_phaseId, _configs);
}
// verifed
function setExecutor(address[] memory _executors, bool _status) external onlyOwner {
for (uint256 i = 0; i < _executors.length; i++) {
executors[_executors[i]] = _status;
}
}
// verifed
function setVerifier(address _verifier) external onlyOwner {
require(_verifier != address(0), "Invalid verifier");
verifier = _verifier;
}
// verified
function toggleTokenURI(bool _status) external onlyOwner {
enableTokenURI = _status;
}
// verified
function toggleBackupURI(bool _status) external onlyOwner {
enableBackupURI = _status;
}
// verified
function toggleHtmlURI(bool _status) external onlyOwner {
enableHtmlURI = _status;
}
// verified
function toggleReveal(bool _status) external onlyOwner {
revealed = _status;
}
// verified
function setPreRevealedURI(string calldata _uri) external onlyAllowedExecutor {
preRevealedURI = _uri;
}
// verified
function setBaseURI(string calldata _uri) external onlyAllowedExecutor {
baseURI = _uri;
}
// verified
function setBackupURI(string calldata _uri) external onlyAllowedExecutor {
backupURI = _uri;
}
// verified
function setHtmlURI(string calldata _uri) external onlyAllowedExecutor {
htmlURI = _uri;
}
// verifed
function setTokensURI(uint16[] calldata _tokenIds, string[] calldata _uris) external onlyAllowedExecutor {
require(_tokenIds.length == _uris.length, "Input mismatch");
for (uint16 i = 0; i < _tokenIds.length; i++) {
token2URI[_tokenIds[i]] = _uris[i];
}
}
// verifed
function adminMintTo(address _to, uint256 _amount) external onlyOwner {
require(_amount > 0, "Invalid amount");
_mintToken(_to, uint16(_amount));
}
function withdraw() public onlyOwner {
uint256 balance = address(this).balance;
payable(0x961E3f37Ce55799E27C1E8CeE24305fccFE7591C).transfer(balance);
}
/* Royalty */
function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {
super.setApprovalForAll(operator, approved);
}
function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {
super.approve(operator, tokenId);
}
function transferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
super.transferFrom(from, to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId, data);
}
function setPrimaryRoyalty(address _receiver, uint96 _feeNumerator) public onlyAllowedExecutor {
_setDefaultRoyalty(_receiver, _feeNumerator);
}
// verified
function deleteDefaultRoyalty() public onlyAllowedExecutor {
_deleteDefaultRoyalty();
}
// verified
function setRoyaltyInfoForToken(uint256 _tokenId, address _receiver, uint96 _feeNumerator) public onlyAllowedExecutor {
_setTokenRoyalty(_tokenId, _receiver, _feeNumerator);
}
// verified
function resetRoyaltyInforToken(uint256 _tokenId) public onlyAllowedExecutor {
_resetTokenRoyalty(_tokenId);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC2981, ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
}
OperatorFilterer.sol 59 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { IOperatorFilterRegistry } from "./IOperatorFilterRegistry.sol";
/**
* @title OperatorFilterer
* @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another
* registrant's entries in the OperatorFilterRegistry.
*/
abstract contract OperatorFilterer {
error OperatorNotAllowed(address operator);
IOperatorFilterRegistry constant OPERATOR_FILTER_REGISTRY = IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);
constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {
// If an inheriting token contract is deployed to a network without the registry deployed, the modifier
// will not revert, but the contract will need to be registered with the registry once it is deployed in
// order for the modifier to filter addresses.
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
if (subscribe) {
OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);
} else {
if (subscriptionOrRegistrantToCopy != address(0)) {
OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);
} else {
OPERATOR_FILTER_REGISTRY.register(address(this));
}
}
}
}
modifier onlyAllowedOperator(address from) virtual {
// Check registry code length to facilitate testing in environments without a deployed registry.
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
// Allow spending tokens from addresses with balance
// Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred
// from an EOA.
if (from == msg.sender) {
_;
return;
}
if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), msg.sender)) {
revert OperatorNotAllowed(msg.sender);
}
}
_;
}
modifier onlyAllowedOperatorApproval(address operator) virtual {
// Check registry code length to facilitate testing in environments without a deployed registry.
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {
revert OperatorNotAllowed(operator);
}
}
_;
}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or 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 {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 70 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _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) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Math.sol 345 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}
DefaultOperatorFilterer.sol 14 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { OperatorFilterer } from "./OperatorFilterer.sol";
/**
* @title DefaultOperatorFilterer
* @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.
*/
abstract contract DefaultOperatorFilterer is OperatorFilterer {
address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);
constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}
}
IOperatorFilterRegistry.sol 68 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
interface IOperatorFilterRegistry {
function isOperatorAllowed(address registrant, address operator) external view returns (bool);
function register(address registrant) external;
function registerAndSubscribe(address registrant, address subscription) external;
function registerAndCopyEntries(address registrant, address registrantToCopy) external;
function unregister(address addr) external;
function updateOperator(
address registrant,
address operator,
bool filtered
) external;
function updateOperators(
address registrant,
address[] calldata operators,
bool filtered
) external;
function updateCodeHash(
address registrant,
bytes32 codehash,
bool filtered
) external;
function updateCodeHashes(
address registrant,
bytes32[] calldata codeHashes,
bool filtered
) external;
function subscribe(address registrant, address registrantToSubscribe) external;
function unsubscribe(address registrant, bool copyExistingEntries) external;
function subscriptionOf(address addr) external returns (address registrant);
function subscribers(address registrant) external returns (address[] memory);
function subscriberAt(address registrant, uint256 index) external returns (address);
function copyEntriesOf(address registrant, address registrantToCopy) external;
function isOperatorFiltered(address registrant, address operator) external returns (bool);
function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);
function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);
function filteredOperators(address addr) external returns (address[] memory);
function filteredCodeHashes(address addr) external returns (bytes32[] memory);
function filteredOperatorAt(address registrant, uint256 index) external returns (address);
function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);
function isRegistered(address addr) external returns (bool);
function codeHashOf(address addr) external returns (bytes32);
}
IERC2981.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
ERC721.sol 506 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.2) (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 = _ownerOf(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 or 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 or 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 or 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 the owner of the `tokenId`. Does NOT revert if token doesn't exist
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
/**
* @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 _ownerOf(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, 1);
// Check that tokenId was not minted by `_beforeTokenTransfer` hook
require(!_exists(tokenId), "ERC721: token already minted");
unchecked {
// Will not overflow unless all 2**256 token ids are minted to the same owner.
// Given that tokens are minted one by one, it is impossible in practice that
// this ever happens. Might change if we allow batch minting.
// The ERC fails to describe this case.
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId, 1);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId, 1);
// Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
owner = ERC721.ownerOf(tokenId);
// Clear approvals
delete _tokenApprovals[tokenId];
unchecked {
// Cannot overflow, as that would require more tokens to be burned/transferred
// out than the owner initially received through minting and transferring in.
_balances[owner] -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId, 1);
}
/**
* @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, 1);
// Check that tokenId was not transferred by `_beforeTokenTransfer` hook
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
// Clear approvals from the previous owner
delete _tokenApprovals[tokenId];
unchecked {
// `_balances[from]` cannot overflow for the same reason as described in `_burn`:
// `from`'s balance is the number of token held, which is at least one before the current
// transfer.
// `_balances[to]` could overflow in the conditions described in `_mint`. That would require
// all 2**256 token ids to be minted, which in practice is impossible.
_balances[from] -= 1;
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId, 1);
}
/**
* @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. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
* - When `from` is zero, the tokens will be minted for `to`.
* - When `to` is zero, ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
* - When `from` is zero, the tokens were minted for `to`.
* - When `to` is zero, ``from``'s tokens were burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual {}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
* being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
* that `ownerOf(tokenId)` is `a`.
*/
// solhint-disable-next-line func-name-mixedcase
function __unsafe_increaseBalance(address account, uint256 amount) internal {
_balances[account] += amount;
}
}
IERC721.sol 145 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* 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);
}
ERC2981.sol 111 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)
pragma solidity ^0.8.0;
import "../../interfaces/IERC2981.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
* fee is specified in basis points by default.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*
* _Available since v4.5._
*/
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @inheritdoc IERC2981
*/
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) {
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];
if (royalty.receiver == address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();
return (royalty.receiver, royaltyAmount);
}
/**
* @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
* fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
* override.
*/
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
/**
* @dev Sets the royalty information that all ids in this contract will default to.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: invalid receiver");
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Removes default royalty information.
*/
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setTokenRoyalty(
uint256 tokenId,
address receiver,
uint96 feeNumerator
) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: Invalid parameters");
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Resets royalty information for the token id back to the global default.
*/
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
delete _tokenRoyaltyInfo[tokenId];
}
}
ECDSA.sol 213 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
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;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
Read Contract
backupURI 0x82f69105 → string
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
currentIdx 0x5bfac41f → uint16
enableBackupURI 0x544267bd → bool
enableHtmlURI 0xa32dced4 → bool
enableTokenURI 0x645bef2d → bool
executors 0x9ac2a011 → bool
getApproved 0x081812fc → address
getPhaseInfo 0x98c2fa07 → tuple, uint16, uint16
getTokenMintedByAccount 0x0c394aac → uint16
htmlURI 0xd207a9db → string
isApprovedForAll 0xe985e9c5 → bool
maxSupply 0xd5abeb01 → uint16
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
phases 0x2e37eef6 → tuple, uint16, uint16
preRevealedURI 0xde210ab3 → string
revealed 0x51830227 → bool
royaltyInfo 0x2a55205a → address, uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
token2URI 0x751c3f51 → string
tokenURI 0xc87b56dd → string
verifier 0x2b7ac3f3 → address
Write Contract 29 functions
These functions modify contract state and require a wallet transaction to execute.
adminMintTo 0x3d6a5745
address _to
uint256 _amount
approve 0x095ea7b3
address operator
uint256 tokenId
createMintingPhase 0x8411824b
tuple _configs
deleteDefaultRoyalty 0xaa1b103f
No parameters
mint 0x8c33d544
uint256 _phaseId
uint16 _amount
uint16 _maxAmount
bytes _signature
mintTo 0x3f84ac0e
address _to
uint16 _amount
renounceOwnership 0x715018a6
No parameters
resetRoyaltyInforToken 0x48ed94b6
uint256 _tokenId
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBackupURI 0x2af80c51
string _uri
setBaseURI 0x55f804b3
string _uri
setExecutor 0xe9bd993a
address[] _executors
bool _status
setHtmlURI 0x030420d5
string _uri
setPreRevealedURI 0x2ca4b209
string _uri
setPrimaryRoyalty 0x4e49e193
address _receiver
uint96 _feeNumerator
setRoyaltyInfoForToken 0x2cf9c186
uint256 _tokenId
address _receiver
uint96 _feeNumerator
setTokensURI 0x1080a0b2
uint16[] _tokenIds
string[] _uris
setTotalSupply 0x562e438b
uint16 _maxSupply
setVerifier 0x5437988d
address _verifier
toggleBackupURI 0x30301b31
bool _status
toggleHtmlURI 0x58834f01
bool _status
toggleReveal 0x4c100321
bool _status
toggleTokenURI 0xc1230ecf
bool _status
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
updateMintingPhase 0x77b37729
uint256 _phaseId
tuple _configs
withdraw 0x3ccfd60b
No parameters
Top Interactions
| Address | Txns | Sent | Received |
|---|---|---|---|
| 0x27AB2E46...cc8e | 1 | 1 | |
| 0x27fD180D...3F19 | 1 | 1 |
Recent Transactions
|
| Hash | Block | Age | From/To | Value | |
|---|---|---|---|---|---|
| 0xa5dee789...22bb29 | 24,314,753 | IN | 0x27fD180D...3F19 | 0 ETH | |
| 0x484012a5...673c2f | 24,314,580 | IN | 0x27AB2E46...cc8e | 0 ETH |