Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xa2ec61AD94F139A69a05fE58CD4D8dc532449C17
Balance 0 ETH
Nonce 1
Code Size 21752 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

21752 bytes
0x60806040526004361061023b5760003560e01c8063911c98741161012e578063b88d4fde116100ab578063e0a8309f1161006f578063e0a8309f14610850578063e985e9c514610879578063ec057f61146108b6578063f2fde38b146108e1578063f6aacfb11461090a5761023b565b8063b88d4fde14610768578063bf968a1b14610784578063c87b56dd146107ad578063dd2e0ac0146107ea578063de3efc91146108135761023b565b80639eb56afc116100f25780639eb56afc146106a4578063a22cb465146106c0578063a475b5dd146106e9578063ad413e3314610700578063b70f402d1461072b5761023b565b8063911c9874146105bf57806392063249146105e857806395d89b411461061357806396c501d01461063e5780639ae697bf146106675761023b565b80634d87816d116101bc578063715018a611610180578063715018a6146104ec57806380f203631461050357806389d3caea1461052c5780638da5cb5b146105695780638f32d59b146105945761023b565b80634d87816d146103f557806354214f691461041e5780636352211e1461044957806367db3b8f1461048657806370a08231146104af5761023b565b806323b872dd1161020357806323b872dd1461032c5780632c0192111461034857806333b945d2146103735780633bbed4a0146103b057806342842e0e146103d95761023b565b806301ffc9a71461024057806306fdde031461027d578063081812fc146102a8578063095ea7b3146102e557806318160ddd14610301575b600080fd5b34801561024c57600080fd5b5061026760048036038101906102629190613c1e565b610947565b6040516102749190613c66565b60405180910390f35b34801561028957600080fd5b506102926109d9565b60405161029f9190613d11565b60405180910390f35b3480156102b457600080fd5b506102cf60048036038101906102ca9190613d69565b610a6b565b6040516102dc9190613dd7565b60405180910390f35b6102ff60048036038101906102fa9190613e1e565b610aea565b005b34801561030d57600080fd5b50610316610b4d565b6040516103239190613e6d565b60405180910390f35b61034660048036038101906103419190613e88565b610b64565b005b34801561035457600080fd5b5061035d610bc9565b60405161036a9190613d11565b60405180910390f35b34801561037f57600080fd5b5061039a60048036038101906103959190613edb565b610c5b565b6040516103a79190613c66565b60405180910390f35b3480156103bc57600080fd5b506103d760048036038101906103d29190613f1b565b610c7f565b005b6103f360048036038101906103ee9190613e88565b610ccb565b005b34801561040157600080fd5b5061041c60048036038101906104179190613f74565b610ceb565b005b34801561042a57600080fd5b50610433610d22565b6040516104409190613c66565b60405180910390f35b34801561045557600080fd5b50610470600480360381019061046b9190613d69565b610d39565b60405161047d9190613dd7565b60405180910390f35b34801561049257600080fd5b506104ad60048036038101906104a89190614019565b610d4b565b005b3480156104bb57600080fd5b506104d660048036038101906104d19190613f1b565b610da9565b6040516104e39190613e6d565b60405180910390f35b3480156104f857600080fd5b50610501610e61565b005b34801561050f57600080fd5b5061052a60048036038101906105259190613d69565b610e75565b005b34801561053857600080fd5b50610553600480360381019061054e91906140cf565b610fb0565b60405161056091906141f6565b60405180910390f35b34801561057557600080fd5b5061057e61115e565b60405161058b9190613dd7565b60405180910390f35b3480156105a057600080fd5b506105a9611187565b6040516105b69190613c66565b60405180910390f35b3480156105cb57600080fd5b506105e660048036038101906105e19190614218565b6111c4565b005b3480156105f457600080fd5b506105fd6113fd565b60405161060a9190613dd7565b60405180910390f35b34801561061f57600080fd5b50610628611427565b6040516106359190613d11565b60405180910390f35b34801561064a57600080fd5b5061066560048036038101906106609190613f1b565b6114b9565b005b34801561067357600080fd5b5061068e60048036038101906106899190613f1b565b611505565b60405161069b9190613e6d565b60405180910390f35b6106be60048036038101906106b99190614258565b611551565b005b3480156106cc57600080fd5b506106e760048036038101906106e291906142cc565b611b96565b005b3480156106f557600080fd5b506106fe611e1e565b005b34801561070c57600080fd5b50610715611e43565b6040516107229190613d11565b60405180910390f35b34801561073757600080fd5b50610752600480360381019061074d9190613d69565b611ed5565b60405161075f9190613c66565b60405180910390f35b610782600480360381019061077d919061443c565b611eff565b005b34801561079057600080fd5b506107ab60048036038101906107a69190613d69565b611f66565b005b3480156107b957600080fd5b506107d460048036038101906107cf9190613d69565b611f7a565b6040516107e19190613d11565b60405180910390f35b3480156107f657600080fd5b50610811600480360381019061080c9190613d69565b6121c5565b005b34801561081f57600080fd5b5061083a60048036038101906108359190613d69565b612301565b604051610847919061451f565b60405180910390f35b34801561085c57600080fd5b506108776004803603810190610872919061453a565b6123e3565b005b34801561088557600080fd5b506108a0600480360381019061089b919061457a565b61242f565b6040516108ad9190613c66565b60405180910390f35b3480156108c257600080fd5b506108cb6124c3565b6040516108d89190613d11565b60405180910390f35b3480156108ed57600080fd5b5061090860048036038101906109039190613f1b565b612555565b005b34801561091657600080fd5b50610931600480360381019061092c9190613d69565b6125d8565b60405161093e9190613c66565b60405180910390f35b60006301ffc9a760e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806109a257506380ac58cd60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806109d25750635b5e139f60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b6060600680546109e8906145e9565b80601f0160208091040260200160405190810160405280929190818152602001828054610a14906145e9565b8015610a615780601f10610a3657610100808354040283529160200191610a61565b820191906000526020600020905b815481529060010190602001808311610a4457829003601f168201915b5050505050905090565b6000610a7682612605565b610aac576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60011515610af7826125d8565b15151415600f90610b3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3591906146b3565b60405180910390fd5b50610b498282612664565b5050565b6000610b576127a8565b6005546004540303905090565b60011515610b71826125d8565b15151415600f90610bb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610baf91906146b3565b60405180910390fd5b50610bc48383836127ad565b505050565b606060228054610bd8906145e9565b80601f0160208091040260200160405190810160405280929190818152602001828054610c04906145e9565b8015610c515780601f10610c2657610100808354040283529160200191610c51565b820191906000526020600020905b815481529060010190602001808311610c3457829003601f168201915b5050505050905090565b600081600c6000858152602001908152602001600020600101541115905092915050565b610c87612acf565b80601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610ce683838360405180602001604052806000815250611eff565b505050565b610cf3612acf565b80601f600084815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6000602060009054906101000a900460ff16905090565b6000610d4482612b4d565b9050919050565b610d53612acf565b60008103610d6e57828260239182610d6c929190614877565b505b60018103610d8957828260229182610d87929190614877565b505b60028103610da457828260219182610da2929190614877565b505b505050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610e10576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054169050919050565b610e69612acf565b610e736000612c19565b565b610e7e81612301565b6000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614601090610ef3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eea91906146b3565b60405180910390fd5b506000610eff82610d39565b9050610f0a81612cdd565b6001600c600084815260200190815260200160002060000160006101000a81548160ff02191690831515021790555042600c600084815260200190815260200160002060010181905550600d60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000815480929190610fa790614976565b91905055505050565b610fb8613b0f565b60006002547f68e83002b91b0fd96d4df3566b5122221117e3ec6c2468fda594f6491f89b1c984604051602001610ff09291906149d7565b60405160208183030381529060405280519060200120604051602001611017929190614a78565b604051602081830303815290604052805190602001209050600061108886868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505083612f6990919063ffffffff16565b905060405180608001604052808573ffffffffffffffffffffffffffffffffffffffff16815260200187878080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505081526020018273ffffffffffffffffffffffffffffffffffffffff168152602001600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815250925050509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061119161115e565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b60006111cf83610d39565b90506111da83610d39565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611247576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123e90614b21565b60405180910390fd5b6000600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160009054906101000a900460ff161561130a5760005b6112a9610b4d565b811015611308576112b981612605565b156112f757600c600082815260200190815260200160002060000160009054906101000a900460ff16156112f65781806112f290614976565b9250505b5b8061130190614976565b90506112a1565b505b600060405180606001604052808573ffffffffffffffffffffffffffffffffffffffff16815260200183815260200160011515815250905080600d60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015560408201518160020160006101000a81548160ff0219169083151502179055509050505050505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060078054611436906145e9565b80601f0160208091040260200160405190810160405280929190818152602001828054611462906145e9565b80156114af5780601f10611484576101008083540402835291602001916114af565b820191906000526020600020905b81548152906001019060200180831161149257829003601f168201915b5050505050905090565b6114c1612acf565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549050919050565b838333600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036115e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115dc90614b8d565b60405180910390fd5b60006002547f68e83002b91b0fd96d4df3566b5122221117e3ec6c2468fda594f6491f89b1c98360405160200161161d9291906149d7565b60405160208183030381529060405280519060200120604051602001611644929190614a78565b60405160208183030381529060405280519060200120905060006116b585858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505083612f6990919063ffffffff16565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611747576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173e90614bf9565b60405180910390fd5b600087611752610b4d565b61175c9190614c19565b90506000601a60019054906101000a900460ff1661177a578761178b565b601a60019054906101000a900460ff165b90508061179a5760175461179e565b6018545b891115601b906117e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117db91906146b3565b60405180910390fd5b50806117ff57601a60009054906101000a900460ff16611810565b601a60019054906101000a900460ff165b601c90611853576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161184a91906146b3565b60405180910390fd5b508061186157601654611865565b6015545b821115601d906118ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118a291906146b3565b60405180910390fd5b50806118b9576017546118bd565b6018545b898261190857601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611949565b601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020545b6119539190614c19565b1115601d90611998576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161198f91906146b3565b60405180910390fd5b508015611af057886019546119ad9190614c4d565b341015601e906119f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119ea91906146b3565b60405180910390fd5b5088601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a3f9190614c19565b601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015611aea573d6000803e3d6000fd5b50611b7f565b88601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b3b9190614c19565b601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b611b89338a612f90565b5050505050505050505050565b6001611ba8611ba3612fae565b611505565b10600f90611bec576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611be391906146b3565b60405180910390fd5b50611bf5612fae565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611c62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c5990614cdb565b60405180910390fd5b80600e6000611c6f612fae565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611d1c612fae565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611d619190613c66565b60405180910390a38015611e1057601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020829080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b611e1a8282612fb6565b5050565b611e26612acf565b6001602060006101000a81548160ff021916908315150217905550565b606060218054611e52906145e9565b80601f0160208091040260200160405190810160405280929190818152602001828054611e7e906145e9565b8015611ecb5780601f10611ea057610100808354040283529160200191611ecb565b820191906000526020600020905b815481529060010190602001808311611eae57829003601f168201915b5050505050905090565b6000601f600083815260200190815260200160002060009054906101000a900460ff169050919050565b60011515611f0c836125d8565b15151415600f90611f53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f4a91906146b3565b60405180910390fd5b50611f60848484846130c1565b50505050565b611f6e612acf565b611f7781613134565b50565b6060611f8582612605565b611fc4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fbb90614d47565b60405180910390fd5b6000611fcf83611ed5565b6120d257611fdb610d22565b612058573073ffffffffffffffffffffffffffffffffffffffff16632c0192116040518163ffffffff1660e01b8152600401600060405180830381865afa15801561202a573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906120539190614e08565b6120cd565b3073ffffffffffffffffffffffffffffffffffffffff1663ec057f616040518163ffffffff1660e01b8152600401600060405180830381865afa1580156120a3573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906120cc9190614e08565b5b612147565b3073ffffffffffffffffffffffffffffffffffffffff1663ad413e336040518163ffffffff1660e01b8152600401600060405180830381865afa15801561211d573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906121469190614e08565b5b90506000612153610d22565b8015612165575061216384611ed5565b155b61218e578160405160200161217a9190614e82565b6040516020818303038152906040526121b9565b81612198856131f1565b6040516020016121a9929190614ee5565b6040516020818303038152906040525b90508092505050919050565b6121ce81612301565b6000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614601090612243576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161223a91906146b3565b60405180910390fd5b50600061224f82610d39565b90506000600c600084815260200190815260200160002060000160006101000a81548160ff02191690831515021790555067ffffffffffffffff8016600c600084815260200190815260200160002060010181905550600d60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160008154809291906122f890614f14565b91905055505050565b612309613b79565b600061231483610d39565b9050600d60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600182015481526020016002820160009054906101000a900460ff161515151581525050915050919050565b6123eb612acf565b80156124105781601a60016101000a81548160ff02191690831515021790555061242b565b81601a60006101000a81548160ff0219169083151502179055505b5050565b6000600e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6060602380546124d2906145e9565b80601f01602080910402602001604051908101604052809291908181526020018280546124fe906145e9565b801561254b5780601f106125205761010080835404028352916020019161254b565b820191906000526020600020905b81548152906001019060200180831161252e57829003601f168201915b5050505050905090565b61255d612acf565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036125cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125c390614faf565b60405180910390fd5b6125d581612c19565b50565b6000600c600083815260200190815260200160002060000160009054906101000a900460ff169050919050565b6000816126106127a8565b1115801561261f575060045482105b801561265d575060007c0100000000000000000000000000000000000000000000000000000000600860008581526020019081526020016000205416145b9050919050565b600061266f82610d39565b90508073ffffffffffffffffffffffffffffffffffffffff16612690612fae565b73ffffffffffffffffffffffffffffffffffffffff16146126f3576126bc816126b7612fae565b61242f565b6126f2576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b82600a600084815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b600090565b60006127b882612b4d565b90508373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461281f576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008061282b84613351565b91509150612841818761283c612fae565b613378565b61288d5761285686612851612fae565b61242f565b61288c576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16036128f3576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61290086868660016133bc565b801561290b57600082555b600960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081546001900391905081905550600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008154600101919050819055506129d9856129b58888876133c2565b7c0200000000000000000000000000000000000000000000000000000000176133ea565b600860008681526020019081526020016000208190555060007c0200000000000000000000000000000000000000000000000000000000841603612a5f5760006001850190506000600860008381526020019081526020016000205403612a5d576004548114612a5c578360086000838152602001908152602001600020819055505b5b505b838573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612ac78686866001613415565b505050505050565b612ad761341b565b73ffffffffffffffffffffffffffffffffffffffff16612af561115e565b73ffffffffffffffffffffffffffffffffffffffff1614612b4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b429061501b565b60405180910390fd5b565b60008082905080612b5c6127a8565b11612be257600454811015612be15760006008600083815260200190815260200160002054905060007c0100000000000000000000000000000000000000000000000000000000821603612bdf575b60008103612bd5576008600083600190039350838152602001908152602001600020549050612bab565b8092505050612c14565b505b5b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050905060005b6000821115612f64576000601160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600184612d7e919061503b565b81548110612d8f57612d8e61506f565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506000600e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff16612e70612fae565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c316000604051612eb69190613c66565b60405180910390a3601160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805480612f0d57612f0c61509e565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558280612f4d90614f14565b9350508180612f5b90614976565b92505050612d27565b505050565b6000806000612f788585613423565b91509150612f8581613474565b819250505092915050565b612faa828260405180602001604052806000815250613640565b5050565b600033905090565b80600b6000612fc3612fae565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16613070612fae565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516130b59190613c66565b60405180910390a35050565b6130cc848484610b64565b60008373ffffffffffffffffffffffffffffffffffffffff163b1461312e576130f7848484846136de565b61312d576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b50505050565b600061313f82610d39565b90506000600c600084815260200190815260200160002060000160006101000a81548160ff02191690831515021790555067ffffffffffffffff8016600c600084815260200190815260200160002060010181905550600d60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160008154809291906131e890614f14565b91905055505050565b606060008203613238576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061334c565b600082905060005b6000821461326a57808061325390614976565b915050600a8261326391906150fc565b9150613240565b60008167ffffffffffffffff81111561328657613285614311565b5b6040519080825280601f01601f1916602001820160405280156132b85781602001600182028036833780820191505090505b5090505b60008514613345576001826132d1919061503b565b9150600a856132e0919061512d565b60306132ec9190614c19565b60f81b8183815181106133025761330161506f565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561333e91906150fc565b94506132bc565b8093505050505b919050565b6000806000600a600085815260200190815260200160002090508092508254915050915091565b600073ffffffffffffffffffffffffffffffffffffffff8316925073ffffffffffffffffffffffffffffffffffffffff821691508382148383141790509392505050565b50505050565b60008060e883901c905060e86133d986868461382e565b62ffffff16901b9150509392505050565b600073ffffffffffffffffffffffffffffffffffffffff83169250814260a01b178317905092915050565b50505050565b600033905090565b60008060418351036134645760008060006020860151925060408601519150606086015160001a905061345887828585613837565b9450945050505061346d565b60006002915091505b9250929050565b600060048111156134885761348761515e565b5b81600481111561349b5761349a61515e565b5b031561363d57600160048111156134b5576134b461515e565b5b8160048111156134c8576134c761515e565b5b03613508576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016134ff906151d9565b60405180910390fd5b6002600481111561351c5761351b61515e565b5b81600481111561352f5761352e61515e565b5b0361356f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161356690615245565b60405180910390fd5b600360048111156135835761358261515e565b5b8160048111156135965761359561515e565b5b036135d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135cd906152d7565b60405180910390fd5b6004808111156135e9576135e861515e565b5b8160048111156135fc576135fb61515e565b5b0361363c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161363390615369565b60405180910390fd5b5b50565b61364a8383613943565b60008373ffffffffffffffffffffffffffffffffffffffff163b146136d95760006004549050600083820390505b61368b60008683806001019450866136de565b6136c1576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8181106136785781600454146136d657600080fd5b50505b505050565b60008373ffffffffffffffffffffffffffffffffffffffff1663150b7a02613704612fae565b8786866040518563ffffffff1660e01b815260040161372694939291906153d3565b6020604051808303816000875af192505050801561376257506040513d601f19601f8201168201806040525081019061375f9190615434565b60015b6137db573d8060008114613792576040519150601f19603f3d011682016040523d82523d6000602084013e613797565b606091505b5060008151036137d3576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050949350505050565b60009392505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c111561387257600060039150915061393a565b601b8560ff161415801561388a5750601c8560ff1614155b1561389c57600060049150915061393a565b6000600187878787604051600081526020016040526040516138c1949392919061547d565b6020604051602081039080840390855afa1580156138e3573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036139315760006001925092505061393a565b80600092509250505b94509492505050565b6000600454905060008203613984576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61399160008483856133bc565b600160406001901b178202600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550613a08836139f960008660006133c2565b613a0285613aff565b176133ea565b6008600083815260200190815260200160002081905550600080838301905073ffffffffffffffffffffffffffffffffffffffff85169150828260007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600183015b818114613aa957808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600181019050613a6e565b5060008203613ae4576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806004819055505050613afa6000848385613415565b505050565b60006001821460e11b9050919050565b6040518060800160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160608152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016000151581525090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b613bfb81613bc6565b8114613c0657600080fd5b50565b600081359050613c1881613bf2565b92915050565b600060208284031215613c3457613c33613bbc565b5b6000613c4284828501613c09565b91505092915050565b60008115159050919050565b613c6081613c4b565b82525050565b6000602082019050613c7b6000830184613c57565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015613cbb578082015181840152602081019050613ca0565b60008484015250505050565b6000601f19601f8301169050919050565b6000613ce382613c81565b613ced8185613c8c565b9350613cfd818560208601613c9d565b613d0681613cc7565b840191505092915050565b60006020820190508181036000830152613d2b8184613cd8565b905092915050565b6000819050919050565b613d4681613d33565b8114613d5157600080fd5b50565b600081359050613d6381613d3d565b92915050565b600060208284031215613d7f57613d7e613bbc565b5b6000613d8d84828501613d54565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613dc182613d96565b9050919050565b613dd181613db6565b82525050565b6000602082019050613dec6000830184613dc8565b92915050565b613dfb81613db6565b8114613e0657600080fd5b50565b600081359050613e1881613df2565b92915050565b60008060408385031215613e3557613e34613bbc565b5b6000613e4385828601613e09565b9250506020613e5485828601613d54565b9150509250929050565b613e6781613d33565b82525050565b6000602082019050613e826000830184613e5e565b92915050565b600080600060608486031215613ea157613ea0613bbc565b5b6000613eaf86828701613e09565b9350506020613ec086828701613e09565b9250506040613ed186828701613d54565b9150509250925092565b60008060408385031215613ef257613ef1613bbc565b5b6000613f0085828601613d54565b9250506020613f1185828601613d54565b9150509250929050565b600060208284031215613f3157613f30613bbc565b5b6000613f3f84828501613e09565b91505092915050565b613f5181613c4b565b8114613f5c57600080fd5b50565b600081359050613f6e81613f48565b92915050565b60008060408385031215613f8b57613f8a613bbc565b5b6000613f9985828601613d54565b9250506020613faa85828601613f5f565b9150509250929050565b600080fd5b600080fd5b600080fd5b60008083601f840112613fd957613fd8613fb4565b5b8235905067ffffffffffffffff811115613ff657613ff5613fb9565b5b60208301915083600182028301111561401257614011613fbe565b5b9250929050565b60008060006040848603121561403257614031613bbc565b5b600084013567ffffffffffffffff8111156140505761404f613bc1565b5b61405c86828701613fc3565b9350935050602061406f86828701613d54565b9150509250925092565b60008083601f84011261408f5761408e613fb4565b5b8235905067ffffffffffffffff8111156140ac576140ab613fb9565b5b6020830191508360018202830111156140c8576140c7613fbe565b5b9250929050565b6000806000604084860312156140e8576140e7613bbc565b5b600084013567ffffffffffffffff81111561410657614105613bc1565b5b61411286828701614079565b9350935050602061412586828701613e09565b9150509250925092565b61413881613db6565b82525050565b600081519050919050565b600082825260208201905092915050565b60006141658261413e565b61416f8185614149565b935061417f818560208601613c9d565b61418881613cc7565b840191505092915050565b60006080830160008301516141ab600086018261412f565b50602083015184820360208601526141c3828261415a565b91505060408301516141d8604086018261412f565b5060608301516141eb606086018261412f565b508091505092915050565b600060208201905081810360008301526142108184614193565b905092915050565b6000806040838503121561422f5761422e613bbc565b5b600061423d85828601613d54565b925050602061424e85828601613e09565b9150509250929050565b6000806000806060858703121561427257614271613bbc565b5b600085013567ffffffffffffffff8111156142905761428f613bc1565b5b61429c87828801614079565b945094505060206142af87828801613d54565b92505060406142c087828801613f5f565b91505092959194509250565b600080604083850312156142e3576142e2613bbc565b5b60006142f185828601613e09565b925050602061430285828601613f5f565b9150509250929050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61434982613cc7565b810181811067ffffffffffffffff8211171561436857614367614311565b5b80604052505050565b600061437b613bb2565b90506143878282614340565b919050565b600067ffffffffffffffff8211156143a7576143a6614311565b5b6143b082613cc7565b9050602081019050919050565b82818337600083830152505050565b60006143df6143da8461438c565b614371565b9050828152602081018484840111156143fb576143fa61430c565b5b6144068482856143bd565b509392505050565b600082601f83011261442357614422613fb4565b5b81356144338482602086016143cc565b91505092915050565b6000806000806080858703121561445657614455613bbc565b5b600061446487828801613e09565b945050602061447587828801613e09565b935050604061448687828801613d54565b925050606085013567ffffffffffffffff8111156144a7576144a6613bc1565b5b6144b38782880161440e565b91505092959194509250565b6144c881613d33565b82525050565b6144d781613c4b565b82525050565b6060820160008201516144f3600085018261412f565b50602082015161450660208501826144bf565b50604082015161451960408501826144ce565b50505050565b600060608201905061453460008301846144dd565b92915050565b6000806040838503121561455157614550613bbc565b5b600061455f85828601613f5f565b925050602061457085828601613f5f565b9150509250929050565b6000806040838503121561459157614590613bbc565b5b600061459f85828601613e09565b92505060206145b085828601613e09565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061460157607f821691505b602082108103614614576146136145ba565b5b50919050565b60008190508160005260206000209050919050565b6000815461463c816145e9565b6146468186613c8c565b945060018216600081146146615760018114614677576146aa565b60ff1983168652811515602002860193506146aa565b6146808561461a565b60005b838110156146a257815481890152600182019150602081019050614683565b808801955050505b50505092915050565b600060208201905081810360008301526146cd818461462f565b905092915050565b600082905092915050565b60006020601f8301049050919050565b600082821b905092915050565b60006008830261472d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826146f0565b61473786836146f0565b95508019841693508086168417925050509392505050565b6000819050919050565b600061477461476f61476a84613d33565b61474f565b613d33565b9050919050565b6000819050919050565b61478e83614759565b6147a261479a8261477b565b8484546146fd565b825550505050565b600090565b6147b76147aa565b6147c2818484614785565b505050565b5b818110156147e6576147db6000826147af565b6001810190506147c8565b5050565b601f82111561482b576147fc8161461a565b614805846146e0565b81016020851015614814578190505b614828614820856146e0565b8301826147c7565b50505b505050565b600082821c905092915050565b600061484e60001984600802614830565b1980831691505092915050565b6000614867838361483d565b9150826002028217905092915050565b61488183836146d5565b67ffffffffffffffff81111561489a57614899614311565b5b6148a482546145e9565b6148af8282856147ea565b6000601f8311600181146148de57600084156148cc578287013590505b6148d6858261485b565b86555061493e565b601f1984166148ec8661461a565b60005b82811015614914578489013582556001820191506020850194506020810190506148ef565b86831015614931578489013561492d601f89168261483d565b8355505b6001600288020188555050505b50505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061498182613d33565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036149b3576149b2614947565b5b600182019050919050565b6000819050919050565b6149d1816149be565b82525050565b60006040820190506149ec60008301856149c8565b6149f96020830184613dc8565b9392505050565b600081905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b6000614a41600283614a00565b9150614a4c82614a0b565b600282019050919050565b6000819050919050565b614a72614a6d826149be565b614a57565b82525050565b6000614a8382614a34565b9150614a8f8285614a61565b602082019150614a9f8284614a61565b6020820191508190509392505050565b7f637573746f6469616e2063616e206f6e6c7920626520736574206279206f776e60008201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b6000614b0b602283613c8c565b9150614b1682614aaf565b604082019050919050565b60006020820190508181036000830152614b3a81614afe565b9050919050565b7f616c6c6f776c697374206e6f7420656e61626c65640000000000000000000000600082015250565b6000614b77601583613c8c565b9150614b8282614b41565b602082019050919050565b60006020820190508181036000830152614ba681614b6a565b9050919050565b7f696e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b6000614be3601183613c8c565b9150614bee82614bad565b602082019050919050565b60006020820190508181036000830152614c1281614bd6565b9050919050565b6000614c2482613d33565b9150614c2f83613d33565b9250828201905080821115614c4757614c46614947565b5b92915050565b6000614c5882613d33565b9150614c6383613d33565b9250828202614c7181613d33565b91508282048414831517614c8857614c87614947565b5b5092915050565b7f63616e6e6f74206772616e7420617070726f76616c20746f2073656c66000000600082015250565b6000614cc5601d83613c8c565b9150614cd082614c8f565b602082019050919050565b60006020820190508181036000830152614cf481614cb8565b9050919050565b7f6e6f6e6578697374656e7420746f6b656e000000000000000000000000000000600082015250565b6000614d31601183613c8c565b9150614d3c82614cfb565b602082019050919050565b60006020820190508181036000830152614d6081614d24565b9050919050565b600067ffffffffffffffff821115614d8257614d81614311565b5b614d8b82613cc7565b9050602081019050919050565b6000614dab614da684614d67565b614371565b905082815260208101848484011115614dc757614dc661430c565b5b614dd2848285613c9d565b509392505050565b600082601f830112614def57614dee613fb4565b5b8151614dff848260208601614d98565b91505092915050565b600060208284031215614e1e57614e1d613bbc565b5b600082015167ffffffffffffffff811115614e3c57614e3b613bc1565b5b614e4884828501614dda565b91505092915050565b6000614e5c82613c81565b614e668185614a00565b9350614e76818560208601613c9d565b80840191505092915050565b6000614e8e8284614e51565b915081905092915050565b7f2f00000000000000000000000000000000000000000000000000000000000000600082015250565b6000614ecf600183614a00565b9150614eda82614e99565b600182019050919050565b6000614ef18285614e51565b9150614efc82614ec2565b9150614f088284614e51565b91508190509392505050565b6000614f1f82613d33565b915060008203614f3257614f31614947565b5b600182039050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614f99602683613c8c565b9150614fa482614f3d565b604082019050919050565b60006020820190508181036000830152614fc881614f8c565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000615005602083613c8c565b915061501082614fcf565b602082019050919050565b6000602082019050818103600083015261503481614ff8565b9050919050565b600061504682613d33565b915061505183613d33565b925082820390508181111561506957615068614947565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061510782613d33565b915061511283613d33565b925082615122576151216150cd565b5b828204905092915050565b600061513882613d33565b915061514383613d33565b925082615153576151526150cd565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b60006151c3601883613c8c565b91506151ce8261518d565b602082019050919050565b600060208201905081810360008301526151f2816151b6565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b600061522f601f83613c8c565b915061523a826151f9565b602082019050919050565b6000602082019050818103600083015261525e81615222565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b60006152c1602283613c8c565b91506152cc82615265565b604082019050919050565b600060208201905081810360008301526152f0816152b4565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b6000615353602283613c8c565b915061535e826152f7565b604082019050919050565b6000602082019050818103600083015261538281615346565b9050919050565b600082825260208201905092915050565b60006153a58261413e565b6153af8185615389565b93506153bf818560208601613c9d565b6153c881613cc7565b840191505092915050565b60006080820190506153e86000830187613dc8565b6153f56020830186613dc8565b6154026040830185613e5e565b8181036060830152615414818461539a565b905095945050505050565b60008151905061542e81613bf2565b92915050565b60006020828403121561544a57615449613bbc565b5b60006154588482850161541f565b91505092915050565b600060ff82169050919050565b61547781615461565b82525050565b600060808201905061549260008301876149c8565b61549f602083018661546e565b6154ac60408301856149c8565b6154b960608301846149c8565b9594505050505056fea26469706673582212204f4ddaf06d38c82858ecad83a905f54a1e284722b0bef649284ed868ddce6ed964736f6c63430008110033

Verified Source Code Full Match

Compiler: v0.8.17+commit.8df45f5f EVM: london Optimization: No
FlexibleMetadata.sol 9 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;

abstract contract FlexibleMetadata {
    function _unrevealedBaseURI() external virtual view returns (string memory);
    function _flaggedBaseURI() external virtual view returns (string memory);
    function _revealedBaseURI() external virtual view returns (string memory);
}
EIP712Allowlisting.sol 44 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "./EIP712Listable.sol";

contract EIP712Allowlisting is EIP712Listable {
    using ECDSA for bytes32;

    bytes32 internal constant MINT_TYPE =
        keccak256("Minter(address wallet)");     

    struct recovered { 
        address receipient;
        bytes signature;
        address recovered;
        address signingKey;
    }

    function recoverAddress(bytes calldata sig, address recip) public view returns (recovered memory) {
        bytes32 digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                DOM_SEP,
                keccak256(abi.encode(MINT_TYPE, recip))
            )
        );        
        address recoveredAddress = digest.recover(sig);
        
        return recovered(recip, sig, recoveredAddress, sigKey);
    }
    modifier requiresSig(bytes calldata sig, address recip) {
        require(sigKey != address(0), "allowlist not enabled");
        bytes32 digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                DOM_SEP,
                keccak256(abi.encode(MINT_TYPE, recip))
            )
        );
        address recovery = digest.recover(sig);
        require(recovery == sigKey, "invalid signature");
        _;
    }
}
IERC721A.sol 282 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

/**
 * @dev Interface of ERC721A.
 */
interface IERC721A {
    /**
     * The caller must own the token or be an approved operator.
     */
    error ApprovalCallerNotOwnerNorApproved();

    /**
     * The token does not exist.
     */
    error ApprovalQueryForNonexistentToken();

    /**
     * Cannot query the balance for the zero address.
     */
    error BalanceQueryForZeroAddress();

    /**
     * Cannot mint to the zero address.
     */
    error MintToZeroAddress();

    /**
     * The quantity of tokens minted must be more than zero.
     */
    error MintZeroQuantity();

    /**
     * The token does not exist.
     */
    error OwnerQueryForNonexistentToken();

    /**
     * The caller must own the token or be an approved operator.
     */
    error TransferCallerNotOwnerNorApproved();

    /**
     * The token must be owned by `from`.
     */
    error TransferFromIncorrectOwner();

    /**
     * Cannot safely transfer to a contract that does not implement the
     * ERC721Receiver interface.
     */
    error TransferToNonERC721ReceiverImplementer();

    /**
     * Cannot transfer to the zero address.
     */
    error TransferToZeroAddress();

    /**
     * The token does not exist.
     */
    error URIQueryForNonexistentToken();

    /**
     * The `quantity` minted with ERC2309 exceeds the safety limit.
     */
    error MintERC2309QuantityExceedsLimit();

    /**
     * The `extraData` cannot be set on an unintialized ownership slot.
     */
    error OwnershipNotInitializedForExtraData();

    // =============================================================
    //                            STRUCTS
    // =============================================================

    struct TokenOwnership {
        // The address of the owner.
        address addr;
        // Stores the start time of ownership with minimal overhead for tokenomics.
        uint64 startTimestamp;
        // Whether the token has been burned.
        bool burned;
        // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
        uint24 extraData;
    }

    // =============================================================
    //                         TOKEN COUNTERS
    // =============================================================

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() external view returns (uint256);

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    // =============================================================
    //                            IERC721
    // =============================================================

    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables
     * (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in `owner`'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`,
     * checking first that contract recipients are aware of the ERC721 protocol
     * to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move
     * this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external payable;

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external payable;

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

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

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom}
     * for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

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

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);

    // =============================================================
    //                           IERC2309
    // =============================================================

    /**
     * @dev Emitted when tokens in `fromTokenId` to `toTokenId`
     * (inclusive) is transferred from `from` to `to`, as defined in the
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
     *
     * See {_mintERC2309} for more details.
     */
    event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}
EIP712Listable.sol 42 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Context.sol";

abstract contract EIP712Listable is Context, Ownable {
    using ECDSA for bytes32;

    address internal sigKey = address(0);

    bytes32 internal DOM_SEP;    

    uint256 chainid = 1;

    function setDomainSeparator(string memory _name, string memory _version) internal {
        DOM_SEP = keccak256(
            abi.encode(
                keccak256(
                    "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
                ),
                keccak256(bytes(_name)),
                keccak256(bytes(_version)),
                chainid,
                address(this)
            )
        );
    }

    function getSigKey() public view returns (address) {
        return sigKey;
    }

    function setSigKey(address _sigKey) public onlyOwner {
        sigKey = _sigKey;
    }

    function isOwner() public view returns (bool) {
        return msg.sender == owner();
    }
  
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
HordeCreaturesA.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "erc721a/contracts/ERC721A.sol";
import "../FlexibleMetadata.sol";
import "../EIP712Allowlisting.sol";
import "./HordeMintableA.sol";


contract HordeCreaturesA is HordeMintableA {  

    string tokenName = "Horde of the Undead: Creatures";
    string version = "1";
    string tokenSymbol = "HORDE2";

    constructor() ERC721A(tokenName, tokenSymbol) {
        setDomainSeparator(tokenName,version);
        setSigKey(0x4f48D073704e884f47595294536A0D6b4Ea383D7);
    }   

    function forceUnlock(uint256 tokenId) external onlyOwner {
        _forceUnlock(tokenId);
    }          
}
HordeMintableA.sol 137 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "../EIP712Allowlisting.sol";
import "../FlexibleMetadata.sol";
import "./LockableA.sol";

abstract contract HordeMintableA is EIP712Allowlisting, LockableA, FlexibleMetadata {  
  
    mapping(address => uint256) private allow_minted;
    mapping(address => uint256) private public_minted;

    address payable private HORDE_AI_WALLET = payable(0xa399Ffb1C1244FA6B583a20c53FF85501Fb91086);

    uint256 private MAX_TOKENS = 400;
    uint256 private MAX_HORDE = 400;
    uint256 private MAX_ALLOW = 3;
    uint256 private MAX_PUBLIC = 2;

    uint256 private PUBLIC_FEE = 0.02 ether;

    bool private HORDE_LIVE = true;
    bool private PUBLIC_LIVE = false;


    string private INVALID_QUANT = "invalid quantity";
    string private INACTIVE_MINT = "mint is not active";
    string private ALLOC_OVER = "mint overallocation";
    string private FEE_UNDER = "insufficient funds";

    mapping(uint256 => bool) private flagged;  

    bool private revealed = false;

    string private flaggedBaseURI="ipfs://QmSUii5oFiBPu94UB3vqS6gDCJhuScAL6d6x9kgGqkh9E9";
    string private unrevealedBaseURI="ipfs://QmSUii5oFiBPu94UB3vqS6gDCJhuScAL6d6x9kgGqkh9E9"; 
    string private revealedBaseURI="ipfs://Qmbw9vH1a9Vadc58Zu5sfNRXUHzAgG1ToMVwkTCFboEbuP";      


    function setLive(bool isLive, bool isPublic) external onlyOwner {        
        if (isPublic) {
            PUBLIC_LIVE = isLive;
        } else {
            HORDE_LIVE = isLive;
        }        
    }

    function setRecipient(address recip) external onlyOwner {        
        HORDE_AI_WALLET = payable(recip);    
    }  

    function setURI(string calldata uri, uint256 uriType) external onlyOwner {    
        if (uriType == 0) { revealedBaseURI = uri; }
        if (uriType == 1) { unrevealedBaseURI = uri; }
        if (uriType == 2) { flaggedBaseURI = uri; }
    }     

    function mint(
        bytes calldata sig, 
        uint256 quant,
        bool isPublic) external payable requiresSig(sig, msg.sender) {  
        uint256 askSize = totalSupply()+quant;
        bool publicMint = PUBLIC_LIVE ? PUBLIC_LIVE : isPublic;
        require(quant <= (publicMint ? MAX_PUBLIC : MAX_ALLOW), INVALID_QUANT);     
        require(publicMint ? PUBLIC_LIVE : HORDE_LIVE, INACTIVE_MINT); 
        require(askSize <= (publicMint ? MAX_TOKENS : MAX_HORDE), ALLOC_OVER);
        require(
            (publicMint ? public_minted[msg.sender] : allow_minted[msg.sender])+quant 
            <= (publicMint ? MAX_PUBLIC : MAX_ALLOW), ALLOC_OVER);
        
        if (publicMint) {
            require(msg.value >= (PUBLIC_FEE * quant), FEE_UNDER);
            public_minted[msg.sender] = public_minted[msg.sender] + quant;
            HORDE_AI_WALLET.transfer(msg.value);
        } else {
            allow_minted[msg.sender] = allow_minted[msg.sender] + quant;
        }

        _safeMint(msg.sender,quant);
        
    }  

   // Reveal unrevealed tokens
    function reveal() public onlyOwner {                 
        revealed = true;
    }

    function setFlag(uint256 tokenId, bool flag) public onlyOwner {                 
        flagged[tokenId] = flag;
    }    

    // Determine if token is flagged
    function isFlagged(uint256 tokenId)
        public
        view
        returns (bool)
    {     
        return flagged[tokenId];
    }

    // Determine if tokens are revealed
    function isRevealed()
        public
        view
        returns (bool)
    {     
        return revealed;
    }   

    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "nonexistent token");
        
        string memory baseURI = isFlagged(tokenId) ?
                this._flaggedBaseURI() :
                isRevealed() ?
                    this._revealedBaseURI():
                    this._unrevealedBaseURI();
        
        string memory uri = (isRevealed() && !isFlagged(tokenId)) ?
            string(abi.encodePacked(baseURI, "/", Strings.toString(tokenId))):
            string(abi.encodePacked(baseURI));
        return uri;
    }      

    function _unrevealedBaseURI() external virtual override view returns (string memory){
        return unrevealedBaseURI;
    }
    function _flaggedBaseURI() external virtual override view returns (string memory){
        return flaggedBaseURI;
    }
    function _revealedBaseURI() external virtual override view returns (string memory){
        return revealedBaseURI;
    }      

}
ECDSA.sol 218 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}
Strings.sol 75 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
LockableA.sol 157 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

uint64 constant MAX_INT = 2**64 - 1;

abstract contract LockableA is ERC721A {
    mapping(uint256 => LTS) private _lt;
    mapping(address => Cust) private _cust;
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    string private LOCKED_BY_OWNER = "token is locked by owner";
    string private ONLY_CUSTODIAN = "lock can only be set by custodian";

    mapping(address => address[]) private _appAll;

    struct LTS {
        bool isLocked;
        uint256 lockedAt;
    }
    
    struct Cust {
        address custodian;
        uint256 lockedBalance;
        bool isAssigned;
    }

    function custodianOf(uint256 id)
        public
        view
        returns (Cust memory)
    {     
        address owner = ownerOf(id);
        return _cust[owner];
    }     

    function revokeApprovals(address holder) private {
    
        uint256 approvals = _appAll[holder].length;
        uint256 removals = 0;
        while (approvals > 0) {     
            address approved = _appAll[holder][approvals-1];  
            _operatorApprovals[holder][approved] = false;      
            emit ApprovalForAll(_msgSenderERC721A(), approved, false);      
            _appAll[holder].pop();         
            approvals--;   
            removals++;           
        }
    }

    function lockToken(uint256 id) public {        
        require(msg.sender == custodianOf(id).custodian, ONLY_CUSTODIAN);    
        address owner = ownerOf(id);
        revokeApprovals(owner);        
        _lt[id].isLocked = true;
        _lt[id].lockedAt = block.timestamp;
        _cust[owner].lockedBalance++;      
    }

    function unlockToken(uint256 id) public {        
        require(msg.sender == custodianOf(id).custodian, ONLY_CUSTODIAN);    
        address owner = ownerOf(id);
        _lt[id].isLocked = false;
        _lt[id].lockedAt = MAX_INT;
        _cust[owner].lockedBalance--;
    }    

    function _forceUnlock(uint256 id) internal virtual {  
        address owner = ownerOf(id);
        _lt[id].isLocked = false;
        _lt[id].lockedAt = MAX_INT;
        _cust[owner].lockedBalance--;
    }    
    function setCustodian(uint256 id, address custodianAddress) public {
        address owner = ownerOf(id);
        require(msg.sender == ownerOf(id), "custodian can only be set by owner");
        uint256 _lockedBalance = 0;
        if (_cust[owner].isAssigned) {
            for( uint256 i; i < totalSupply(); ++i ){
                if(_exists(i)){
                    if( _lt[i].isLocked){
                        _lockedBalance++;
                    }
                }
            }
        }
        Cust memory custodian = Cust(custodianAddress, _lockedBalance, true);
        _cust[owner] = custodian;
    }

    function isLocked(uint256 id)
        public
        view
        returns (bool)
    {     
        return _lt[id].isLocked;
    } 

    function lockedSince(uint256 id, uint256 since)
        public
        view
        returns (bool)
    {     
        return _lt[id].lockedAt <= since;
    }     

    function lockedBalance(address owner)
        public
        view
        returns (uint256)
    {     
        return _cust[owner].lockedBalance;
    } 

    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }    
            
    function approve(address app, uint256 id) public virtual override payable {
        require(isLocked(id) != true, LOCKED_BY_OWNER);
        super.approve(app, id);
    }  

    function setApprovalForAll(address _op, bool _app) public virtual override {
        require(lockedBalance(_msgSenderERC721A()) < 1, LOCKED_BY_OWNER);
        require(_op != _msgSenderERC721A(), "cannot grant approval to self");
        
        _operatorApprovals[_msgSenderERC721A()][_op] = _app;
        emit ApprovalForAll(_msgSenderERC721A(), _op, _app);

        if (_app) {
            _appAll[msg.sender].push(_op);
        }
        super.setApprovalForAll(_op, _app);
    }   

    function transferFrom(
        address f,
        address t,
        uint256 id
    ) public virtual override payable {
        require(isLocked(id) != true, LOCKED_BY_OWNER);
        super.transferFrom(f, t, id);
    }

    function safeTransferFrom(
        address f,
        address t,
        uint256 id,
        bytes memory data
    ) public virtual override payable {        
        require(isLocked(id) != true, LOCKED_BY_OWNER);
        super.safeTransferFrom(f, t, id, data);
    }          
}
ERC721A.sol 1091 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import './IERC721A.sol';

/**
 * @dev Interface of ERC721 token receiver.
 */
interface ERC721A__IERC721Receiver {
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

/**
 * @title ERC721A
 *
 * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
 * Non-Fungible Token Standard, including the Metadata extension.
 * Optimized for lower gas during batch mints.
 *
 * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
 * starting from `_startTokenId()`.
 *
 * Assumptions:
 *
 * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
 * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
 */
contract ERC721A is IERC721A {
    // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).
    struct TokenApprovalRef {
        address value;
    }

    // =============================================================
    //                           CONSTANTS
    // =============================================================

    // Mask of an entry in packed address data.
    uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;

    // The bit position of `numberMinted` in packed address data.
    uint256 private constant _BITPOS_NUMBER_MINTED = 64;

    // The bit position of `numberBurned` in packed address data.
    uint256 private constant _BITPOS_NUMBER_BURNED = 128;

    // The bit position of `aux` in packed address data.
    uint256 private constant _BITPOS_AUX = 192;

    // Mask of all 256 bits in packed address data except the 64 bits for `aux`.
    uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;

    // The bit position of `startTimestamp` in packed ownership.
    uint256 private constant _BITPOS_START_TIMESTAMP = 160;

    // The bit mask of the `burned` bit in packed ownership.
    uint256 private constant _BITMASK_BURNED = 1 << 224;

    // The bit position of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;

    // The bit mask of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;

    // The bit position of `extraData` in packed ownership.
    uint256 private constant _BITPOS_EXTRA_DATA = 232;

    // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
    uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;

    // The mask of the lower 160 bits for addresses.
    uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;

    // The maximum `quantity` that can be minted with {_mintERC2309}.
    // This limit is to prevent overflows on the address data entries.
    // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
    // is required to cause an overflow, which is unrealistic.
    uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;

    // The `Transfer` event signature is given by:
    // `keccak256(bytes("Transfer(address,address,uint256)"))`.
    bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
        0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    // =============================================================
    //                            STORAGE
    // =============================================================

    // The next token ID to be minted.
    uint256 private _currentIndex;

    // The number of tokens burned.
    uint256 private _burnCounter;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to ownership details
    // An empty struct value does not necessarily mean the token is unowned.
    // See {_packedOwnershipOf} implementation for details.
    //
    // Bits Layout:
    // - [0..159]   `addr`
    // - [160..223] `startTimestamp`
    // - [224]      `burned`
    // - [225]      `nextInitialized`
    // - [232..255] `extraData`
    mapping(uint256 => uint256) private _packedOwnerships;

    // Mapping owner address to address data.
    //
    // Bits Layout:
    // - [0..63]    `balance`
    // - [64..127]  `numberMinted`
    // - [128..191] `numberBurned`
    // - [192..255] `aux`
    mapping(address => uint256) private _packedAddressData;

    // Mapping from token ID to approved address.
    mapping(uint256 => TokenApprovalRef) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // =============================================================
    //                          CONSTRUCTOR
    // =============================================================

    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
        _currentIndex = _startTokenId();
    }

    // =============================================================
    //                   TOKEN COUNTING OPERATIONS
    // =============================================================

    /**
     * @dev Returns the starting token ID.
     * To change the starting token ID, please override this function.
     */
    function _startTokenId() internal view virtual returns (uint256) {
        return 0;
    }

    /**
     * @dev Returns the next token ID to be minted.
     */
    function _nextTokenId() internal view virtual returns (uint256) {
        return _currentIndex;
    }

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        // Counter underflow is impossible as _burnCounter cannot be incremented
        // more than `_currentIndex - _startTokenId()` times.
        unchecked {
            return _currentIndex - _burnCounter - _startTokenId();
        }
    }

    /**
     * @dev Returns the total amount of tokens minted in the contract.
     */
    function _totalMinted() internal view virtual returns (uint256) {
        // Counter underflow is impossible as `_currentIndex` does not decrement,
        // and it is initialized to `_startTokenId()`.
        unchecked {
            return _currentIndex - _startTokenId();
        }
    }

    /**
     * @dev Returns the total number of tokens burned.
     */
    function _totalBurned() internal view virtual returns (uint256) {
        return _burnCounter;
    }

    // =============================================================
    //                    ADDRESS DATA OPERATIONS
    // =============================================================

    /**
     * @dev Returns the number of tokens in `owner`'s account.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        if (owner == address(0)) revert BalanceQueryForZeroAddress();
        return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens minted by `owner`.
     */
    function _numberMinted(address owner) internal view returns (uint256) {
        return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens burned by or on behalf of `owner`.
     */
    function _numberBurned(address owner) internal view returns (uint256) {
        return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     */
    function _getAux(address owner) internal view returns (uint64) {
        return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
    }

    /**
     * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     * If there are multiple variables, please pack them into a uint64.
     */
    function _setAux(address owner, uint64 aux) internal virtual {
        uint256 packed = _packedAddressData[owner];
        uint256 auxCasted;
        // Cast `aux` with assembly to avoid redundant masking.
        assembly {
            auxCasted := aux
        }
        packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
        _packedAddressData[owner] = packed;
    }

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        // The interface IDs are constants representing the first 4 bytes
        // of the XOR of all function selectors in the interface.
        // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
        // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
        return
            interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
            interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
            interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
    }

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

    /**
     * @dev Returns the token collection name.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        if (!_exists(tokenId)) revert URIQueryForNonexistentToken();

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

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

    // =============================================================
    //                     OWNERSHIPS OPERATIONS
    // =============================================================

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        return address(uint160(_packedOwnershipOf(tokenId)));
    }

    /**
     * @dev Gas spent here starts off proportional to the maximum mint batch size.
     * It gradually moves to O(1) as tokens get transferred around over time.
     */
    function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnershipOf(tokenId));
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct at `index`.
     */
    function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnerships[index]);
    }

    /**
     * @dev Initializes the ownership slot minted at `index` for efficiency purposes.
     */
    function _initializeOwnershipAt(uint256 index) internal virtual {
        if (_packedOwnerships[index] == 0) {
            _packedOwnerships[index] = _packedOwnershipOf(index);
        }
    }

    /**
     * Returns the packed ownership data of `tokenId`.
     */
    function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
        uint256 curr = tokenId;

        unchecked {
            if (_startTokenId() <= curr)
                if (curr < _currentIndex) {
                    uint256 packed = _packedOwnerships[curr];
                    // If not burned.
                    if (packed & _BITMASK_BURNED == 0) {
                        // Invariant:
                        // There will always be an initialized ownership slot
                        // (i.e. `ownership.addr != address(0) && ownership.burned == false`)
                        // before an unintialized ownership slot
                        // (i.e. `ownership.addr == address(0) && ownership.burned == false`)
                        // Hence, `curr` will not underflow.
                        //
                        // We can directly compare the packed value.
                        // If the address is zero, packed will be zero.
                        while (packed == 0) {
                            packed = _packedOwnerships[--curr];
                        }
                        return packed;
                    }
                }
        }
        revert OwnerQueryForNonexistentToken();
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct from `packed`.
     */
    function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
        ownership.addr = address(uint160(packed));
        ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
        ownership.burned = packed & _BITMASK_BURNED != 0;
        ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
    }

    /**
     * @dev Packs ownership data into a single uint256.
     */
    function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
            result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
        }
    }

    /**
     * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
     */
    function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
        // For branchless setting of the `nextInitialized` flag.
        assembly {
            // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
            result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
        }
    }

    // =============================================================
    //                      APPROVAL OPERATIONS
    // =============================================================

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

        if (_msgSenderERC721A() != owner)
            if (!isApprovedForAll(owner, _msgSenderERC721A())) {
                revert ApprovalCallerNotOwnerNorApproved();
            }

        _tokenApprovals[tokenId].value = to;
        emit Approval(owner, to, tokenId);
    }

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();

        return _tokenApprovals[tokenId].value;
    }

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom}
     * for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _operatorApprovals[_msgSenderERC721A()][operator] = approved;
        emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
    }

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted. See {_mint}.
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return
            _startTokenId() <= tokenId &&
            tokenId < _currentIndex && // If within bounds,
            _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
    }

    /**
     * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
     */
    function _isSenderApprovedOrOwner(
        address approvedAddress,
        address owner,
        address msgSender
    ) private pure returns (bool result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
            msgSender := and(msgSender, _BITMASK_ADDRESS)
            // `msgSender == owner || msgSender == approvedAddress`.
            result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
        }
    }

    /**
     * @dev Returns the storage slot and value for the approved address of `tokenId`.
     */
    function _getApprovedSlotAndAddress(uint256 tokenId)
        private
        view
        returns (uint256 approvedAddressSlot, address approvedAddress)
    {
        TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
        // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.
        assembly {
            approvedAddressSlot := tokenApproval.slot
            approvedAddress := sload(approvedAddressSlot)
        }
    }

    // =============================================================
    //                      TRANSFER OPERATIONS
    // =============================================================

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token
     * by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public payable virtual override {
        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

        if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        // The nested ifs save around 20+ gas over a compound boolean condition.
        if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
            if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();

        if (to == address(0)) revert TransferToZeroAddress();

        _beforeTokenTransfers(from, to, tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // We can directly increment and decrement the balances.
            --_packedAddressData[from]; // Updates: `balance -= 1`.
            ++_packedAddressData[to]; // Updates: `balance += 1`.

            // Updates:
            // - `address` to the next owner.
            // - `startTimestamp` to the timestamp of transfering.
            // - `burned` to `false`.
            // - `nextInitialized` to `true`.
            _packedOwnerships[tokenId] = _packOwnershipData(
                to,
                _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (_packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != _currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        _packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

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

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public payable virtual override {
        safeTransferFrom(from, to, tokenId, '');
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token
     * by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public payable virtual override {
        transferFrom(from, to, tokenId);
        if (to.code.length != 0)
            if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
                revert TransferToNonERC721ReceiverImplementer();
            }
    }

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

    /**
     * @dev Hook that is called after a set of serially-ordered token IDs
     * have been transferred. This includes minting.
     * And also called after one token has been burned.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
     * transferred to `to`.
     * - When `from` is zero, `tokenId` has been minted for `to`.
     * - When `to` is zero, `tokenId` has been burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _afterTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
     *
     * `from` - Previous owner of the given token ID.
     * `to` - Target address that will receive the token.
     * `tokenId` - Token ID to be transferred.
     * `_data` - Optional data to send along with the call.
     *
     * Returns whether the call correctly returned the expected magic value.
     */
    function _checkContractOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
            bytes4 retval
        ) {
            return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
        } catch (bytes memory reason) {
            if (reason.length == 0) {
                revert TransferToNonERC721ReceiverImplementer();
            } else {
                assembly {
                    revert(add(32, reason), mload(reason))
                }
            }
        }
    }

    // =============================================================
    //                        MINT OPERATIONS
    // =============================================================

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _mint(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = _currentIndex;
        if (quantity == 0) revert MintZeroQuantity();

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

        // Overflows are incredibly unrealistic.
        // `balance` and `numberMinted` have a maximum limit of 2**64.
        // `tokenId` has a maximum limit of 2**256.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            _packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            uint256 toMasked;
            uint256 end = startTokenId + quantity;

            // Use assembly to loop and emit the `Transfer` event for gas savings.
            // The duplicated `log4` removes an extra check and reduces stack juggling.
            // The assembly, together with the surrounding Solidity code, have been
            // delicately arranged to nudge the compiler into producing optimized opcodes.
            assembly {
                // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
                toMasked := and(to, _BITMASK_ADDRESS)
                // Emit the `Transfer` event.
                log4(
                    0, // Start of data (0, since no data).
                    0, // End of data (0, since no data).
                    _TRANSFER_EVENT_SIGNATURE, // Signature.
                    0, // `address(0)`.
                    toMasked, // `to`.
                    startTokenId // `tokenId`.
                )

                // The `iszero(eq(,))` check ensures that large values of `quantity`
                // that overflows uint256 will make the loop run out of gas.
                // The compiler will optimize the `iszero` away for performance.
                for {
                    let tokenId := add(startTokenId, 1)
                } iszero(eq(tokenId, end)) {
                    tokenId := add(tokenId, 1)
                } {
                    // Emit the `Transfer` event. Similar to above.
                    log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
                }
            }
            if (toMasked == 0) revert MintToZeroAddress();

            _currentIndex = end;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * This function is intended for efficient minting only during contract creation.
     *
     * It emits only one {ConsecutiveTransfer} as defined in
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
     * instead of a sequence of {Transfer} event(s).
     *
     * Calling this function outside of contract creation WILL make your contract
     * non-compliant with the ERC721 standard.
     * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
     * {ConsecutiveTransfer} event is only permissible during contract creation.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {ConsecutiveTransfer} event.
     */
    function _mintERC2309(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = _currentIndex;
        if (to == address(0)) revert MintToZeroAddress();
        if (quantity == 0) revert MintZeroQuantity();
        if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();

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

        // Overflows are unrealistic due to the above check for `quantity` to be below the limit.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            _packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);

            _currentIndex = startTokenId + quantity;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Safely mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
     * - `quantity` must be greater than 0.
     *
     * See {_mint}.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory _data
    ) internal virtual {
        _mint(to, quantity);

        unchecked {
            if (to.code.length != 0) {
                uint256 end = _currentIndex;
                uint256 index = end - quantity;
                do {
                    if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
                        revert TransferToNonERC721ReceiverImplementer();
                    }
                } while (index < end);
                // Reentrancy protection.
                if (_currentIndex != end) revert();
            }
        }
    }

    /**
     * @dev Equivalent to `_safeMint(to, quantity, '')`.
     */
    function _safeMint(address to, uint256 quantity) internal virtual {
        _safeMint(to, quantity, '');
    }

    // =============================================================
    //                        BURN OPERATIONS
    // =============================================================

    /**
     * @dev Equivalent to `_burn(tokenId, false)`.
     */
    function _burn(uint256 tokenId) internal virtual {
        _burn(tokenId, false);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

        address from = address(uint160(prevOwnershipPacked));

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        if (approvalCheck) {
            // The nested ifs save around 20+ gas over a compound boolean condition.
            if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
                if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
        }

        _beforeTokenTransfers(from, address(0), tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // Updates:
            // - `balance -= 1`.
            // - `numberBurned += 1`.
            //
            // We can directly decrement the balance, and increment the number burned.
            // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
            _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;

            // Updates:
            // - `address` to the last owner.
            // - `startTimestamp` to the timestamp of burning.
            // - `burned` to `true`.
            // - `nextInitialized` to `true`.
            _packedOwnerships[tokenId] = _packOwnershipData(
                from,
                (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (_packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != _currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        _packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        emit Transfer(from, address(0), tokenId);
        _afterTokenTransfers(from, address(0), tokenId, 1);

        // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
        unchecked {
            _burnCounter++;
        }
    }

    // =============================================================
    //                     EXTRA DATA OPERATIONS
    // =============================================================

    /**
     * @dev Directly sets the extra data for the ownership data `index`.
     */
    function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
        uint256 packed = _packedOwnerships[index];
        if (packed == 0) revert OwnershipNotInitializedForExtraData();
        uint256 extraDataCasted;
        // Cast `extraData` with assembly to avoid redundant masking.
        assembly {
            extraDataCasted := extraData
        }
        packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
        _packedOwnerships[index] = packed;
    }

    /**
     * @dev Called during each token transfer to set the 24bit `extraData` field.
     * Intended to be overridden by the cosumer contract.
     *
     * `previousExtraData` - the value of `extraData` before transfer.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _extraData(
        address from,
        address to,
        uint24 previousExtraData
    ) internal view virtual returns (uint24) {}

    /**
     * @dev Returns the next extra data for the packed ownership data.
     * The returned result is shifted into position.
     */
    function _nextExtraData(
        address from,
        address to,
        uint256 prevOwnershipPacked
    ) private view returns (uint256) {
        uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
        return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
    }

    // =============================================================
    //                       OTHER OPERATIONS
    // =============================================================

    /**
     * @dev Returns the message sender (defaults to `msg.sender`).
     *
     * If you are writing GSN compatible contracts, you need to override this function.
     */
    function _msgSenderERC721A() internal view virtual returns (address) {
        return msg.sender;
    }

    /**
     * @dev Converts a uint256 to its ASCII string decimal representation.
     */
    function _toString(uint256 value) internal pure virtual returns (string memory str) {
        assembly {
            // The maximum value of a uint256 contains 78 digits (1 byte per digit), but
            // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
            // We will need 1 word for the trailing zeros padding, 1 word for the length,
            // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
            let m := add(mload(0x40), 0xa0)
            // Update the free memory pointer to allocate.
            mstore(0x40, m)
            // Assign the `str` to the end.
            str := sub(m, 0x20)
            // Zeroize the slot after the string.
            mstore(str, 0)

            // Cache the end of the memory to calculate the length later.
            let end := str

            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            // prettier-ignore
            for { let temp := value } 1 {} {
                str := sub(str, 1)
                // Write the character to the pointer.
                // The ASCII index of the '0' character is 48.
                mstore8(str, add(48, mod(temp, 10)))
                // Keep dividing `temp` until zero.
                temp := div(temp, 10)
                // prettier-ignore
                if iszero(temp) { break }
            }

            let length := sub(end, str)
            // Move the pointer 32 bytes leftwards to make room for the length.
            str := sub(str, 0x20)
            // Store the length.
            mstore(str, length)
        }
    }
}

Read Contract

_flaggedBaseURI 0xad413e33 → string
_revealedBaseURI 0xec057f61 → string
_unrevealedBaseURI 0x2c019211 → string
balanceOf 0x70a08231 → uint256
custodianOf 0xde3efc91 → tuple
getApproved 0x081812fc → address
getSigKey 0x92063249 → address
isApprovedForAll 0xe985e9c5 → bool
isFlagged 0xb70f402d → bool
isLocked 0xf6aacfb1 → bool
isOwner 0x8f32d59b → bool
isRevealed 0x54214f69 → bool
lockedBalance 0x9ae697bf → uint256
lockedSince 0x33b945d2 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
recoverAddress 0x89d3caea → tuple
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256

Write Contract 18 functions

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

approve 0x095ea7b3
address app
uint256 id
forceUnlock 0xbf968a1b
uint256 tokenId
lockToken 0x80f20363
uint256 id
mint 0x9eb56afc
bytes sig
uint256 quant
bool isPublic
renounceOwnership 0x715018a6
No parameters
reveal 0xa475b5dd
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address f
address t
uint256 id
bytes data
setApprovalForAll 0xa22cb465
address _op
bool _app
setCustodian 0x911c9874
uint256 id
address custodianAddress
setFlag 0x4d87816d
uint256 tokenId
bool flag
setLive 0xe0a8309f
bool isLive
bool isPublic
setRecipient 0x3bbed4a0
address recip
setSigKey 0x96c501d0
address _sigKey
setURI 0x67db3b8f
string uri
uint256 uriType
transferFrom 0x23b872dd
address f
address t
uint256 id
transferOwnership 0xf2fde38b
address newOwner
unlockToken 0xdd2e0ac0
uint256 id

Recent Transactions

No transactions found for this address