Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x4C69dBc3a2Aa3476c3F7a1227ab70950DB1F4858
Balance 0.005000 ETH
Nonce 1
Code Size 15938 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

15938 bytes
0x6080604052600436106103bc5760003560e01c806381b02fd8116101f2578063c87b56dd1161010d578063e985e9c5116100a0578063f3d0e07a1161006f578063f3d0e07a14610b0a578063f53d667214610b3a578063fc47df1414610b5c578063feea632914610b7c57600080fd5b8063e985e9c514610a6c578063ec13b17f14610ab5578063f03f8b3c14610aca578063f2fde38b14610aea57600080fd5b8063dc5c03d3116100dc578063dc5c03d3146109f3578063dce53a0114610a09578063dd88b16214610a29578063e8f9eec814610a5657600080fd5b8063c87b56dd14610973578063c8c584e414610993578063d547cfb7146109cb578063d78d2f2e146109e057600080fd5b8063a01947cb11610185578063a9fea20411610154578063a9fea20414610902578063b472070f14610922578063b88d4fde1461093d578063bd42b89f1461095057600080fd5b8063a01947cb14610882578063a06afc81146108a2578063a22cb465146108c2578063a89f8bdb146108e257600080fd5b806394d008ef116101c157806394d008ef1461081457806395d89b41146108275780639c8857061461083c5780639fb90e7c1461085257600080fd5b806381b02fd81461076e57806385107367146107a95780638da5cb5b146107c95780638e2844ab146107e757600080fd5b80633a16a738116102e25780636e50acd41161027557806375b4d78c1161024457806375b4d78c146106d557806378b004a2146107185780637be14e9f1461072e57806380ceba1e1461074e57600080fd5b80636e50acd41461067357806370a082311461068b578063715018a6146106ab57806374f6b2c5146106c057600080fd5b80634c97f707116102b15780634c97f707146106125780635344b044146106285780635c4121011461063d5780636352211e1461065357600080fd5b80633a16a738146105aa5780633ccfd60b146105ca57806342842e0e146105df578063484b973c146105f257600080fd5b806318160ddd1161035a57806323b872dd1161032957806323b872dd1461054657806330176e131461055957806331c3c7a01461057957806332cb6b0c1461059457600080fd5b806318160ddd146104c35780631ba97836146104d857806321e67bb21461051057806323471d181461052657600080fd5b806306fdde031161039657806306fdde031461044a578063081812fc1461046c578063095ea7b31461048c57806309a2dd861461049f57600080fd5b80630193ae85146103c857806301ffc9a7146103dd578063055622921461041257600080fd5b366103c357005b600080fd5b6103db6103d63660046135e0565b610bad565b005b3480156103e957600080fd5b506103fd6103f83660046137fe565b610e4b565b60405190151581526020015b60405180910390f35b34801561041e57600080fd5b50601654610432906001600160a01b031681565b6040516001600160a01b039091168152602001610409565b34801561045657600080fd5b5061045f610e9d565b6040516104099190613b82565b34801561047857600080fd5b5061043261048736600461394a565b610f2f565b6103db61049a366004613696565b610f73565b3480156104ab57600080fd5b506104b5600d5481565b604051908152602001610409565b3480156104cf57600080fd5b506104b5610fea565b3480156104e457600080fd5b506103fd6104f3366004613469565b6001600160a01b03166000908152601d6020526040902054151590565b34801561051c57600080fd5b506104b5600b5481565b34801561053257600080fd5b506103db610541366004613469565b610ff8565b6103db6105543660046134dc565b611022565b34801561056557600080fd5b506103db610574366004613838565b6111b0565b34801561058557600080fd5b506104b5667c58508723800081565b3480156105a057600080fd5b506104b561271081565b3480156105b657600080fd5b506103db6105c536600461394a565b6111c9565b3480156105d657600080fd5b506103db6111d6565b6103db6105ed3660046134dc565b611272565b3480156105fe57600080fd5b506103db61060d366004613696565b61128d565b34801561061e57600080fd5b506104b5600a5481565b34801561063457600080fd5b506103db6112d3565b34801561064957600080fd5b506104b560105481565b34801561065f57600080fd5b5061043261066e36600461394a565b611302565b34801561067f57600080fd5b5060125460ff166103fd565b34801561069757600080fd5b506104b56106a6366004613469565b61130d565b3480156106b757600080fd5b506103db61135b565b3480156106cc57600080fd5b506103db61136f565b3480156106e157600080fd5b50601e54601f546020546021546106f89392919084565b604080519485526020850193909352918301526060820152608001610409565b34801561072457600080fd5b506104b5600c5481565b34801561073a57600080fd5b50601554610432906001600160a01b031681565b34801561075a57600080fd5b506103db610769366004613668565b6114b3565b34801561077a57600080fd5b506103fd6107893660046139ad565b601960209081526000928352604080842090915290825290205460ff1681565b3480156107b557600080fd5b50601454610432906001600160a01b031681565b3480156107d557600080fd5b506008546001600160a01b0316610432565b3480156107f357600080fd5b5061080761080236600461386d565b6114e6565b6040516104099190613b4a565b6103db6108223660046136c2565b61179b565b34801561083357600080fd5b5061045f611976565b34801561084857600080fd5b506104b5600f5481565b34801561085e57600080fd5b506103fd61086d366004613469565b601b6020526000908152604090205460ff1681565b34801561088e57600080fd5b506103db61089d36600461394a565b611985565b3480156108ae57600080fd5b506103db6108bd366004613469565b611992565b3480156108ce57600080fd5b506103db6108dd366004613668565b6119bc565b3480156108ee57600080fd5b506103db6108fd36600461371d565b611a2f565b34801561090e57600080fd5b506103db61091d36600461375e565b611b9e565b34801561092e57600080fd5b506104b566b1a2bc2ec5000081565b6103db61094b36600461351d565b61219f565b34801561095c57600080fd5b506022546023546024546025546106f89392919084565b34801561097f57600080fd5b5061045f61098e36600461394a565b6121e3565b34801561099f57600080fd5b506104b56109ae366004613696565b601a60209081526000928352604080842090915290825290205481565b3480156109d757600080fd5b5061045f6122af565b6103db6109ee366004613963565b61233d565b3480156109ff57600080fd5b506104b5600e5481565b348015610a1557600080fd5b506103db610a2436600461394a565b6126fd565b348015610a3557600080fd5b506104b5610a44366004613469565b60176020526000908152604090205481565b348015610a6257600080fd5b506104b560135481565b348015610a7857600080fd5b506103fd610a873660046134a3565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610ac157600080fd5b50601c546104b5565b348015610ad657600080fd5b506103db610ae536600461371d565b61270a565b348015610af657600080fd5b506103db610b05366004613469565b6128b2565b348015610b1657600080fd5b506103fd610b2536600461394a565b60009081526018602052604090205460ff1690565b348015610b4657600080fd5b50610b4f612928565b6040516104099190613afd565b348015610b6857600080fd5b506103db610b77366004613469565b61298c565b348015610b8857600080fd5b506103fd610b9736600461394a565b60009081526018602052604090205460ff161590565b61271084610bb9610fea565b610bc39190613c40565b1115610bea5760405162461bcd60e51b8152600401610be190613bed565b60405180910390fd5b610bfb667c58508723800085613c6c565b341015610c1a5760405162461bcd60e51b8152600401610be190613bbd565b601554604080516020601f85018190048102820181019092528381526001600160a01b0390921691610c9a91859085908190840183828082843760009201919091525050604051610c949250610c7991508b908a908a90602001613a05565b604051602081830303815290604052805190602001206129b6565b90612a09565b6001600160a01b031614610cf05760405162461bcd60e51b815260206004820152601b60248201527f596f75277265206e6f74206f6e207468652077686974656c69737400000000006044820152606401610be1565b6000836003811115610d0457610d04613d7b565b1415610d5457600a546001600160a01b038716600090815260176020526040902054610d31908690613c40565b1115610d4f5760405162461bcd60e51b8152600401610be190613b95565b610e1b565b6001836003811115610d6857610d68613d7b565b1415610d9557600b546001600160a01b038716600090815260176020526040902054610d31908690613c40565b6002836003811115610da957610da9613d7b565b1415610dd657600c546001600160a01b038716600090815260176020526040902054610d31908690613c40565b600c546001600160a01b038716600090815260176020526040902054610dfd908690613c40565b1115610e1b5760405162461bcd60e51b8152600401610be190613b95565b6001600160a01b0386166000908152601760205260409020805485019055610e438585612a2d565b505050505050565b60006301ffc9a760e01b6001600160e01b031983161480610e7c57506380ac58cd60e01b6001600160e01b03198316145b80610e975750635b5e139f60e01b6001600160e01b03198316145b92915050565b606060028054610eac90613ce5565b80601f0160208091040260200160405190810160405280929190818152602001828054610ed890613ce5565b8015610f255780601f10610efa57610100808354040283529160200191610f25565b820191906000526020600020905b815481529060010190602001808311610f0857829003601f168201915b5050505050905090565b6000610f3a82612b24565b610f57576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b6001600160a01b0382166000908152601b602052604090205460ff1615610fdc5760405162461bcd60e51b815260206004820152601b60248201527f5468652061646472657373206973206e6f7420617070726f76656400000000006044820152606401610be1565b610fe68282612b59565b5050565b600154600054036000190190565b611000612bf9565b601480546001600160a01b0319166001600160a01b0392909216919091179055565b600061102d82612c53565b9050836001600160a01b0316816001600160a01b0316146110605760405162a1148160e81b815260040160405180910390fd5b60008281526006602052604090208054338082146001600160a01b038816909114176110ad576110908633610a87565b6110ad57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0385166110d457604051633a954ecd60e21b815260040160405180910390fd5b80156110df57600082555b6001600160a01b038681166000908152600560205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260046020526040902055600160e11b831661116a57600184016000818152600460205260409020546111685760005481146111685760008181526004602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4610e43565b6111b8612bf9565b6111c460118383613335565b505050565b6111d1612bf9565b601055565b6111de612bf9565b60225460405160009133918381818185875af1925050503d8060008114611221576040519150601f19603f3d011682016040523d82523d6000602084013e611226565b606091505b5050600060225590508061126f5760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b6044820152606401610be1565b50565b6111c48383836040518060200160405280600081525061219f565b611295612bf9565b612710816112a1610fea565b6112ab9190613c40565b11156112c95760405162461bcd60e51b8152600401610be190613bed565b610fe68282612a2d565b6112db612bf9565b6024546023546112eb9190613c40565b602381905560006024819055601f91909155602055565b6000610e9782612c53565b60006001600160a01b038216611336576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b611363612bf9565b61136d6000612cbc565b565b611377612bf9565b604051806080016040528060644760146113919190613c6c565b61139b9190613c58565b815260200160646113ad476023613c6c565b6113b79190613c58565b815260200160646113c9476023613c6c565b6113d39190613c58565b815260200160646113e547600a613c6c565b6113ef9190613c58565b90528051601e55602080820151601f55604080830151909155606090910151602155805160808101909152806064611428476014613c6c565b6114329190613c58565b81526020016064611444476023613c6c565b61144e9190613c58565b81526020016064611460476023613c6c565b61146a9190613c58565b8152602001606461147c47600a613c6c565b6114869190613c58565b9052805160225560208101516023556040810151602455606001516025556012805460ff19166001179055565b6114bb612bf9565b6001600160a01b03919091166000908152601b60205260409020805460ff1916911515919091179055565b60606114f0612bf9565b6000836001600160401b0381111561150a5761150a613dbd565b604051908082528060200260200182016040528015611533578160200160208202803683370190505b5090506000846001600160401b0381111561155057611550613dbd565b604051908082528060200260200182016040528015611579578160200160208202803683370190505b50845190915060005b8681101561173e5785516040805160208101849052908101919091524260608201524460808201524360a0820152829060c0016040516020818303038152906040528051906020012060001c6115d89190613d3b565b8482815181106115ea576115ea613da7565b6020026020010181815250508584828151811061160957611609613da7565b60200260200101518151811061162157611621613da7565b602002602001015183828151811061163b5761163b613da7565b60200260200101818152505060008660018389516116599190613c8b565b6116639190613c8b565b8151811061167357611673613da7565b602002602001015190508685838151811061169057611690613da7565b6020026020010151815181106116a8576116a8613da7565b6020026020010151876001848a516116c09190613c8b565b6116ca9190613c8b565b815181106116da576116da613da7565b60200260200101818152505080878684815181106116fa576116fa613da7565b60200260200101518151811061171257611712613da7565b60209081029190910101528261172781613cce565b93505050808061173690613d20565b915050611582565b50878760405161174f929190613a81565b60405180910390207fae2d510396e2d23f924831e683bcfbc45d4d9d91ccc4a8e12bddcc836bf7d61f836040516117869190613b4a565b60405180910390a2509150505b949350505050565b6013544210156117e25760405162461bcd60e51b81526020600482015260126024820152714e6f74206f6e207075626c69632073616c6560701b6044820152606401610be1565b612710836117ee610fea565b6117f89190613c40565b11156118165760405162461bcd60e51b8152600401610be190613bed565b600e546001600160a01b03851660009081526017602052604090205461183d908590613c40565b111561185b5760405162461bcd60e51b8152600401610be190613b95565b61186c66b1a2bc2ec5000084613c6c565b34101561188b5760405162461bcd60e51b8152600401610be190613bbd565b601554604080516020601f85018190048102820181019092528381526001600160a01b0390921691611901918590859081908401838280828437600092019190915250506040516bffffffffffffffffffffffff1960608b901b16602082015260348101899052610c9492506054019050610c79565b6001600160a01b0316146119485760405162461bcd60e51b815260206004820152600e60248201526d14da59db985d1d5c994819985a5b60921b6044820152606401610be1565b6001600160a01b03841660009081526017602052604090208054840190556119708484612a2d565b50505050565b606060038054610eac90613ce5565b61198d612bf9565b601355565b61199a612bf9565b601680546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0382166000908152601b602052604090205460ff1615611a255760405162461bcd60e51b815260206004820152601b60248201527f5468652061646472657373206973206e6f7420617070726f76656400000000006044820152606401610be1565b610fe68282612d0e565b611a37612bf9565b60005b818110156111c45730631ba97836848484818110611a5a57611a5a613da7565b9050602002016020810190611a6f9190613469565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b158015611aae57600080fd5b505afa158015611ac2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae691906137e1565b611b8c57601c838383818110611afe57611afe613da7565b9050602002016020810190611b139190613469565b81546001810183556000928352602083200180546001600160a01b0319166001600160a01b0392909216919091179055601c5490601d90858585818110611b5c57611b5c613da7565b9050602002016020810190611b719190613469565b6001600160a01b031681526020810191909152604001600020555b80611b9681613d20565b915050611a3a565b60026009541415611bf15760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610be1565b600260095560125460ff16611c3c5760405162461bcd60e51b81526020600482015260116024820152704e6f742074696d6520746f20636c61696d60781b6044820152606401610be1565b7ffa26db7ca85ead399216e7c6316bc50ed24393c3122b582735e7f3b0f91b93f060005b85811015611f475733611c8a888884818110611c7e57611c7e613da7565b90506020020135611302565b6001600160a01b031614611d805760145433906001600160a01b03166317968dff898985818110611cbd57611cbd613da7565b905060200201356040518263ffffffff1660e01b8152600401611ce291815260200190565b60206040518083038186803b158015611cfa57600080fd5b505afa158015611d0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d329190613486565b6001600160a01b031614611d805760405162461bcd60e51b81526020600482015260156024820152742cb7ba9030b932903737ba103a34329037bbb732b960591b6044820152606401610be1565b60196000888884818110611d9657611d96613da7565b60209081029290920135835250818101929092526040908101600090812060ff808a168352935220541615611e195760405162461bcd60e51b815260206004820152602360248201527f596f75206861766520616c72656164792072656365697665642074686520626f6044820152626e757360e81b6064820152608401610be1565b600160196000898985818110611e3157611e31613da7565b90506020020135815260200190815260200160002060008760ff1660ff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600160186000898985818110611e8c57611e8c613da7565b90506020020135815260200190815260200160002060006101000a81548160ff0219169083151502179055508133888884818110611ecc57611ecc613da7565b9050602002013587604051602001611f1c949392919093845260609290921b6bffffffffffffffffffffffff19166020840152603483015260f81b6001600160f81b031916605482015260550190565b6040516020818303038152906040528051906020012091508080611f3f90613d20565b915050611c60565b50601654604080516020601f86018190048102820181019092528481526001600160a01b0390921691611f9a918690869081908401838280828437600092019190915250610c9492508691506129b69050565b6001600160a01b031614611ffc5760405162461bcd60e51b815260206004820152602360248201527f596f752063616e2774206765742074686520636f6e736f6c6174696f6e207072604482015262697a6560e81b6064820152608401610be1565b60ff841661208957601054601f5460009161201691613c58565b602354909150156120535761202b8682613c6c565b6023546120389190613c8b565b60235561204e336120498884613c6c565b612d7a565b612087565b60405162461bcd60e51b815260206004820152600960248201526810db185a5b48195b9960ba1b6044820152606401610be1565b505b60ff8416600114156120eb5760006008600f54601e600201546120ac9190613c58565b6120b69190613c58565b60245490915015612053576120cb8682613c6c565b6024546120d89190613c8b565b6024556120e9336120498884613c6c565b505b60ff84166002141561214c576000600a6018601e6003015461210d9190613c58565b6121179190613c58565b602554909150156120535761212c8682613c6c565b6025546121399190613c8b565b60255561214a336120498884613c6c565b505b8360ff168686604051612160929190613a55565b6040519081900381209033907f340acc4507bd9d4fcb8cb291e68842d3aa15325663dd7132f507213ee1fc5ef990600090a45050600160095550505050565b6121aa848484611022565b6001600160a01b0383163b15611970576121c684848484612e93565b611970576040516368d2bf6b60e11b815260040160405180910390fd5b60606121ee82612b24565b6122525760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610be1565b600061225c612f87565b905080516000141561227d57604051806020016040528060008152506122a8565b8061228784612f96565b604051602001612298929190613a91565b6040516020818303038152906040525b9392505050565b601180546122bc90613ce5565b80601f01602080910402602001604051908101604052809291908181526020018280546122e890613ce5565b80156123355780601f1061230a57610100808354040283529160200191612335565b820191906000526020600020905b81548152906001019060200180831161231857829003601f168201915b505050505081565b600081156123c457604051630b02f02d60e31b8152600481018490526001600160a01b0385169063581781689060240160206040518083038186803b15801561238557600080fd5b505afa158015612399573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123bd9190613486565b905061243f565b6040516331a9108f60e11b8152600481018490526001600160a01b03851690636352211e9060240160206040518083038186803b15801561240457600080fd5b505afa158015612418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243c9190613486565b90505b6001600160a01b03811661248e5760405162461bcd60e51b815260206004820152601660248201527542636e546f6b656e4964206e6f74206578697374732160501b6044820152606401610be1565b6001600160a01b038085166000908152601a6020908152604080832087845282528083205493851683526017909152902054600d546124cd8884613c40565b111561251b5760405162461bcd60e51b815260206004820152601860248201527f42636e546f6b656e49642069732075736564206c696d697400000000000000006044820152606401610be1565b604051630dd4bc1b60e11b81526001600160a01b03871660048201523090631ba978369060240160206040518083038186803b15801561255a57600080fd5b505afa15801561256e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259291906137e1565b6125d55760405162461bcd60e51b81526020600482015260146024820152732737ba1039bab83837b93a103a3434b9903131b760611b6044820152606401610be1565b600d546125e28883613c40565b11156126005760405162461bcd60e51b8152600401610be190613b95565b6127108761260c610fea565b6126169190613c40565b11156126345760405162461bcd60e51b8152600401610be190613bed565b612645667c58508723800088613c6c565b3410156126645760405162461bcd60e51b8152600401610be190613bbd565b6001600160a01b038084166000908152601760209081526040808320858c0190559289168252601a815282822088835290522082880190556126a68388612a2d565b856001600160a01b031687846001600160a01b03167f1313a106430aceffba19452cbc52f96e2aca9f45a4acdbbeae07bcd4e4eb66dc886040516126ec91815260200190565b60405180910390a450505050505050565b612705612bf9565b600f55565b612712612bf9565b60005b818110156111c4576000601d8185858581811061273457612734613da7565b90506020020160208101906127499190613469565b6001600160a01b031681526020810191909152604001600020549050801561289f576000612778600183613c8b565b601c5490915060009061278d90600190613c8b565b9050818114612818576000601c60000182815481106127ae576127ae613da7565b600091825260209091200154601c80546001600160a01b0390921692508291859081106127dd576127dd613da7565b600091825260208083209190910180546001600160a01b0319166001600160a01b03948516179055929091168152601d909152604090208390555b601c80548061282957612829613d91565b600082815260208120820160001990810180546001600160a01b0319169055909101909155601d9087878781811061286357612863613da7565b90506020020160208101906128789190613469565b6001600160a01b03166001600160a01b031681526020019081526020016000206000905550505b50806128aa81613d20565b915050612715565b6128ba612bf9565b6001600160a01b03811661291f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610be1565b61126f81612cbc565b6060601c600001805480602002602001604051908101604052809291908181526020018280548015610f2557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612965575050505050905090565b612994612bf9565b601580546001600160a01b0319166001600160a01b0392909216919091179055565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b6000806000612a188585612fe4565b91509150612a2581613054565b509392505050565b60005481612a4e5760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b03831660008181526005602090815260408083208054680100000000000000018802019055848352600490915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b818114612afd57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600101612ac5565b5081612b1b57604051622e076360e81b815260040160405180910390fd5b60005550505050565b600081600111158015612b38575060005482105b8015610e97575050600090815260046020526040902054600160e01b161590565b6000612b6482611302565b9050336001600160a01b03821614612b9d57612b808133610a87565b612b9d576040516367d9dca160e11b815260040160405180910390fd5b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6008546001600160a01b0316331461136d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610be1565b60008180600111612ca357600054811015612ca357600081815260046020526040902054600160e01b8116612ca1575b806122a8575060001901600081815260046020526040902054612c83565b505b604051636f96cda160e11b815260040160405180910390fd5b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b80471015612dca5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610be1565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612e17576040519150601f19603f3d011682016040523d82523d6000602084013e612e1c565b606091505b50509050806111c45760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610be1565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612ec8903390899088908890600401613ac0565b602060405180830381600087803b158015612ee257600080fd5b505af1925050508015612f12575060408051601f3d908101601f19168201909252612f0f9181019061381b565b60015b612f6d573d808015612f40576040519150601f19603f3d011682016040523d82523d6000602084013e612f45565b606091505b508051612f65576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611793565b606060118054610eac90613ce5565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a900480612fcd57612fd2565b612fb0565b50819003601f19909101908152919050565b60008082516041141561301b5760208301516040840151606085015160001a61300f8782858561320f565b9450945050505061304d565b825160401415613045576020830151604084015161303a8683836132fc565b93509350505061304d565b506000905060025b9250929050565b600081600481111561306857613068613d7b565b14156130715750565b600181600481111561308557613085613d7b565b14156130d35760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610be1565b60028160048111156130e7576130e7613d7b565b14156131355760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610be1565b600381600481111561314957613149613d7b565b14156131a25760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610be1565b60048160048111156131b6576131b6613d7b565b141561126f5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610be1565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561324657506000905060036132f3565b8460ff16601b1415801561325e57508460ff16601c14155b1561326f57506000905060046132f3565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156132c3573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166132ec576000600192509250506132f3565b9150600090505b94509492505050565b6000806001600160ff1b0383168161331960ff86901c601b613c40565b90506133278782888561320f565b935093505050935093915050565b82805461334190613ce5565b90600052602060002090601f01602090048101928261336357600085556133a9565b82601f1061337c5782800160ff198235161785556133a9565b828001600101855582156133a9579182015b828111156133a957823582559160200191906001019061338e565b506133b59291506133b9565b5090565b5b808211156133b557600081556001016133ba565b60008083601f8401126133e057600080fd5b5081356001600160401b038111156133f757600080fd5b6020830191508360208260051b850101111561304d57600080fd5b60008083601f84011261342457600080fd5b5081356001600160401b0381111561343b57600080fd5b60208301915083602082850101111561304d57600080fd5b803560ff8116811461346457600080fd5b919050565b60006020828403121561347b57600080fd5b81356122a881613dd3565b60006020828403121561349857600080fd5b81516122a881613dd3565b600080604083850312156134b657600080fd5b82356134c181613dd3565b915060208301356134d181613dd3565b809150509250929050565b6000806000606084860312156134f157600080fd5b83356134fc81613dd3565b9250602084013561350c81613dd3565b929592945050506040919091013590565b6000806000806080858703121561353357600080fd5b843561353e81613dd3565b935060208581013561354f81613dd3565b93506040860135925060608601356001600160401b038082111561357257600080fd5b818801915088601f83011261358657600080fd5b81358181111561359857613598613dbd565b6135aa601f8201601f19168501613c10565b915080825289848285010111156135c057600080fd5b808484018584013760008482840101525080935050505092959194509250565b60008060008060008060a087890312156135f957600080fd5b863561360481613dd3565b9550602087013561361481613dd3565b94506040870135935060608701356004811061362f57600080fd5b925060808701356001600160401b0381111561364a57600080fd5b61365689828a01613412565b979a9699509497509295939492505050565b6000806040838503121561367b57600080fd5b823561368681613dd3565b915060208301356134d181613de8565b600080604083850312156136a957600080fd5b82356136b481613dd3565b946020939093013593505050565b600080600080606085870312156136d857600080fd5b84356136e381613dd3565b93506020850135925060408501356001600160401b0381111561370557600080fd5b61371187828801613412565b95989497509550505050565b6000806020838503121561373057600080fd5b82356001600160401b0381111561374657600080fd5b613752858286016133ce565b90969095509350505050565b60008060008060006060868803121561377657600080fd5b85356001600160401b038082111561378d57600080fd5b61379989838a016133ce565b90975095508591506137ad60208901613453565b945060408801359150808211156137c357600080fd5b506137d088828901613412565b969995985093965092949392505050565b6000602082840312156137f357600080fd5b81516122a881613de8565b60006020828403121561381057600080fd5b81356122a881613df6565b60006020828403121561382d57600080fd5b81516122a881613df6565b6000806020838503121561384b57600080fd5b82356001600160401b0381111561386157600080fd5b61375285828601613412565b6000806000806060858703121561388357600080fd5b84356001600160401b038082111561389a57600080fd5b6138a688838901613412565b9096509450602087810135945091506040870135818111156138c757600080fd5b8701601f810189136138d857600080fd5b8035828111156138ea576138ea613dbd565b8060051b92506138fb848401613c10565b8181528481019083860185850187018d101561391657600080fd5b600095505b8386101561393957803583526001959095019491860191860161391b565b50989b979a50959850505050505050565b60006020828403121561395c57600080fd5b5035919050565b6000806000806080858703121561397957600080fd5b84359350602085013561398b81613dd3565b92506040850135915060608501356139a281613de8565b939692955090935050565b600080604083850312156139c057600080fd5b823591506139d060208401613453565b90509250929050565b600081518084526139f1816020860160208601613ca2565b601f01601f19169290920160200192915050565b6bffffffffffffffffffffffff198460601b168152826014820152600060048310613a4057634e487b7160e01b600052602160045260246000fd5b5060f89190911b603482015260350192915050565b60006001600160fb1b03831115613a6b57600080fd5b8260051b80858437600092019182525092915050565b8183823760009101908152919050565b60008351613aa3818460208801613ca2565b835190830190613ab7818360208801613ca2565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613af3908301846139d9565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015613b3e5783516001600160a01b031683529284019291840191600101613b19565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015613b3e57835183529284019291840191600101613b66565b6020815260006122a860208301846139d9565b6020808252600e908201526d131a5b5a5d08195e18d95959195960921b604082015260600190565b6020808252601690820152754e6f7420706179696e6720656e6f756768206665657360501b604082015260600190565b602080825260099082015268536f6c64206f75742160b81b604082015260600190565b604051601f8201601f191681016001600160401b0381118282101715613c3857613c38613dbd565b604052919050565b60008219821115613c5357613c53613d4f565b500190565b600082613c6757613c67613d65565b500490565b6000816000190483118215151615613c8657613c86613d4f565b500290565b600082821015613c9d57613c9d613d4f565b500390565b60005b83811015613cbd578181015183820152602001613ca5565b838111156119705750506000910152565b600081613cdd57613cdd613d4f565b506000190190565b600181811c90821680613cf957607f821691505b60208210811415613d1a57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613d3457613d34613d4f565b5060010190565b600082613d4a57613d4a613d65565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461126f57600080fd5b801515811461126f57600080fd5b6001600160e01b03198116811461126f57600080fdfea26469706673582212200442e9913461729be3308b3cf560f0a49b9028ffb83ac7f9a59ed95190243c4e64736f6c63430008070033

Verified Source Code Full Match

Compiler: v0.8.7+commit.e28d00a7 EVM: london Optimization: Yes (200 runs)
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
ECDSA.sol 230 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

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

    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) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        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.
            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 if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } 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));
    }
}
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)
        }
    }
}
StakeContract.sol 6 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

contract StakeContract {
    mapping(uint256 => address) public stakeOwnerOf;
}
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);
}
_10KWorldCup.sol 498 lines
// SPDX-License-Identifier: MIT

/*

  $$\   $$$$$$\  $$\   $$\       $$\      $$\                     $$\       $$\                                     
$$$$ | $$$ __$$\ $$ | $$  |      $$ | $\  $$ |                    $$ |      $$ |                                    
\_$$ | $$$$\ $$ |$$ |$$  /       $$ |$$$\ $$ | $$$$$$\   $$$$$$\  $$ | $$$$$$$ |       $$$$$$$\ $$\   $$\  $$$$$$\  
  $$ | $$\$$\$$ |$$$$$  /        $$ $$ $$\$$ |$$  __$$\ $$  __$$\ $$ |$$  __$$ |      $$  _____|$$ |  $$ |$$  __$$\ 
  $$ | $$ \$$$$ |$$  $$<         $$$$  _$$$$ |$$ /  $$ |$$ |  \__|$$ |$$ /  $$ |      $$ /      $$ |  $$ |$$ /  $$ |
  $$ | $$ |\$$$ |$$ |\$$\        $$$  / \$$$ |$$ |  $$ |$$ |      $$ |$$ |  $$ |      $$ |      $$ |  $$ |$$ |  $$ |
$$$$$$\\$$$$$$  /$$ | \$$\       $$  /   \$$ |\$$$$$$  |$$ |      $$ |\$$$$$$$ |      \$$$$$$$\ \$$$$$$  |$$$$$$$  |
\______|\______/ \__|  \__|      \__/     \__| \______/ \__|      \__| \_______|       \_______| \______/ $$  ____/ 
                                                                                                          $$ |      
                                                                                                          $$ |      
                                                                                                          \__|      
*/

pragma solidity ^0.8.7;

import "./IERC721D.sol";
import "./StakeContract.sol";
import "./CryptoPunksMarket.sol";
import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract _10KWorldCup is IERC721D, ERC721A, Ownable, ReentrancyGuard {
    using ECDSA for bytes32;
    uint256 public constant MAX_SUPPLY = 10000;
    uint256 public constant WL_PRICE = 0.035 ether;
    uint256 public constant PUB_PRICE = 0.05 ether;
    uint256 public BuilderWL_LIMIT = 8;
    uint256 public SuperWL_LIMIT = 4;
    uint256 public WL_LIMIT = 2;
    uint256 public BCN_LIMIT = 2;
    uint256 public PUB_SALE_LIMIT = 2;
    uint256 public topEightRightTeams;
    uint256 public championTokenIdAmount;
    string public baseTokenURI;
    bool claimStatus;
    uint256 public pubSaleTime = 1667829600;
    address public stakeAddress;
    address public mintSignAddress = 0x66E1A1c2307c5a126ef2837969ae020Ede7d6548;
    address public ClaimSignAddress =
        0x93A0f55968a2050b4bF5B900b5Aa566F304194e2;

    mapping(address => uint256) public minteds;
    mapping(uint256 => bool) bonusCliamed;
    mapping(uint256 => mapping(uint8 => bool)) public bonusInfo;
    mapping(address => mapping(uint256 => uint256)) public bcnTokenIdUsedLimit;
    mapping(address => bool) public disapprovedMarketplaces;

    enum WlType {
        BuilderWl,
        SuperWl,
        LuckyWl,
        CommonWl
    }

    enum ClaimType {
        ChampionBonus,
        TopEightBonus,
        ConsolationPrize
    }

    Bcn supportedBcns;
    struct Bcn {
        address[] _bcnAddress;
        mapping(address => uint256) _index;
    }

    Bonus public bonus;
    struct Bonus {
        uint256 ownerBonus;
        uint256 championBonus;
        uint256 topEightBonus;
        uint256 consolationPrize;
    }

    RemainBonus public remainBonus;
    struct RemainBonus {
        uint256 ownerBonus;
        uint256 championBonus;
        uint256 topEightBonus;
        uint256 consolationPrize;
    }

    event RandomTeam(string indexed country, uint256[]);
    event MintToBcn(
        address indexed to,
        uint256 indexed amount,
        address indexed bcnAddress,
        uint256
    );

    constructor(string memory _baseTokenUri)
        ERC721A("10K World Cup", "10K World Cup")
    {
        baseTokenURI = _baseTokenUri;
    }

    function mint(
        address to,
        uint256 amount,
        bytes calldata _signature
    ) external payable {
        require(block.timestamp >= pubSaleTime, "Not on public sale");
        require(totalSupply() + amount <= MAX_SUPPLY, "Sold out!");
        require(minteds[to] + amount <= PUB_SALE_LIMIT, "Limit exceeded");
        require(msg.value >= amount * PUB_PRICE, "Not paying enough fees");
        require(
            keccak256(abi.encodePacked(to, amount))
                .toEthSignedMessageHash()
                .recover(_signature) == mintSignAddress,
            "Signature fail"
        );
        unchecked {
            minteds[to] += amount;
        }
        _mint(to, amount);
    }

    function wlMint(
        address _owner,
        address to,
        uint256 amount,
        WlType _WlType,
        bytes calldata _singature
    ) external payable {
        require(totalSupply() + amount <= MAX_SUPPLY, "Sold out!");
        require(msg.value >= amount * WL_PRICE, "Not paying enough fees");
        require(
            keccak256(abi.encodePacked(_owner, amount, _WlType))
                .toEthSignedMessageHash()
                .recover(_singature) == mintSignAddress,
            "You're not on the whitelist"
        );

        if (_WlType == WlType.BuilderWl) {
            require(
                minteds[_owner] + amount <= BuilderWL_LIMIT,
                "Limit exceeded"
            );
        } else if (_WlType == WlType.SuperWl) {
            require(
                minteds[_owner] + amount <= SuperWL_LIMIT,
                "Limit exceeded"
            );
        } else if (_WlType == WlType.LuckyWl) {
            require(minteds[_owner] + amount <= WL_LIMIT, "Limit exceeded");
        } else {
            require(minteds[_owner] + amount <= WL_LIMIT, "Limit exceeded");
        }

        unchecked {
            minteds[_owner] += amount;
        }
        _mint(to, amount);
    }

    function mintToBcn(
        uint256 amount,
        address bcn,
        uint256 bcnTokenId,
        bool isCryptoPunks
    ) external payable {
        address to;
        if (isCryptoPunks) {
            to = CryptoPunksMarket(bcn).punkIndexToAddress(bcnTokenId);
        } else {
            to = IERC721A(bcn).ownerOf(bcnTokenId);
        }

        require(to != address(0), "BcnTokenId not exists!");
        uint256 bcnTokenLimit = bcnTokenIdUsedLimit[bcn][bcnTokenId];
        uint256 wlMintedAmount = minteds[to];
        require(
            bcnTokenLimit + amount <= BCN_LIMIT,
            "BcnTokenId is used limit"
        );
        require(this.containsBcn(bcn), "Not support this bcn");
        require(wlMintedAmount + amount <= BCN_LIMIT, "Limit exceeded");
        require(totalSupply() + amount <= MAX_SUPPLY, "Sold out!");
        require(msg.value >= amount * WL_PRICE, "Not paying enough fees");
        unchecked {
            minteds[to] = wlMintedAmount + amount;
            bcnTokenIdUsedLimit[bcn][bcnTokenId] = bcnTokenLimit + amount;
        }
        _mint(to, amount);
        emit MintToBcn(to, amount, bcn, bcnTokenId);
    }

    function addBcn(address[] calldata bcns) external onlyOwner {
        for (uint256 i = 0; i < bcns.length; i++) {
            if (!this.containsBcn(bcns[i])) {
                supportedBcns._bcnAddress.push(bcns[i]);
                supportedBcns._index[bcns[i]] = supportedBcns
                    ._bcnAddress
                    .length;
            }
        }
    }

    function removeBcn(address[] calldata bcns) external onlyOwner {
        for (uint256 i = 0; i < bcns.length; i++) {
            uint256 addressIndex = supportedBcns._index[bcns[i]];
            if (addressIndex != 0) {
                uint256 toDeleteIndex = addressIndex - 1;
                uint256 lastIndex = supportedBcns._bcnAddress.length - 1;
                if (lastIndex != toDeleteIndex) {
                    address lastAddress = supportedBcns._bcnAddress[lastIndex];
                    supportedBcns._bcnAddress[toDeleteIndex] = lastAddress;
                    supportedBcns._index[lastAddress] = addressIndex;
                }
                supportedBcns._bcnAddress.pop();
                delete supportedBcns._index[bcns[i]];
            }
        }
    }

    function containsBcn(address bcn) external view returns (bool) {
        return supportedBcns._index[bcn] != 0;
    }

    function allSupportedBcn() external view returns (address[] memory) {
        return supportedBcns._bcnAddress;
    }

    function lengthBcn() external view returns (uint256) {
        return supportedBcns._bcnAddress.length;
    }

    function getRandomOfTeam(
        string calldata country,
        uint256 amount,
        uint256[] memory tokenIds
    ) external onlyOwner returns (uint256[] memory randomTokenId) {
        uint256[] memory randomNumbers = new uint256[](amount);
        uint256[] memory randomTokenIds = new uint256[](amount);
        uint256 range = tokenIds.length;
        for (uint256 i = 0; i < amount; i++) {
            randomNumbers[i] =
                uint256(
                    keccak256(
                        abi.encodePacked(
                            i,
                            tokenIds.length,
                            block.timestamp,
                            block.difficulty,
                            block.number
                        )
                    )
                ) %
                range;
            randomTokenIds[i] = tokenIds[randomNumbers[i]];
            uint256 lastTokenId = tokenIds[tokenIds.length - i - 1];
            tokenIds[tokenIds.length - i - 1] = tokenIds[randomNumbers[i]];
            tokenIds[randomNumbers[i]] = lastTokenId;
            range--;
        }
        emit RandomTeam(country, randomTokenIds);
        return randomTokenIds;
    }

    function intoChampionBonus() external onlyOwner {
        remainBonus.championBonus =
            remainBonus.championBonus +
            remainBonus.topEightBonus;
        remainBonus.topEightBonus = 0;
        bonus.championBonus = remainBonus.championBonus;
        bonus.topEightBonus = remainBonus.topEightBonus;
    }

    function setDistribution() external virtual override onlyOwner {
        bonus = Bonus({
            ownerBonus: (address(this).balance * 20) / 100,
            championBonus: (address(this).balance * 35) / 100,
            topEightBonus: (address(this).balance * 35) / 100,
            consolationPrize: (address(this).balance * 10) / 100
        });
        remainBonus = RemainBonus({
            ownerBonus: (address(this).balance * 20) / 100,
            championBonus: (address(this).balance * 35) / 100,
            topEightBonus: (address(this).balance * 35) / 100,
            consolationPrize: (address(this).balance * 10) / 100
        });
        claimStatus = true;
    }

    receive() external payable {}

    function claimDistribution(
        uint256[] calldata tokenIds,
        uint8 enumType,
        bytes calldata _signature
    ) external virtual override nonReentrant {
        require(claimStatus, "Not time to claim");
        bytes32 signedHash = 0xfa26db7ca85ead399216e7c6316bc50ed24393c3122b582735e7f3b0f91b93f0;
        for (uint256 i = 0; i < tokenIds.length; i++) {
            if (ownerOf(tokenIds[i]) != msg.sender) {
                require(
                    StakeContract(stakeAddress).stakeOwnerOf(tokenIds[i]) ==
                        msg.sender,
                    "You are not the owner"
                );
            }
            require(
                !bonusInfo[tokenIds[i]][enumType],
                "You have already received the bonus"
            );
            bonusInfo[tokenIds[i]][enumType] = true;
            bonusCliamed[tokenIds[i]] = true;
            signedHash = keccak256(
                abi.encodePacked(signedHash, msg.sender, tokenIds[i], enumType)
            );
        }
        require(
            signedHash.toEthSignedMessageHash().recover(_signature) ==
                ClaimSignAddress,
            "You can't get the consolation prize"
        );

        if (enumType == uint8(ClaimType.ChampionBonus)) {
            uint256 bonusValue = bonus.championBonus / championTokenIdAmount;
            if (remainBonus.championBonus > 0) {
                remainBonus.championBonus =
                    remainBonus.championBonus -
                    (bonusValue * tokenIds.length);
                sendValue(payable(msg.sender), bonusValue * tokenIds.length);
            } else {
                revert("Claim end");
            }
        }

        if (enumType == uint8(ClaimType.TopEightBonus)) {
            uint256 bonusValue = bonus.topEightBonus / topEightRightTeams / 8;
            if (remainBonus.topEightBonus > 0) {
                remainBonus.topEightBonus =
                    remainBonus.topEightBonus -
                    (bonusValue * tokenIds.length);
                sendValue(payable(msg.sender), bonusValue * tokenIds.length);
            } else {
                revert("Claim end");
            }
        }

        if (enumType == uint8(ClaimType.ConsolationPrize)) {
            uint256 bonusValue = bonus.consolationPrize / 24 / 10;
            if (remainBonus.consolationPrize > 0) {
                remainBonus.consolationPrize =
                    remainBonus.consolationPrize -
                    (bonusValue * tokenIds.length);
                sendValue(payable(msg.sender), bonusValue * tokenIds.length);
            } else {
                revert("Claim end");
            }
        }

        emit ClaimEvent(msg.sender, tokenIds, enumType);
    }

    function isSupportClaim(uint256 tokenId)
        external
        view
        virtual
        override
        returns (bool)
    {
        return bonusCliamed[tokenId] == false;
    }

    function isClaimedDistribution(uint256 tokenId)
        external
        view
        virtual
        override
        returns (bool)
    {
        return bonusCliamed[tokenId];
    }

    function isBegainClaim() external view virtual override returns (bool) {
        return claimStatus;
    }

    function setTopEightTeams(uint256 _topEightRightTeams) external onlyOwner {
        topEightRightTeams = _topEightRightTeams;
    }

    function setChampionTokenAmount(uint256 _championTokenAmount)
        external
        onlyOwner
    {
        championTokenIdAmount = _championTokenAmount;
    }

    function setPubSaleTime(uint256 timestamp) external onlyOwner {
        pubSaleTime = timestamp;
    }

    function ownerMint(address to, uint256 amount) external onlyOwner {
        require(totalSupply() + amount <= MAX_SUPPLY, "Sold out!");
        _mint(to, amount);
    }

    function setMintSignedAddress(address _mintSignAddress) external onlyOwner {
        mintSignAddress = _mintSignAddress;
    }

    function setStakeAddress(address _stakeAddress) external onlyOwner {
        stakeAddress = _stakeAddress;
    }

    function setClaimSignedAddress(address _claimSignAddress)
        external
        onlyOwner
    {
        ClaimSignAddress = _claimSignAddress;
    }

    function setBaseTokenURI(string calldata _uri) external onlyOwner {
        baseTokenURI = _uri;
    }

    function setDisapprovedMarketplace(address market, bool isDisapprove)
        external
        onlyOwner
    {
        disapprovedMarketplaces[market] = isDisapprove;
    }

    function sendValue(address payable recipient, uint256 amount) internal {
        require(
            address(this).balance >= amount,
            "Address: insufficient balance"
        );
        (bool success, ) = recipient.call{value: amount}("");
        require(
            success,
            "Address: unable to send value, recipient may have reverted"
        );
    }

    function withdraw() external onlyOwner {
        (bool success, ) = msg.sender.call{value: remainBonus.ownerBonus}("");
        remainBonus.ownerBonus = 0;
        require(success, "Transfer failed.");
    }


    function approve(address to, uint256 tokenId)
        public
        payable
        virtual
        override
    {
        require(!disapprovedMarketplaces[to], "The address is not approved");
        super.approve(to, tokenId);
    }

    function setApprovalForAll(address operator, bool approved)
        public
        virtual
        override
    {
        require(
            !disapprovedMarketplaces[operator],
            "The address is not approved"
        );
        super.setApprovalForAll(operator, approved);
    }

    function _baseURI() internal view override returns (string memory) {
        return baseTokenURI;
    }

    function tokenURI(uint256 tokenId)
        public
        view
        override
        returns (string memory)
    {
        require(
            _exists(tokenId),
            "ERC721Metadata: URI query for nonexistent token"
        );
        string memory baseURI = _baseURI();
        return
            bytes(baseURI).length != 0
                ? string(abi.encodePacked(baseURI, _toString(tokenId)))
                : "";
    }

    function _startTokenId() internal pure override returns (uint256) {
        return 1;
    }
}
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);
    }
}
CryptoPunksMarket.sol 6 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

contract CryptoPunksMarket {
    mapping(uint256 => address) public punkIndexToAddress;
}
IERC721D.sol 60 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

/**
 * New Distribution Scheme ERC721D
 */

interface IERC721D {
    /**
     * Cliamed Distribution Event;
     */

    event ClaimEvent(
        address indexed to,
        uint256[] indexed tokenIds,
        uint8 indexed claimType
    );

    /**
     * Set  Distribution Scheme
     */

    function setDistribution() external;

    /**
     *Uint256 [] tokenIds give the token id holder the allocated bonus
     *Uint8 enumType distinguishes different bonus distribution schemes
     *bytes calldata _ Signature verifies the legitimacy of the collection
     * emit event after claimed
     */

    function claimDistribution(
        uint256[] calldata tokenIds,
        uint8 enumType,
        bytes calldata _signature
    ) external;

    /**
     * Check whether a token ID supports Claim
     * returns supported: is support claim
     */

    function isSupportClaim(uint256 tokenId) external view returns (bool);

    /**
     * Check whether the token id has been claimed
     * returns cliamed : claimed status
     */

    function isClaimedDistribution(uint256 tokenId)
        external
        view
        returns (bool);

    /**
     * Check whether begain claim
     */

    function isBegainClaim() external view returns (bool);
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

Read Contract

BCN_LIMIT 0x09a2dd86 → uint256
BuilderWL_LIMIT 0x4c97f707 → uint256
ClaimSignAddress 0x05562292 → address
MAX_SUPPLY 0x32cb6b0c → uint256
PUB_PRICE 0xb472070f → uint256
PUB_SALE_LIMIT 0xdc5c03d3 → uint256
SuperWL_LIMIT 0x21e67bb2 → uint256
WL_LIMIT 0x78b004a2 → uint256
WL_PRICE 0x31c3c7a0 → uint256
allSupportedBcn 0xf53d6672 → address[]
balanceOf 0x70a08231 → uint256
baseTokenURI 0xd547cfb7 → string
bcnTokenIdUsedLimit 0xc8c584e4 → uint256
bonus 0x75b4d78c → uint256, uint256, uint256, uint256
bonusInfo 0x81b02fd8 → bool
championTokenIdAmount 0x5c412101 → uint256
containsBcn 0x1ba97836 → bool
disapprovedMarketplaces 0x9fb90e7c → bool
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
isBegainClaim 0x6e50acd4 → bool
isClaimedDistribution 0xf3d0e07a → bool
isSupportClaim 0xfeea6329 → bool
lengthBcn 0xec13b17f → uint256
mintSignAddress 0x7be14e9f → address
minteds 0xdd88b162 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
pubSaleTime 0xe8f9eec8 → uint256
remainBonus 0xbd42b89f → uint256, uint256, uint256, uint256
stakeAddress 0x85107367 → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
topEightRightTeams 0x9c885706 → uint256
totalSupply 0x18160ddd → uint256

Write Contract 26 functions

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

addBcn 0xa89f8bdb
address[] bcns
approve 0x095ea7b3
address to
uint256 tokenId
claimDistribution 0xa9fea204
uint256[] tokenIds
uint8 enumType
bytes _signature
getRandomOfTeam 0x8e2844ab
string country
uint256 amount
uint256[] tokenIds
returns: uint256[]
intoChampionBonus 0x5344b044
No parameters
mint 0x94d008ef
address to
uint256 amount
bytes _signature
mintToBcn 0xd78d2f2e
uint256 amount
address bcn
uint256 bcnTokenId
bool isCryptoPunks
ownerMint 0x484b973c
address to
uint256 amount
removeBcn 0xf03f8b3c
address[] bcns
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseTokenURI 0x30176e13
string _uri
setChampionTokenAmount 0x3a16a738
uint256 _championTokenAmount
setClaimSignedAddress 0xa06afc81
address _claimSignAddress
setDisapprovedMarketplace 0x80ceba1e
address market
bool isDisapprove
setDistribution 0x74f6b2c5
No parameters
setMintSignedAddress 0xfc47df14
address _mintSignAddress
setPubSaleTime 0xa01947cb
uint256 timestamp
setStakeAddress 0x23471d18
address _stakeAddress
setTopEightTeams 0xdce53a01
uint256 _topEightRightTeams
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
wlMint 0x0193ae85
address _owner
address to
uint256 amount
uint8 _WlType
bytes _singature

Recent Transactions

No transactions found for this address