Address Contract Verified
Address
0xd16809C0a7d82C9E7552a01Fd608fFF90EFb564f
Balance
0 ETH
Nonce
1
Code Size
22251 bytes
Creator
0x0F9acF89...0412 at tx 0x7c8aee2e...25642d
Indexed Transactions
0
Contract Bytecode
22251 bytes
0x608060405234801561001057600080fd5b506004361061025e5760003560e01c806370a0823111610146578063b77a147b116100c3578063cfa84dfe11610087578063cfa84dfe1461075b578063d12a4c9814610779578063d547741f146107a9578063e985e9c5146107c5578063f414a308146107f5578063f8ea173e146108115761025e565b8063b77a147b1461067f578063b88d4fde146106af578063be010c40146106cb578063c76ab940146106fb578063c87b56dd1461072b5761025e565b806395d89b411161010a57806395d89b41146105ef578063a217fddf1461060d578063a22cb4651461062b578063a44b6b7414610647578063a7016023146106635761025e565b806370a08231146105255780637ca4e3d6146105555780637cb64759146105855780638da5cb5b146105a157806391d14854146105bf5761025e565b8063248a9ca3116101df57806335b2802e116101a357806335b2802e1461046557806336568abe1461048357806342842e0e1461049f578063524ce085146104bb5780635de6dc55146104c55780636352211e146104f55761025e565b8063248a9ca3146103bf578063287726c1146103ef5780632eb4a7ab1461040d5780632f2ff15d1461042b57806332cb6b0c146104475761025e565b8063095ea7b311610226578063095ea7b31461031b57806316d3bfbb1461033757806318160ddd146103555780631e7269c51461037357806323b872dd146103a35761025e565b806301ffc9a71461026357806303e399c01461029357806306fdde03146102b1578063081812fc146102cf5780630890d80c146102ff575b600080fd5b61027d600480360381019061027891906139d1565b610841565b60405161028a919061451c565b60405180910390f35b61029b610853565b6040516102a89190614552565b60405180910390f35b6102b96108e1565b6040516102c69190614552565b60405180910390f35b6102e960048036038101906102e49190613aba565b610973565b6040516102f69190614493565b60405180910390f35b61031960048036038101906103149190613a23565b6109f8565b005b610335600480360381019061033091906138eb565b610a58565b005b61033f610b70565b60405161034c9190614794565b60405180910390f35b61035d610b78565b60405161036a9190614794565b60405180910390f35b61038d60048036038101906103889190613780565b610b7e565b60405161039a919061451c565b60405180910390f35b6103bd60048036038101906103b891906137e5565b610b9e565b005b6103d960048036038101906103d4919061396c565b610bfe565b6040516103e69190614537565b60405180910390f35b6103f7610c1e565b604051610404919061451c565b60405180910390f35b610415610c31565b6040516104229190614537565b60405180910390f35b61044560048036038101906104409190613995565b610c37565b005b61044f610c60565b60405161045c9190614794565b60405180910390f35b61046d610c66565b60405161047a9190614552565b60405180910390f35b61049d60048036038101906104989190613995565b610cf4565b005b6104b960048036038101906104b491906137e5565b610d77565b005b6104c3610d97565b005b6104df60048036038101906104da9190613780565b610dca565b6040516104ec91906144fa565b60405180910390f35b61050f600480360381019061050a9190613aba565b610f17565b60405161051c9190614493565b60405180910390f35b61053f600480360381019061053a9190613780565b610fc9565b60405161054c9190614794565b60405180910390f35b61056f600480360381019061056a9190613aba565b611081565b60405161057c919061451c565b60405180910390f35b61059f600480360381019061059a919061396c565b6110a0565b005b6105a96110c0565b6040516105b69190614493565b60405180910390f35b6105d960048036038101906105d49190613995565b6110ea565b6040516105e6919061451c565b60405180910390f35b6105f7611155565b6040516106049190614552565b60405180910390f35b6106156111e7565b6040516106229190614537565b60405180910390f35b610645600480360381019061064091906138af565b6111ee565b005b610661600480360381019061065c9190613ae3565b611204565b005b61067d60048036038101906106789190613780565b611246565b005b61069960048036038101906106949190613927565b611268565b6040516106a69190614794565b60405180910390f35b6106c960048036038101906106c49190613834565b611512565b005b6106e560048036038101906106e09190613aba565b611574565b6040516106f29190614794565b60405180910390f35b61071560048036038101906107109190613aba565b61158c565b6040516107229190614552565b60405180910390f35b61074560048036038101906107409190613aba565b61162c565b6040516107529190614552565b60405180910390f35b6107636116af565b6040516107709190614552565b60405180910390f35b610793600480360381019061078e9190613aba565b61173d565b6040516107a09190614552565b60405180910390f35b6107c360048036038101906107be9190613995565b61174f565b005b6107df60048036038101906107da91906137a9565b611778565b6040516107ec919061451c565b60405180910390f35b61080f600480360381019061080a9190613aba565b61180c565b005b61082b60048036038101906108269190613aba565b6118e9565b6040516108389190614794565b60405180910390f35b600061084c82611920565b9050919050565b6073805461086090614ac6565b80601f016020809104026020016040519081016040528092919081815260200182805461088c90614ac6565b80156108d95780601f106108ae576101008083540402835291602001916108d9565b820191906000526020600020905b8154815290600101906020018083116108bc57829003601f168201915b505050505081565b6060600080546108f090614ac6565b80601f016020809104026020016040519081016040528092919081815260200182805461091c90614ac6565b80156109695780601f1061093e57610100808354040283529160200191610969565b820191906000526020600020905b81548152906001019060200180831161094c57829003601f168201915b5050505050905090565b600061097e8261199a565b6109bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b4906146d4565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000801b610a0d81610a08611a06565b611a0e565b8360719080519060200190610a23929190613545565b508260729080519060200190610a3a929190613545565b508160739080519060200190610a51929190613545565b5050505050565b6000610a6382610f17565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ad4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610acb90614714565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610af3611a06565b73ffffffffffffffffffffffffffffffffffffffff161480610b225750610b2181610b1c611a06565b611778565b5b610b61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5890614654565b60405180910390fd5b610b6b8383611aab565b505050565b6301e1338081565b60745481565b606e6020528060005260406000206000915054906101000a900460ff1681565b610baf610ba9611a06565b82611b64565b610bee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610be590614734565b60405180910390fd5b610bf9838383611c42565b505050565b600060076000838152602001908152602001600020600101549050919050565b607560009054906101000a900460ff1681565b60765481565b610c4082610bfe565b610c5181610c4c611a06565b611a0e565b610c5b8383611e9e565b505050565b61040181565b60718054610c7390614ac6565b80601f0160208091040260200160405190810160405280929190818152602001828054610c9f90614ac6565b8015610cec5780601f10610cc157610100808354040283529160200191610cec565b820191906000526020600020905b815481529060010190602001808311610ccf57829003601f168201915b505050505081565b610cfc611a06565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610d69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6090614774565b60405180910390fd5b610d738282611f7f565b5050565b610d9283838360405180602001604052806000815250611512565b505050565b6000801b610dac81610da7611a06565b611a0e565b6001607560006101000a81548160ff02191690831515021790555050565b60606000610dd783610fc9565b905060008167ffffffffffffffff811115610e1b577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015610e495781602001602082028036833780820191505090505b5090506000805b607454811015610f0b578573ffffffffffffffffffffffffffffffffffffffff16610e7a82610f17565b73ffffffffffffffffffffffffffffffffffffffff161415610eeb5780838381518110610ed0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010181815250508180610ee790614b29565b9250505b83821415610ef857610f0b565b8080610f0390614b29565b915050610e50565b50819350505050919050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610fc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb790614694565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561103a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161103190614674565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600042606f600084815260200190815260200160002054119050919050565b6000801b6110b5816110b0611a06565b611a0e565b816076819055505050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006007600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60606001805461116490614ac6565b80601f016020809104026020016040519081016040528092919081815260200182805461119090614ac6565b80156111dd5780601f106111b2576101008083540402835291602001916111dd565b820191906000526020600020905b8154815290600101906020018083116111c057829003601f168201915b5050505050905090565b6000801b81565b6112006111f9611a06565b8383612061565b5050565b6000801b61121981611214611a06565b611a0e565b81607060008581526020019081526020016000209080519060200190611240929190613545565b50505050565b6000801b61125b81611256611a06565b611a0e565b611264826121ce565b5050565b6000600260065414156112b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a790614754565b60405180910390fd5b6002600681905550610401607454106112f5576040517fd05cb60900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611379576040517fddefae2800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113983373ffffffffffffffffffffffffffffffffffffffff1661190d565b156113cf576040517f2dd5679600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060745490506000336040516020016113e99190614257565b60405160208183030381529060405280519060200120905061144f858580806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505060765483612294565b611485576040517f0ed6f64500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6074600081548092919061149890614b29565b91905055506001606e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506114ff33836122ab565b8192505050600160068190555092915050565b61152361151d611a06565b83611b64565b611562576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155990614734565b60405180910390fd5b61156e848484846122c9565b50505050565b606f6020528060005260406000206000915090505481565b607060205280600052604060002060009150905080546115ab90614ac6565b80601f01602080910402602001604051908101604052809291908181526020018280546115d790614ac6565b80156116245780601f106115f957610100808354040283529160200191611624565b820191906000526020600020905b81548152906001019060200180831161160757829003601f168201915b505050505081565b60606000611685607161163e85612325565b607261165161164c886124d2565b6129cc565b607361165c89612325565b6040516020016116719695949392919061439d565b6040516020818303038152906040526129cc565b9050806040516020016116989190614437565b604051602081830303815290604052915050919050565b607280546116bc90614ac6565b80601f01602080910402602001604051908101604052809291908181526020018280546116e890614ac6565b80156117355780601f1061170a57610100808354040283529160200191611735565b820191906000526020600020905b81548152906001019060200180831161171857829003601f168201915b505050505081565b6060611748826124d2565b9050919050565b61175882610bfe565b61176981611764611a06565b611a0e565b6117738383611f7f565b505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b607560009054906101000a900460ff16611852576040517ffb7e4cbe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff1661187282610f17565b73ffffffffffffffffffffffffffffffffffffffff16146118bf576040517fdaedf54a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6301e13380426118cf91906148c7565b606f60008381526020019081526020016000208190555050565b606d81815481106118f957600080fd5b906000526020600020016000915090505481565b600080823b905060008111915050919050565b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611993575061199282612b8a565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b611a1882826110ea565b611aa757611a3d8173ffffffffffffffffffffffffffffffffffffffff166014612c6c565b611a4b8360001c6020612c6c565b604051602001611a5c929190614459565b6040516020818303038152906040526040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a9e9190614552565b60405180910390fd5b5050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611b1e83610f17565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611b6f8261199a565b611bae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ba590614634565b60405180910390fd5b6000611bb983610f17565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611c2857508373ffffffffffffffffffffffffffffffffffffffff16611c1084610973565b73ffffffffffffffffffffffffffffffffffffffff16145b80611c395750611c388185611778565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611c6282610f17565b73ffffffffffffffffffffffffffffffffffffffff1614611cb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611caf906146f4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d1f906145d4565b60405180910390fd5b611d33838383612f66565b611d3e600082611aab565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611d8e91906149a8565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611de591906148c7565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b611ea882826110ea565b611f7b5760016007600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611f20611a06565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b611f8982826110ea565b1561205d5760006007600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550612002611a06565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156120d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120c7906145f4565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516121c1919061451c565b60405180910390a3505050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167ff6a7092513e1f3f720c1d0ad65eb323494afe10d43e19dc4a40bac61ade7579160405160405180910390a35050565b6000826122a18584612f6b565b1490509392505050565b6122c5828260405180602001604052806000815250613044565b5050565b6122d4848484611c42565b6122e08484848461309f565b61231f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161231690614594565b60405180910390fd5b50505050565b6060600082141561236d576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506124cd565b600082905060005b6000821461239f57808061238890614b29565b915050600a82612398919061491d565b9150612375565b60008167ffffffffffffffff8111156123e1577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156124135781602001600182028036833780820191505090505b5090505b600085146124c65760018261242c91906149a8565b9150600a8561243b9190614ba0565b603061244791906148c7565b60f81b818381518110612483577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856124bf919061491d565b9450612417565b8093505050505b919050565b60606124dd8261199a565b612513576040517fb1d04f0800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000821461266b5761252482611081565b1561260e5760706000606d8481548110612567577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001548152602001908152602001600020805461258b90614ac6565b80601f01602080910402602001604051908101604052809291908181526020018280546125b790614ac6565b80156126045780601f106125d957610100808354040283529160200191612604565b820191906000526020600020905b8154815290600101906020018083116125e757829003601f168201915b5050505050612645565b6040518060400160405280600681526020017f66666666666600000000000000000000000000000000000000000000000000008152505b6040516020016126559190614370565b60405160208183030381529060405290506129c7565b600061267962010000613236565b90506126fe607060008081526020019081526020016000206070600060018152602001908152602001600020607060006002815260200190815260200160002060706000600381526020019081526020016000206040516020016126e094939291906142fb565b6040516020818303038152906040528261326090919063ffffffff16565b600060405180608001604052806040518060400160405280600181526020017f610000000000000000000000000000000000000000000000000000000000000081525081526020016040518060400160405280600181526020017f620000000000000000000000000000000000000000000000000000000000000081525081526020016040518060400160405280600181526020017f630000000000000000000000000000000000000000000000000000000000000081525081526020016040518060400160405280600181526020017f6400000000000000000000000000000000000000000000000000000000000000815250815250905060008060005b61040081101561297657602080826128159190614ba0565b61281f919061494e565b92506020808261282f919061491d565b612839919061494e565b915061296361284784612325565b61285084612325565b61286560018561286091906148c7565b611081565b6128a4576040518060400160405280600181526020017f7700000000000000000000000000000000000000000000000000000000000000815250612933565b86606d6001866128b491906148c7565b815481106128eb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001546004811061292d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200201515b6040516020016129459392919061429e565b6040516020818303038152906040528661326090919063ffffffff16565b808061296e90614b29565b9150506127fd565b506129bf6040518060400160405280600681526020017f3c2f7376673e00000000000000000000000000000000000000000000000000008152508561326090919063ffffffff16565b839450505050505b919050565b606060008251905060008114156129f55760405180602001604052806000815250915050612b85565b60006003600283612a0691906148c7565b612a10919061491d565b6004612a1c919061494e565b90506000602082612a2d91906148c7565b67ffffffffffffffff811115612a6c577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612a9e5781602001600182028036833780820191505090505b5090506000604051806060016040528060408152602001615676604091399050600181016020830160005b86811015612b425760038101905062ffffff818a015116603f8160121c168401518060081b905060ff603f83600c1c1686015116810190508060081b905060ff603f8360061c1686015116810190508060081b905060ff603f831686015116810190508060e01b90508084526004840193505050612ac9565b506003860660018114612b5c5760028114612b6c57612b77565b613d3d60f01b6002830352612b77565b603d60f81b60018303525b508484525050819450505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612c5557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80612c655750612c64826132d0565b5b9050919050565b606060006002836002612c7f919061494e565b612c8991906148c7565b67ffffffffffffffff811115612cc8577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612cfa5781602001600182028036833780820191505090505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612d58577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612de2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006001846002612e22919061494e565b612e2c91906148c7565b90505b6001811115612f18577f3031323334353637383961626364656600000000000000000000000000000000600f861660108110612e94577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b1a60f81b828281518110612ed1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c945080612f1190614a9c565b9050612e2f565b5060008414612f5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f5390614574565b60405180910390fd5b8091505092915050565b505050565b60008082905060005b8451811015613039576000858281518110612fb8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050808311612ff9578281604051602001612fdc929190614272565b604051602081830303815290604052805190602001209250613025565b808360405160200161300c929190614272565b6040516020818303038152906040528051906020012092505b50808061303190614b29565b915050612f74565b508091505092915050565b61304e838361333a565b61305b600084848461309f565b61309a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161309190614594565b60405180910390fd5b505050565b60006130c08473ffffffffffffffffffffffffffffffffffffffff1661190d565b15613229578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026130e9611a06565b8786866040518563ffffffff1660e01b815260040161310b94939291906144ae565b602060405180830381600087803b15801561312557600080fd5b505af192505050801561315657506040513d601f19601f8201168201806040525081019061315391906139fa565b60015b6131d9573d8060008114613186576040519150601f19603f3d011682016040523d82523d6000602084013e61318b565b606091505b506000815114156131d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016131c890614594565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061322e565b600190505b949350505050565b60606040516060830180820180604052505060408301808252506020810191506000825250919050565b60008060406020850351039150835190508183518261327f91906148c7565b11156132c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132b790614614565b60405180910390fd5b6132ca8484613508565b50505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156133aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133a1906146b4565b60405180910390fd5b6133b38161199a565b156133f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133ea906145b4565b60405180910390fd5b6133ff60008383612f66565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461344f91906148c7565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b8051602082019150808201602084510184015b81841015613538578351815260208401935060208101905061351b565b5050808351018352505050565b82805461355190614ac6565b90600052602060002090601f01602090048101928261357357600085556135ba565b82601f1061358c57805160ff19168380011785556135ba565b828001600101855582156135ba579182015b828111156135b957825182559160200191906001019061359e565b5b5090506135c791906135cb565b5090565b5b808211156135e45760008160009055506001016135cc565b5090565b60006135fb6135f6846147d4565b6147af565b90508281526020810184848401111561361357600080fd5b61361e848285614a5a565b509392505050565b600061363961363484614805565b6147af565b90508281526020810184848401111561365157600080fd5b61365c848285614a5a565b509392505050565b60008135905061367381615602565b92915050565b60008083601f84011261368b57600080fd5b8235905067ffffffffffffffff8111156136a457600080fd5b6020830191508360208202830111156136bc57600080fd5b9250929050565b6000813590506136d281615619565b92915050565b6000813590506136e781615630565b92915050565b6000813590506136fc81615647565b92915050565b60008151905061371181615647565b92915050565b600082601f83011261372857600080fd5b81356137388482602086016135e8565b91505092915050565b600082601f83011261375257600080fd5b8135613762848260208601613626565b91505092915050565b60008135905061377a8161565e565b92915050565b60006020828403121561379257600080fd5b60006137a084828501613664565b91505092915050565b600080604083850312156137bc57600080fd5b60006137ca85828601613664565b92505060206137db85828601613664565b9150509250929050565b6000806000606084860312156137fa57600080fd5b600061380886828701613664565b935050602061381986828701613664565b925050604061382a8682870161376b565b9150509250925092565b6000806000806080858703121561384a57600080fd5b600061385887828801613664565b945050602061386987828801613664565b935050604061387a8782880161376b565b925050606085013567ffffffffffffffff81111561389757600080fd5b6138a387828801613717565b91505092959194509250565b600080604083850312156138c257600080fd5b60006138d085828601613664565b92505060206138e1858286016136c3565b9150509250929050565b600080604083850312156138fe57600080fd5b600061390c85828601613664565b925050602061391d8582860161376b565b9150509250929050565b6000806020838503121561393a57600080fd5b600083013567ffffffffffffffff81111561395457600080fd5b61396085828601613679565b92509250509250929050565b60006020828403121561397e57600080fd5b600061398c848285016136d8565b91505092915050565b600080604083850312156139a857600080fd5b60006139b6858286016136d8565b92505060206139c785828601613664565b9150509250929050565b6000602082840312156139e357600080fd5b60006139f1848285016136ed565b91505092915050565b600060208284031215613a0c57600080fd5b6000613a1a84828501613702565b91505092915050565b600080600060608486031215613a3857600080fd5b600084013567ffffffffffffffff811115613a5257600080fd5b613a5e86828701613741565b935050602084013567ffffffffffffffff811115613a7b57600080fd5b613a8786828701613741565b925050604084013567ffffffffffffffff811115613aa457600080fd5b613ab086828701613741565b9150509250925092565b600060208284031215613acc57600080fd5b6000613ada8482850161376b565b91505092915050565b60008060408385031215613af657600080fd5b6000613b048582860161376b565b925050602083013567ffffffffffffffff811115613b2157600080fd5b613b2d85828601613741565b9150509250929050565b6000613b438383614239565b60208301905092915050565b613b58816149dc565b82525050565b613b6f613b6a826149dc565b614b72565b82525050565b6000613b808261485b565b613b8a8185614889565b9350613b9583614836565b8060005b83811015613bc6578151613bad8882613b37565b9750613bb88361487c565b925050600181019050613b99565b5085935050505092915050565b613bdc816149ee565b82525050565b613beb816149fa565b82525050565b613c02613bfd826149fa565b614b84565b82525050565b6000613c1382614866565b613c1d818561489a565b9350613c2d818560208601614a69565b613c3681614c8d565b840191505092915050565b6000613c4c82614871565b613c5681856148ab565b9350613c66818560208601614a69565b613c6f81614c8d565b840191505092915050565b6000613c8582614871565b613c8f81856148bc565b9350613c9f818560208601614a69565b80840191505092915050565b60008154613cb881614ac6565b613cc281866148bc565b94506001821660008114613cdd5760018114613cee57613d21565b60ff19831686528186019350613d21565b613cf785614846565b60005b83811015613d1957815481890152600182019150602081019050613cfa565b838801955050505b50505092915050565b6000613d376020836148ab565b9150613d4282614cab565b602082019050919050565b6000613d5a6009836148bc565b9150613d6582614cd4565b600982019050919050565b6000613d7d6005836148bc565b9150613d8882614cfd565b600582019050919050565b6000613da06013836148bc565b9150613dab82614d26565b601382019050919050565b6000613dc36032836148ab565b9150613dce82614d4f565b604082019050919050565b6000613de6601c836148ab565b9150613df182614d9e565b602082019050919050565b6000613e096019836148bc565b9150613e1482614dc7565b601982019050919050565b6000613e2c600a836148bc565b9150613e3782614df0565b600a82019050919050565b6000613e4f600d836148bc565b9150613e5a82614e19565b600d82019050919050565b6000613e726024836148ab565b9150613e7d82614e42565b604082019050919050565b6000613e956019836148ab565b9150613ea082614e91565b602082019050919050565b6000613eb86027836148ab565b9150613ec382614eba565b604082019050919050565b6000613edb602c836148ab565b9150613ee682614f09565b604082019050919050565b6000613efe6009836148bc565b9150613f0982614f58565b600982019050919050565b6000613f2160a4836148bc565b9150613f2c82614f81565b60a482019050919050565b6000613f446003836148bc565b9150613f4f82615068565b600382019050919050565b6000613f676038836148ab565b9150613f7282615091565b604082019050919050565b6000613f8a602a836148ab565b9150613f95826150e0565b604082019050919050565b6000613fad6029836148ab565b9150613fb88261512f565b604082019050919050565b6000613fd06020836148ab565b9150613fdb8261517e565b602082019050919050565b6000613ff3602c836148ab565b9150613ffe826151a7565b604082019050919050565b60006140166021836148bc565b9150614021826151f6565b602182019050919050565b60006140396029836148ab565b915061404482615245565b604082019050919050565b600061405c6027836148bc565b915061406782615294565b602782019050919050565b600061407f6098836148bc565b915061408a826152e3565b609882019050919050565b60006140a2600a836148bc565b91506140ad826153a4565b600a82019050919050565b60006140c56021836148ab565b91506140d0826153cd565b604082019050919050565b60006140e86009836148bc565b91506140f38261541c565b600982019050919050565b600061410b601d836148bc565b915061411682615445565b601d82019050919050565b600061412e600a836148bc565b91506141398261546e565b600a82019050919050565b6000614151600a836148bc565b915061415c82615497565b600a82019050919050565b60006141746031836148ab565b915061417f826154c0565b604082019050919050565b60006141976017836148bc565b91506141a28261550f565b601782019050919050565b60006141ba601f836148ab565b91506141c582615538565b602082019050919050565b60006141dd6004836148bc565b91506141e882615561565b600482019050919050565b60006142006011836148bc565b915061420b8261558a565b601182019050919050565b6000614223602f836148ab565b915061422e826155b3565b604082019050919050565b61424281614a50565b82525050565b61425181614a50565b82525050565b60006142638284613b5e565b60148201915081905092915050565b600061427e8285613bf1565b60208201915061428e8284613bf1565b6020820191508190509392505050565b60006142a982613d4d565b91506142b58286613c7a565b91506142c082613d70565b91506142cc8285613c7a565b91506142d7826140db565b91506142e38284613c7a565b91506142ee82613f37565b9150819050949350505050565b600061430682613f14565b91506143128287613cab565b915061431d82614144565b91506143298286613cab565b915061433482613e1f565b91506143408285613cab565b915061434b82614121565b91506143578284613cab565b915061436282613dfc565b915081905095945050505050565b600061437b82614072565b91506143878284613c7a565b915061439282613ef1565b915081905092915050565b60006143a882614095565b91506143b48289613cab565b91506143c08288613c7a565b91506143cb82613d93565b91506143d78287613cab565b91506143e28261404f565b91506143ee8286613c7a565b91506143f982614009565b91506144058285613cab565b915061441082613e42565b915061441c8284613c7a565b9150614427826141d0565b9150819050979650505050505050565b6000614442826140fe565b915061444e8284613c7a565b915081905092915050565b60006144648261418a565b91506144708285613c7a565b915061447b826141f3565b91506144878284613c7a565b91508190509392505050565b60006020820190506144a86000830184613b4f565b92915050565b60006080820190506144c36000830187613b4f565b6144d06020830186613b4f565b6144dd6040830185614248565b81810360608301526144ef8184613c08565b905095945050505050565b600060208201905081810360008301526145148184613b75565b905092915050565b60006020820190506145316000830184613bd3565b92915050565b600060208201905061454c6000830184613be2565b92915050565b6000602082019050818103600083015261456c8184613c41565b905092915050565b6000602082019050818103600083015261458d81613d2a565b9050919050565b600060208201905081810360008301526145ad81613db6565b9050919050565b600060208201905081810360008301526145cd81613dd9565b9050919050565b600060208201905081810360008301526145ed81613e65565b9050919050565b6000602082019050818103600083015261460d81613e88565b9050919050565b6000602082019050818103600083015261462d81613eab565b9050919050565b6000602082019050818103600083015261464d81613ece565b9050919050565b6000602082019050818103600083015261466d81613f5a565b9050919050565b6000602082019050818103600083015261468d81613f7d565b9050919050565b600060208201905081810360008301526146ad81613fa0565b9050919050565b600060208201905081810360008301526146cd81613fc3565b9050919050565b600060208201905081810360008301526146ed81613fe6565b9050919050565b6000602082019050818103600083015261470d8161402c565b9050919050565b6000602082019050818103600083015261472d816140b8565b9050919050565b6000602082019050818103600083015261474d81614167565b9050919050565b6000602082019050818103600083015261476d816141ad565b9050919050565b6000602082019050818103600083015261478d81614216565b9050919050565b60006020820190506147a96000830184614248565b92915050565b60006147b96147ca565b90506147c58282614af8565b919050565b6000604051905090565b600067ffffffffffffffff8211156147ef576147ee614c5e565b5b6147f882614c8d565b9050602081019050919050565b600067ffffffffffffffff8211156148205761481f614c5e565b5b61482982614c8d565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006148d282614a50565b91506148dd83614a50565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561491257614911614bd1565b5b828201905092915050565b600061492882614a50565b915061493383614a50565b92508261494357614942614c00565b5b828204905092915050565b600061495982614a50565b915061496483614a50565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561499d5761499c614bd1565b5b828202905092915050565b60006149b382614a50565b91506149be83614a50565b9250828210156149d1576149d0614bd1565b5b828203905092915050565b60006149e782614a30565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015614a87578082015181840152602081019050614a6c565b83811115614a96576000848401525b50505050565b6000614aa782614a50565b91506000821415614abb57614aba614bd1565b5b600182039050919050565b60006002820490506001821680614ade57607f821691505b60208210811415614af257614af1614c2f565b5b50919050565b614b0182614c8d565b810181811067ffffffffffffffff82111715614b2057614b1f614c5e565b5b80604052505050565b6000614b3482614a50565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614b6757614b66614bd1565b5b600182019050919050565b6000614b7d82614b8e565b9050919050565b6000819050919050565b6000614b9982614c9e565b9050919050565b6000614bab82614a50565b9150614bb683614a50565b925082614bc657614bc5614c00565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f537472696e67733a20686578206c656e67746820696e73756666696369656e74600082015250565b7f3c7265637420783d270000000000000000000000000000000000000000000000600082015250565b7f2720793d27000000000000000000000000000000000000000000000000000000600082015250565b7f222c20226465736372697074696f6e223a202200000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f7d2e777b66696c6c3a236666666666667d3c2f7374796c653e00000000000000600082015250565b7f7d2e637b66696c6c3a2300000000000000000000000000000000000000000000600082015250565b7f222c202276616c7565223a202200000000000000000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f44796e616d69634275666665723a20417070656e64696e67206f7574206f662060008201527f626f756e64732e00000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f272f3e3c2f7376673e0000000000000000000000000000000000000000000000600082015250565b7f3c7376672077696474683d273130323427206865696768743d2731303234272060008201527f69643d27746f6b656e2d302720786d6c6e733d27687474703a2f2f7777772e7760208201527f332e6f72672f323030302f737667273e203c7374796c653e23746f6b656e2d3060408201527f7b73686170652d72656e646572696e673a20637269737065646765733b7d207260608201527f6563747b77696474683a333270783b6865696768743a333270787d2e617b666960808201527f6c6c3a230000000000000000000000000000000000000000000000000000000060a082015250565b7f272f3e0000000000000000000000000000000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f222c202261747472696275746573223a205b7b2274726169745f74797065223a60008201527f2200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f222c2022696d616765223a2022646174613a696d6167652f7376672b786d6c3b60008201527f6261736536342c00000000000000000000000000000000000000000000000000602082015250565b7f3c7376672077696474683d273130302527206865696768743d2731303025272060008201527f76696577426f783d27302030203234203234272066696c6c3d276e6f6e65272060208201527f786d6c6e733d27687474703a2f2f7777772e77332e6f72672f323030302f737660408201527f67273e203c7265637420783d27302720793d2730272077696474683d2731303060608201527f2527206865696768743d2731303025272066696c6c3d27230000000000000000608082015250565b7f7b226e616d65223a202200000000000000000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f2720636c6173733d270000000000000000000000000000000000000000000000600082015250565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000600082015250565b7f7d2e647b66696c6c3a2300000000000000000000000000000000000000000000600082015250565b7f7d2e627b66696c6c3a2300000000000000000000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000600082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f227d5d7d00000000000000000000000000000000000000000000000000000000600082015250565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000600082015250565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b61560b816149dc565b811461561657600080fd5b50565b615622816149ee565b811461562d57600080fd5b50565b615639816149fa565b811461564457600080fd5b50565b61565081614a04565b811461565b57600080fd5b50565b61566781614a50565b811461567257600080fd5b5056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa26469706673582212202f93c84e4232d2c930b21a99f5fc464cee6d32db80e60eabfa83fefd77cec25f64736f6c63430008040033
Verified Source Code Full Match
Compiler: v0.8.4+commit.c7e474f2
EVM: istanbul
Optimization: No
RCS.sol 240 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./Errors.sol";
import "./MagicNumbers.sol";
import "./Base64.sol";
import "./Ownable.sol";
import "@divergencetech/ethier/contracts/utils/DynamicBuffer.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Address.sol";
/// @title RCS
/// @author @0x__jj, @llio (Deca)
contract RCS is ERC721, ReentrancyGuard, AccessControl, Ownable, MagicNumbers {
using Address for address;
using DynamicBuffer for bytes;
mapping(address => bool) public minted;
mapping(uint256 => uint256) public expiryTime;
mapping(uint256 => string) public colours;
string public _name_;
string public _description;
string public _attribute;
uint256 public totalSupply = 0;
bool public attestationEnabled = false;
uint256 public constant MAX_SUPPLY = 1025;
uint256 public constant ONE_YEAR = 60 * 60 * 24 * 365;
bytes32 public merkleRoot;
event Mint(uint256 indexed tokenId, address indexed minter);
constructor(
string memory name_,
string memory description_,
string memory attribute_,
address[] memory admins_
) ERC721("RCS", "RCS") {
_setOwnership(msg.sender);
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
for (uint256 i = 0; i < admins_.length; i++) {
_grantRole(DEFAULT_ADMIN_ROLE, admins_[i]);
}
colours[0] = "ffffff";
colours[1] = "ffffff";
colours[2] = "ffffff";
colours[3] = "ffffff";
_name_ = name_;
_description = description_;
_attribute = attribute_;
totalSupply++;
_safeMint(address(0xDeCaDECadECadecADecadeCAdECadECAdeCAdecA), 0);
}
function setMerkleRoot(bytes32 merkleRoot_) external onlyRole(DEFAULT_ADMIN_ROLE) {
merkleRoot = merkleRoot_;
}
function setMetadata(
string memory name_,
string memory description_,
string memory attribute_
) external onlyRole(DEFAULT_ADMIN_ROLE) {
_name_ = name_;
_description = description_;
_attribute = attribute_;
}
function setOwnership(address newOwner) external onlyRole(DEFAULT_ADMIN_ROLE) {
_setOwnership(newOwner);
}
function setColor(uint256 index, string memory value) external onlyRole(DEFAULT_ADMIN_ROLE) {
colours[index] = value;
}
function enableAttestation() external onlyRole(DEFAULT_ADMIN_ROLE) {
attestationEnabled = true;
}
function isAttested(uint256 tokenId_) public view returns (bool) {
return (expiryTime[tokenId_] > block.timestamp);
}
function attestToken(uint256 tokenId_) external {
if (!attestationEnabled) revert AttestationIsNotEnabled();
if (ownerOf(tokenId_) != msg.sender) revert DoesNotOwnToken();
expiryTime[tokenId_] = block.timestamp + ONE_YEAR;
}
function mint(bytes32[] calldata _merkleProof) external nonReentrant returns (uint256) {
if (totalSupply >= MAX_SUPPLY) revert MaxSupplyReached();
if (minted[msg.sender]) revert AlreadyMinted();
if (msg.sender.isContract()) revert CannotMintFromContract();
uint256 tokenId = totalSupply;
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
if (!MerkleProof.verify(_merkleProof, merkleRoot, leaf)) revert ProofInvalidOrNotInAllowlist();
totalSupply++;
minted[msg.sender] = true;
_safeMint(msg.sender, tokenId);
return tokenId;
}
function tokenURI(uint256 tokenId_) public view override(ERC721) returns (string memory) {
string memory json = Base64.encode(
bytes(
string(
abi.encodePacked(
'{"name": "',
_name_,
toString(tokenId_),
'", "description": "',
_description,
'", "image": "data:image/svg+xml;base64,',
Base64.encode(_renderSVG(tokenId_)),
'", "attributes": [{"trait_type":"',
_attribute,
'", "value": "',
toString(tokenId_),
'"}]}'
)
)
)
);
return string(abi.encodePacked("data:application/json;base64,", json));
}
function renderSVG(uint256 tokenId_) public view returns (string memory) {
return string(_renderSVG(tokenId_));
}
// Inspired by Every Icon by @divergenceharri and @divergencearran
// 0xf9a423b86afbf8db41d7f24fa56848f56684e43f
function _renderSVG(uint256 tokenId_) internal view returns (bytes memory) {
if (!_exists(tokenId_)) revert NonexistentToken();
if (tokenId_ != 0) {
return
abi.encodePacked(
"<svg width='100%' height='100%' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'> <rect x='0' y='0' width='100%' height='100%' fill='#",
!isAttested(tokenId_) ? "ffffff" : colours[magic[tokenId_]],
"'/></svg>"
);
} else {
bytes memory svg = DynamicBuffer.allocate(2**16); // 64KB
svg.appendSafe(
abi.encodePacked(
"<svg width='1024' height='1024' id='token-0' xmlns='http://www.w3.org/2000/svg'> <style>#token-0{shape-rendering: crispedges;} rect{width:32px;height:32px}.a{fill:#",
colours[0],
"}.b{fill:#",
colours[1],
"}.c{fill:#",
colours[2],
"}.d{fill:#",
colours[3],
"}.w{fill:#ffffff}</style>"
)
);
string[4] memory classes = ["a", "b", "c", "d"];
uint256 x;
uint256 y;
for (uint256 i = 0; i < 1024; i++) {
x = (i % 32) * 32;
y = (i / 32) * 32;
svg.appendSafe(
abi.encodePacked(
"<rect x='",
toString(x),
"' y='",
toString(y),
"' class='",
isAttested(i + 1) ? classes[magic[i + 1]] : "w",
"'/>"
)
);
}
svg.appendSafe("</svg>");
return svg;
}
}
function getTokensOfOwner(address _owner) public view returns (uint256[] memory) {
uint256 tokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](tokenCount);
uint256 seen = 0;
for (uint256 i; i < totalSupply; i++) {
if (ownerOf(i) == _owner) {
tokenIds[seen] = i;
seen++;
}
if (seen == tokenCount) break;
}
return tokenIds;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, AccessControl) returns (bool) {
return super.supportsInterface(interfaceId);
}
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
}
Base64.sol 62 lines
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Base64 /// @notice Provides a function for encoding some bytes in base64 /// @author Brecht Devos <[email protected]> library Base64 { bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /// @notice Encodes some bytes to the base64 representation function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) { } { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); } }
Errors.sol 10 lines
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; error DoesNotOwnToken(); error MaxSupplyReached(); error AlreadyMinted(); error ProofInvalidOrNotInAllowlist(); error CannotMintFromContract(); error NonexistentToken(); error AttestationIsNotEnabled();
Ownable.sol 29 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Ownable {
address private _convenienceOwner;
event OwnershipSet(address indexed previousOwner, address indexed newOwner);
/// @notice returns the address of the current _convenienceOwner
/// @dev not used for access control, used by services that require a single owner account
/// @return _convenienceOwner address
function owner() public view virtual returns (address) {
return _convenienceOwner;
}
/// @notice Set the _convenienceOwner address
/// @dev not used for access control, used by services that require a single owner account
/// @param newOwner address of the new _convenienceOwner
function _setOwnership(address newOwner) internal virtual {
address oldOwner = _convenienceOwner;
_convenienceOwner = newOwner;
emit OwnershipSet(oldOwner, newOwner);
}
/// @notice This empty reserved space is put in place to allow future versions to add new
/// variables without shifting down storage in the inheritance chain.
/// See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
uint256[100] private __gap;
}
MagicNumbers.sol 1032 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
contract MagicNumbers {
uint256[] public magic = [
4152542045564552595748455245,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
2,
2,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
0,
0,
0,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
2,
2,
1,
1,
1,
0,
0,
0,
0,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
1,
1,
1,
1,
1,
1,
0,
0,
0,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
2,
1,
1,
1,
1,
1,
1,
1,
1,
0,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
3,
3,
3,
3,
3,
3,
3,
3,
3,
3,
3,
2,
2,
2,
2,
2,
2,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
3,
2,
1,
2,
3,
2,
1,
2,
3,
1,
1,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
3,
1,
2,
3,
3,
3,
2,
1,
3,
1,
1,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
3,
3,
3,
3,
1,
3,
3,
3,
3,
1,
1,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
2,
1,
0,
0,
0,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
2,
2,
2,
2,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
0,
0,
0,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
0,
0,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
0,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
0,
0,
1,
2,
2,
2,
2,
2,
2,
2,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
0,
0,
0,
2,
2,
2,
2,
2,
2,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0
];
}
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @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
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Math.sol 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @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 / b + (a % b == 0 ? 0 : 1);
}
}
ERC721.sol 424 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
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) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public 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 owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
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: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @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 of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {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 a {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 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 {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
AccessControl.sol 223 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @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 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);
/**
* @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;
}
IAccessControl.sol 88 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
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);
}
DynamicBuffer.sol 106 lines
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0;
/// @title DynamicBuffer
/// @author David Huber (@cxkoda) and Simon Fremaux (@dievardump). See also
/// https://raw.githubusercontent.com/dievardump/solidity-dynamic-buffer
/// @notice This library is used to allocate a big amount of container memory
// which will be subsequently filled without needing to reallocate
/// memory.
/// @dev First, allocate memory.
/// Then use `buffer.appendUnchecked(theBytes)` or `appendSafe()` if
/// bounds checking is required.
library DynamicBuffer {
/// @notice Allocates container space for the DynamicBuffer
/// @param capacity The intended max amount of bytes in the buffer
/// @return buffer The memory location of the buffer
/// @dev Allocates `capacity + 0x60` bytes of space
/// The buffer array starts at the first container data position,
/// (i.e. `buffer = container + 0x20`)
function allocate(uint256 capacity)
internal
pure
returns (bytes memory buffer)
{
assembly {
// Get next-free memory address
let container := mload(0x40)
// Allocate memory by setting a new next-free address
{
// Add 2 x 32 bytes in size for the two length fields
// Add 32 bytes safety space for 32B chunked copy
let size := add(capacity, 0x60)
let newNextFree := add(container, size)
mstore(0x40, newNextFree)
}
// Set the correct container length
{
let length := add(capacity, 0x40)
mstore(container, length)
}
// The buffer starts at idx 1 in the container (0 is length)
buffer := add(container, 0x20)
// Init content with length 0
mstore(buffer, 0)
}
return buffer;
}
/// @notice Appends data to buffer, and update buffer length
/// @param buffer the buffer to append the data to
/// @param data the data to append
/// @dev Does not perform out-of-bound checks (container capacity)
/// for efficiency.
function appendUnchecked(bytes memory buffer, bytes memory data)
internal
pure
{
assembly {
let length := mload(data)
for {
data := add(data, 0x20)
let dataEnd := add(data, length)
let copyTo := add(buffer, add(mload(buffer), 0x20))
} lt(data, dataEnd) {
data := add(data, 0x20)
copyTo := add(copyTo, 0x20)
} {
// Copy 32B chunks from data to buffer.
// This may read over data array boundaries and copy invalid
// bytes, which doesn't matter in the end since we will
// later set the correct buffer length, and have allocated an
// additional word to avoid buffer overflow.
mstore(copyTo, mload(data))
}
// Update buffer length
mstore(buffer, add(mload(buffer), length))
}
}
/// @notice Appends data to buffer, and update buffer length
/// @param buffer the buffer to append the data to
/// @param data the data to append
/// @dev Performs out-of-bound checks and calls `appendUnchecked`.
function appendSafe(bytes memory buffer, bytes memory data) internal pure {
uint256 capacity;
uint256 length;
assembly {
capacity := sub(mload(sub(buffer, 0x20)), 0x40)
length := mload(buffer)
}
require(
length + data.length <= capacity,
"DynamicBuffer: Appending out of bounds."
);
appendUnchecked(buffer, data);
}
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
MerkleProof.sol 52 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Trees proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
}
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
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MAX_SUPPLY 0x32cb6b0c → uint256
ONE_YEAR 0x16d3bfbb → uint256
_attribute 0x03e399c0 → string
_description 0xcfa84dfe → string
_name_ 0x35b2802e → string
attestationEnabled 0x287726c1 → bool
balanceOf 0x70a08231 → uint256
colours 0xc76ab940 → string
expiryTime 0xbe010c40 → uint256
getApproved 0x081812fc → address
getRoleAdmin 0x248a9ca3 → bytes32
getTokensOfOwner 0x5de6dc55 → uint256[]
hasRole 0x91d14854 → bool
isApprovedForAll 0xe985e9c5 → bool
isAttested 0x7ca4e3d6 → bool
magic 0xf8ea173e → uint256
merkleRoot 0x2eb4a7ab → bytes32
minted 0x1e7269c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
renderSVG 0xd12a4c98 → string
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 15 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
attestToken 0xf414a308
uint256 tokenId_
enableAttestation 0x524ce085
No parameters
grantRole 0x2f2ff15d
bytes32 role
address account
mint 0xb77a147b
bytes32[] _merkleProof
returns: uint256
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setColor 0xa44b6b74
uint256 index
string value
setMerkleRoot 0x7cb64759
bytes32 merkleRoot_
setMetadata 0x0890d80c
string name_
string description_
string attribute_
setOwnership 0xa7016023
address newOwner
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
Recent Transactions
No transactions found for this address