Address Contract Verified
Address
0xb5d53555afd52822f979200E83a515d3464a3c2B
Balance
0 ETH
Nonce
1
Code Size
21120 bytes
Creator
0x0Cc6F5a2...1683 at tx 0xce193130...4ef9e1
Indexed Transactions
0
Contract Bytecode
21120 bytes
0x6080604052600436106102195760003560e01c80638462151c11610123578063c12f0396116100ab578063e222c7f91161006f578063e222c7f9146107dc578063e474def4146107f3578063e985e9c51461081c578063ebc90e1b14610859578063f2fde38b1461087057610219565b8063c12f0396146106df578063c23dc68f1461070a578063c32fe11b14610747578063c87b56dd14610772578063d5e2eb55146107af57610219565b806392f6f745116100f257806392f6f745146105fc57806395d89b411461062557806399a2557a14610650578063a22cb4651461068d578063b88d4fde146106b657610219565b80638462151c14610561578063853828b61461059e5780638da5cb5b146105b557806392ed4b10146105e057610219565b806349985a79116101a65780635bbb2177116101755780635bbb21771461046a578063627804af146104a75780636352211e146104d057806370a082311461050d578063715018a61461054a57610219565b806349985a79146103bd57806350cee227146103e857806355f804b3146104255780635a5e5d581461044e57610219565b8063095ea7b3116101ed578063095ea7b3146102ec57806318160ddd1461031557806323b872dd146103405780633f5e47411461036957806342842e0e1461039457610219565b8062f714ce1461021e57806301ffc9a71461024757806306fdde0314610284578063081812fc146102af575b600080fd5b34801561022a57600080fd5b506102456004803603810190610240919061380f565b610899565b005b34801561025357600080fd5b5061026e600480360381019061026991906138a7565b6109ea565b60405161027b91906138ef565b60405180910390f35b34801561029057600080fd5b50610299610acc565b6040516102a6919061399a565b60405180910390f35b3480156102bb57600080fd5b506102d660048036038101906102d191906139bc565b610b5e565b6040516102e391906139f8565b60405180910390f35b3480156102f857600080fd5b50610313600480360381019061030e9190613a13565b610bda565b005b34801561032157600080fd5b5061032a610cde565b6040516103379190613a62565b60405180910390f35b34801561034c57600080fd5b5061036760048036038101906103629190613a7d565b610cf5565b005b34801561037557600080fd5b5061037e610d05565b60405161038b91906138ef565b60405180910390f35b3480156103a057600080fd5b506103bb60048036038101906103b69190613a7d565b610d18565b005b3480156103c957600080fd5b506103d2610d38565b6040516103df91906138ef565b60405180910390f35b3480156103f457600080fd5b5061040f600480360381019061040a9190613c05565b610d84565b60405161041c91906138ef565b60405180910390f35b34801561043157600080fd5b5061044c60048036038101906104479190613cc1565b610eab565b005b610468600480360381019061046391906139bc565b610ec9565b005b34801561047657600080fd5b50610491600480360381019061048c9190613dd1565b61112a565b60405161049e9190613f4c565b60405180910390f35b3480156104b357600080fd5b506104ce60048036038101906104c99190613a13565b6111eb565b005b3480156104dc57600080fd5b506104f760048036038101906104f291906139bc565b611258565b60405161050491906139f8565b60405180910390f35b34801561051957600080fd5b50610534600480360381019061052f9190613f6e565b61126e565b6040516105419190613a62565b60405180910390f35b34801561055657600080fd5b5061055f61133d565b005b34801561056d57600080fd5b5061058860048036038101906105839190613f6e565b611351565b6040516105959190614059565b60405180910390f35b3480156105aa57600080fd5b506105b361154c565b005b3480156105c157600080fd5b506105ca61165f565b6040516105d791906139f8565b60405180910390f35b6105fa60048036038101906105f5919061407b565b611689565b005b34801561060857600080fd5b50610623600480360381019061061e91906139bc565b61189d565b005b34801561063157600080fd5b5061063a611946565b604051610647919061399a565b60405180910390f35b34801561065c57600080fd5b50610677600480360381019061067291906140d7565b6119d8565b6040516106849190614059565b60405180910390f35b34801561069957600080fd5b506106b460048036038101906106af9190614156565b611c97565b005b3480156106c257600080fd5b506106dd60048036038101906106d89190614196565b611e0e565b005b3480156106eb57600080fd5b506106f4611e86565b6040516107019190613a62565b60405180910390f35b34801561071657600080fd5b50610731600480360381019061072c91906139bc565b611f21565b60405161073e919061425b565b60405180910390f35b34801561075357600080fd5b5061075c61203e565b60405161076991906139f8565b60405180910390f35b34801561077e57600080fd5b50610799600480360381019061079491906139bc565b612064565b6040516107a6919061399a565b60405180910390f35b3480156107bb57600080fd5b506107c4612102565b6040516107d393929190614276565b60405180910390f35b3480156107e857600080fd5b506107f1612127565b005b3480156107ff57600080fd5b5061081a60048036038101906108159190613f6e565b612199565b005b34801561082857600080fd5b50610843600480360381019061083e91906142ad565b6121e5565b60405161085091906138ef565b60405180910390f35b34801561086557600080fd5b5061086e612279565b005b34801561087c57600080fd5b5061089760048036038101906108929190613f6e565b61230c565b005b6108a161238f565b6002600954036108e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108dd90614339565b60405180910390fd5b600260098190555081471015610931576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610928906143a5565b60405180910390fd5b60008173ffffffffffffffffffffffffffffffffffffffff1683604051610957906143f6565b60006040518083038185875af1925050503d8060008114610994576040519150601f19603f3d011682016040523d82523d6000602084013e610999565b606091505b50509050806109dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109d49061442e565b60405180910390fd5b5060016009819055505050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610ab557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610ac55750610ac48261240d565b5b9050919050565b606060028054610adb9061447d565b80601f0160208091040260200160405190810160405280929190818152602001828054610b079061447d565b8015610b545780601f10610b2957610100808354040283529160200191610b54565b820191906000526020600020905b815481529060010190602001808311610b3757829003601f168201915b5050505050905090565b6000610b6982612477565b610b9f576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610be582611258565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610c4c576040517f943f7b8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610c6b6124c5565b73ffffffffffffffffffffffffffffffffffffffff1614610cce57610c9781610c926124c5565b6121e5565b610ccd576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b610cd98383836124cd565b505050565b6000610ce861257f565b6001546000540303905090565b610d00838383612584565b505050565b601060009054906101000a900460ff1681565b610d3383838360405180602001604052806000815250611e0e565b505050565b600080600c60405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900460ff1615151515815250509050806040015191505090565b600080600f547fe6b90c15f3ba2bb52929ad300ac2ab0bf348830f281145566f53d3691638349f856040518060400160405280600d81526020017f616c6c6f776c69737453616c650000000000000000000000000000000000000081525080519060200120604051602001610dfb939291906144c7565b60405160208183030381529060405280519060200120604051602001610e22929190614576565b604051602081830303815290604052805190602001209050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610e7d8285612a38565b73ffffffffffffffffffffffffffffffffffffffff1614610e9f576000610ea2565b60015b91505092915050565b610eb361238f565b818160119182610ec4929190614764565b505050565b601060009054906101000a900460ff16610f18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0f90614880565b60405180910390fd5b6115b381610f24610cde565b610f2e91906148cf565b1115610f6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f669061494f565b60405180910390fd5b80600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fba91906148cf565b60021015610ffd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ff4906149e1565b60405180910390fd5b8066470de4df8200006110109190614a01565b34101561102e8266470de4df8200006110299190614a01565b612a5f565b60405160200161103e9190614b0c565b6040516020818303038152906040529061108e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611085919061399a565b60405180910390fd5b506110993382612bbf565b80600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110e491906148cf565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b606060008251905060008167ffffffffffffffff81111561114e5761114d613ada565b5b60405190808252806020026020018201604052801561118757816020015b611174613724565b81526020019060019003908161116c5790505b50905060005b8281146111e0576111b78582815181106111aa576111a9614b39565b5b6020026020010151611f21565b8282815181106111ca576111c9614b39565b5b602002602001018190525080600101905061118d565b508092505050919050565b6111f361238f565b6115b3816111ff610cde565b61120991906148cf565b111561124a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124190614bb4565b60405180910390fd5b6112548282612bbf565b5050565b600061126382612e99565b600001519050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036112d5576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900467ffffffffffffffff1667ffffffffffffffff169050919050565b61134561238f565b61134f6000613124565b565b606060008060006113618561126e565b905060008167ffffffffffffffff81111561137f5761137e613ada565b5b6040519080825280602002602001820160405280156113ad5781602001602082028036833780820191505090505b5090506113b8613724565b60006113c261257f565b90505b83861461153e57600460008281526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509150816040015161153357600073ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff16146114d857816000015194505b8773ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1603611532578083878060010198508151811061152557611524614b39565b5b6020026020010181815250505b5b8060010190506113c5565b508195505050505050919050565b61155461238f565b600260095403611599576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159090614339565b60405180910390fd5b600260098190555060006115ab61165f565b73ffffffffffffffffffffffffffffffffffffffff16476040516115ce906143f6565b60006040518083038185875af1925050503d806000811461160b576040519150601f19603f3d011682016040523d82523d6000602084013e611610565b606091505b5050905080611654576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164b9061442e565b60405180910390fd5b506001600981905550565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000611693611e86565b116116d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116ca90614c20565b60405180910390fd5b6116dd3382610d84565b61171c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161171390614c8c565b60405180910390fd5b6115b382611728610cde565b61173291906148cf565b1115611773576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176a9061494f565b60405180910390fd5b81600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117be91906148cf565b60021015611801576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f8906149e1565b60405180910390fd5b61180b3383612bbf565b81600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461185691906148cf565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b6118a561238f565b6040518060600160405280428152602001603c836118c39190614a01565b426118ce91906148cf565b815260200160011515815250600c600082015181600001556020820151816001015560408201518160020160006101000a81548160ff021916908315150217905550905050600115157f5db65beb593b110b71660a4f84d11eef4e452cf0255f5b1ff94258ffac07703660405160405180910390a250565b6060600380546119559061447d565b80601f01602080910402602001604051908101604052809291908181526020018280546119819061447d565b80156119ce5780601f106119a3576101008083540402835291602001916119ce565b820191906000526020600020905b8154815290600101906020018083116119b157829003601f168201915b5050505050905090565b6060818310611a13576040517f32c1995a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806000549050611a2361257f565b851015611a3557611a3261257f565b94505b80841115611a41578093505b6000611a4c8761126e565b905084861015611a6f576000868603905081811015611a69578091505b50611a74565b600090505b60008167ffffffffffffffff811115611a9057611a8f613ada565b5b604051908082528060200260200182016040528015611abe5781602001602082028036833780820191505090505b50905060008203611ad55780945050505050611c90565b6000611ae088611f21565b905060008160400151611af557816000015190505b60008990505b888114158015611b0b5750848714155b15611c8257600460008281526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff16151515158152505092508260400151611c7757600073ffffffffffffffffffffffffffffffffffffffff16836000015173ffffffffffffffffffffffffffffffffffffffff1614611c1c57826000015191505b8a73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611c765780848880600101995081518110611c6957611c68614b39565b5b6020026020010181815250505b5b806001019050611afb565b508583528296505050505050505b9392505050565b611c9f6124c5565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611d03576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060076000611d106124c5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611dbd6124c5565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611e0291906138ef565b60405180910390a35050565b611e19848484612584565b611e388373ffffffffffffffffffffffffffffffffffffffff166131ea565b15611e8057611e498484848461320d565b611e7f576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b50505050565b600080600c60405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900460ff16151515158152505090506000816000015190506000826020015190508163ffffffff164210158015611ef557508063ffffffff164211155b15611f1657428163ffffffff16611f0c9190614cac565b9350505050611f1e565b600093505050505b90565b611f29613724565b611f31613724565b611f3961257f565b831080611f4857506000548310155b15611f565780915050612039565b600460008481526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff161515151581525050905080604001511561202c5780915050612039565b61203583612e99565b9150505b919050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b606061206f82612477565b6120a5576040517fa14c4b5000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006120af61335d565b905060008151036120cf57604051806020016040528060008152506120fa565b806120d984612a5f565b6040516020016120ea929190614ce0565b6040516020818303038152906040525b915050919050565b600c8060000154908060010154908060020160009054906101000a900460ff16905083565b61212f61238f565b601060009054906101000a900460ff1615601060006101000a81548160ff021916908315150217905550601060009054906101000a900460ff1615157ff09b37ecbfe134bf1f6c2f38082fa76cd990d1ffddfb88add51b7c8348c79c4a60405160405180910390a2565b6121a161238f565b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61228161238f565b6040518060600160405280600081526020016000815260200160001515815250600c600082015181600001556020820151816001015560408201518160020160006101000a81548160ff021916908315150217905550905050600015157f5db65beb593b110b71660a4f84d11eef4e452cf0255f5b1ff94258ffac07703660405160405180910390a2565b61231461238f565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612383576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161237a90614d76565b60405180910390fd5b61238c81613124565b50565b6123976124c5565b73ffffffffffffffffffffffffffffffffffffffff166123b561165f565b73ffffffffffffffffffffffffffffffffffffffff161461240b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161240290614de2565b60405180910390fd5b565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008161248261257f565b11158015612491575060005482105b80156124be575060046000838152602001908152602001600020600001601c9054906101000a900460ff16155b9050919050565b600033905090565b826006600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b600090565b600061258f82612e99565b90508373ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff16146125fa576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008473ffffffffffffffffffffffffffffffffffffffff1661261b6124c5565b73ffffffffffffffffffffffffffffffffffffffff16148061264a5750612649856126446124c5565b6121e5565b5b8061268f57506126586124c5565b73ffffffffffffffffffffffffffffffffffffffff1661267784610b5e565b73ffffffffffffffffffffffffffffffffffffffff16145b9050806126c8576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff160361272e576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61273b85858560016133ef565b612747600084876124cd565b6001600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160392506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506001600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600460008581526020019081526020016000209050848160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550428160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060006001850190506000600460008381526020019081526020016000209050600073ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036129c65760005482146129c557878160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084602001518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b505050828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612a3185858560016133f5565b5050505050565b6000806000612a4785856133fb565b91509150612a548161344c565b819250505092915050565b606060008203612aa6576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612bba565b600082905060005b60008214612ad8578080612ac190614e02565b915050600a82612ad19190614e79565b9150612aae565b60008167ffffffffffffffff811115612af457612af3613ada565b5b6040519080825280601f01601f191660200182016040528015612b265781602001600182028036833780820191505090505b5090505b60008514612bb357600182612b3f9190614cac565b9150600a85612b4e9190614eaa565b6030612b5a91906148cf565b60f81b818381518110612b7057612b6f614b39565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612bac9190614e79565b9450612b2a565b8093505050505b919050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603612c2b576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008203612c65576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612c7260008483856133ef565b81600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160088282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550826004600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426004600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000819050600083820190505b818060010192508573ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4808210612e1557816000819055505050612e9460008483856133f5565b505050565b612ea1613724565b600082905080612eaf61257f565b116130ed576000548110156130ec576000600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff161515151581525050905080604001516130ea57600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612fce57809250505061311f565b5b6001156130e957818060019003925050600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff16146130e457809250505061311f565b612fcf565b5b505b5b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60008373ffffffffffffffffffffffffffffffffffffffff1663150b7a026132336124c5565b8786866040518563ffffffff1660e01b81526004016132559493929190614f30565b6020604051808303816000875af192505050801561329157506040513d601f19601f8201168201806040525081019061328e9190614f91565b60015b61330a573d80600081146132c1576040519150601f19603f3d011682016040523d82523d6000602084013e6132c6565b606091505b506000815103613302576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050949350505050565b60606011805461336c9061447d565b80601f01602080910402602001604051908101604052809291908181526020018280546133989061447d565b80156133e55780601f106133ba576101008083540402835291602001916133e5565b820191906000526020600020905b8154815290600101906020018083116133c857829003601f168201915b5050505050905090565b50505050565b50505050565b600080604183510361343c5760008060006020860151925060408601519150606086015160001a905061343087828585613618565b94509450505050613445565b60006002915091505b9250929050565b600060048111156134605761345f614fbe565b5b81600481111561347357613472614fbe565b5b0315613615576001600481111561348d5761348c614fbe565b5b8160048111156134a05761349f614fbe565b5b036134e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016134d790615039565b60405180910390fd5b600260048111156134f4576134f3614fbe565b5b81600481111561350757613506614fbe565b5b03613547576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161353e906150a5565b60405180910390fd5b6003600481111561355b5761355a614fbe565b5b81600481111561356e5761356d614fbe565b5b036135ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135a590615137565b60405180910390fd5b6004808111156135c1576135c0614fbe565b5b8160048111156135d4576135d3614fbe565b5b03613614576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161360b906151c9565b60405180910390fd5b5b50565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c111561365357600060039150915061371b565b601b8560ff161415801561366b5750601c8560ff1614155b1561367d57600060049150915061371b565b6000600187878787604051600081526020016040526040516136a29493929190615205565b6020604051602081039080840390855afa1580156136c4573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036137125760006001925092505061371b565b80600092509250505b94509492505050565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681526020016000151581525090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b61378e8161377b565b811461379957600080fd5b50565b6000813590506137ab81613785565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006137dc826137b1565b9050919050565b6137ec816137d1565b81146137f757600080fd5b50565b600081359050613809816137e3565b92915050565b6000806040838503121561382657613825613771565b5b60006138348582860161379c565b9250506020613845858286016137fa565b9150509250929050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6138848161384f565b811461388f57600080fd5b50565b6000813590506138a18161387b565b92915050565b6000602082840312156138bd576138bc613771565b5b60006138cb84828501613892565b91505092915050565b60008115159050919050565b6138e9816138d4565b82525050565b600060208201905061390460008301846138e0565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015613944578082015181840152602081019050613929565b60008484015250505050565b6000601f19601f8301169050919050565b600061396c8261390a565b6139768185613915565b9350613986818560208601613926565b61398f81613950565b840191505092915050565b600060208201905081810360008301526139b48184613961565b905092915050565b6000602082840312156139d2576139d1613771565b5b60006139e08482850161379c565b91505092915050565b6139f2816137d1565b82525050565b6000602082019050613a0d60008301846139e9565b92915050565b60008060408385031215613a2a57613a29613771565b5b6000613a38858286016137fa565b9250506020613a498582860161379c565b9150509250929050565b613a5c8161377b565b82525050565b6000602082019050613a776000830184613a53565b92915050565b600080600060608486031215613a9657613a95613771565b5b6000613aa4868287016137fa565b9350506020613ab5868287016137fa565b9250506040613ac68682870161379c565b9150509250925092565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b613b1282613950565b810181811067ffffffffffffffff82111715613b3157613b30613ada565b5b80604052505050565b6000613b44613767565b9050613b508282613b09565b919050565b600067ffffffffffffffff821115613b7057613b6f613ada565b5b613b7982613950565b9050602081019050919050565b82818337600083830152505050565b6000613ba8613ba384613b55565b613b3a565b905082815260208101848484011115613bc457613bc3613ad5565b5b613bcf848285613b86565b509392505050565b600082601f830112613bec57613beb613ad0565b5b8135613bfc848260208601613b95565b91505092915050565b60008060408385031215613c1c57613c1b613771565b5b6000613c2a858286016137fa565b925050602083013567ffffffffffffffff811115613c4b57613c4a613776565b5b613c5785828601613bd7565b9150509250929050565b600080fd5b600080fd5b60008083601f840112613c8157613c80613ad0565b5b8235905067ffffffffffffffff811115613c9e57613c9d613c61565b5b602083019150836001820283011115613cba57613cb9613c66565b5b9250929050565b60008060208385031215613cd857613cd7613771565b5b600083013567ffffffffffffffff811115613cf657613cf5613776565b5b613d0285828601613c6b565b92509250509250929050565b600067ffffffffffffffff821115613d2957613d28613ada565b5b602082029050602081019050919050565b6000613d4d613d4884613d0e565b613b3a565b90508083825260208201905060208402830185811115613d7057613d6f613c66565b5b835b81811015613d995780613d85888261379c565b845260208401935050602081019050613d72565b5050509392505050565b600082601f830112613db857613db7613ad0565b5b8135613dc8848260208601613d3a565b91505092915050565b600060208284031215613de757613de6613771565b5b600082013567ffffffffffffffff811115613e0557613e04613776565b5b613e1184828501613da3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b613e4f816137d1565b82525050565b600067ffffffffffffffff82169050919050565b613e7281613e55565b82525050565b613e81816138d4565b82525050565b606082016000820151613e9d6000850182613e46565b506020820151613eb06020850182613e69565b506040820151613ec36040850182613e78565b50505050565b6000613ed58383613e87565b60608301905092915050565b6000602082019050919050565b6000613ef982613e1a565b613f038185613e25565b9350613f0e83613e36565b8060005b83811015613f3f578151613f268882613ec9565b9750613f3183613ee1565b925050600181019050613f12565b5085935050505092915050565b60006020820190508181036000830152613f668184613eee565b905092915050565b600060208284031215613f8457613f83613771565b5b6000613f92848285016137fa565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b613fd08161377b565b82525050565b6000613fe28383613fc7565b60208301905092915050565b6000602082019050919050565b600061400682613f9b565b6140108185613fa6565b935061401b83613fb7565b8060005b8381101561404c5781516140338882613fd6565b975061403e83613fee565b92505060018101905061401f565b5085935050505092915050565b600060208201905081810360008301526140738184613ffb565b905092915050565b6000806040838503121561409257614091613771565b5b60006140a08582860161379c565b925050602083013567ffffffffffffffff8111156140c1576140c0613776565b5b6140cd85828601613bd7565b9150509250929050565b6000806000606084860312156140f0576140ef613771565b5b60006140fe868287016137fa565b935050602061410f8682870161379c565b92505060406141208682870161379c565b9150509250925092565b614133816138d4565b811461413e57600080fd5b50565b6000813590506141508161412a565b92915050565b6000806040838503121561416d5761416c613771565b5b600061417b858286016137fa565b925050602061418c85828601614141565b9150509250929050565b600080600080608085870312156141b0576141af613771565b5b60006141be878288016137fa565b94505060206141cf878288016137fa565b93505060406141e08782880161379c565b925050606085013567ffffffffffffffff81111561420157614200613776565b5b61420d87828801613bd7565b91505092959194509250565b60608201600082015161422f6000850182613e46565b5060208201516142426020850182613e69565b5060408201516142556040850182613e78565b50505050565b60006060820190506142706000830184614219565b92915050565b600060608201905061428b6000830186613a53565b6142986020830185613a53565b6142a560408301846138e0565b949350505050565b600080604083850312156142c4576142c3613771565b5b60006142d2858286016137fa565b92505060206142e3858286016137fa565b9150509250929050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b6000614323601f83613915565b915061432e826142ed565b602082019050919050565b6000602082019050818103600083015261435281614316565b9050919050565b7f4e6f7420656e6f7567682045544820746f207769746864726177210000000000600082015250565b600061438f601b83613915565b915061439a82614359565b602082019050919050565b600060208201905081810360008301526143be81614382565b9050919050565b600081905092915050565b50565b60006143e06000836143c5565b91506143eb826143d0565b600082019050919050565b6000614401826143d3565b9150819050919050565b6000614418600083613915565b9150614423826143d0565b600082019050919050565b600060208201905081810360008301526144478161440b565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061449557607f821691505b6020821081036144a8576144a761444e565b5b50919050565b6000819050919050565b6144c1816144ae565b82525050565b60006060820190506144dc60008301866144b8565b6144e960208301856139e9565b6144f660408301846144b8565b949350505050565b600081905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b600061453f6002836144fe565b915061454a82614509565b600282019050919050565b6000819050919050565b61457061456b826144ae565b614555565b82525050565b600061458182614532565b915061458d828561455f565b60208201915061459d828461455f565b6020820191508190509392505050565b600082905092915050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b60006008830261461a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826145dd565b61462486836145dd565b95508019841693508086168417925050509392505050565b6000819050919050565b600061466161465c6146578461377b565b61463c565b61377b565b9050919050565b6000819050919050565b61467b83614646565b61468f61468782614668565b8484546145ea565b825550505050565b600090565b6146a4614697565b6146af818484614672565b505050565b5b818110156146d3576146c860008261469c565b6001810190506146b5565b5050565b601f821115614718576146e9816145b8565b6146f2846145cd565b81016020851015614701578190505b61471561470d856145cd565b8301826146b4565b50505b505050565b600082821c905092915050565b600061473b6000198460080261471d565b1980831691505092915050565b6000614754838361472a565b9150826002028217905092915050565b61476e83836145ad565b67ffffffffffffffff81111561478757614786613ada565b5b614791825461447d565b61479c8282856146d7565b6000601f8311600181146147cb57600084156147b9578287013590505b6147c38582614748565b86555061482b565b601f1984166147d9866145b8565b60005b82811015614801578489013582556001820191506020850194506020810190506147dc565b8683101561481e578489013561481a601f89168261472a565b8355505b6001600288020188555050505b50505050505050565b7f5075626c69632073616c65206973206e6f74206f6e0000000000000000000000600082015250565b600061486a601583613915565b915061487582614834565b602082019050919050565b600060208201905081810360008301526148998161485d565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006148da8261377b565b91506148e58361377b565b92508282019050808211156148fd576148fc6148a0565b5b92915050565b7f43616e2774206d696e74206d6f7265207468616e206d617820746f6b656e7300600082015250565b6000614939601f83613915565b915061494482614903565b602082019050919050565b600060208201905081810360008301526149688161492c565b9050919050565b7f4d617820746f6b656e20636f756e74207065722077616c6c657420657863656560008201527f6465642100000000000000000000000000000000000000000000000000000000602082015250565b60006149cb602483613915565b91506149d68261496f565b604082019050919050565b600060208201905081810360008301526149fa816149be565b9050919050565b6000614a0c8261377b565b9150614a178361377b565b9250828202614a258161377b565b91508282048414831517614a3c57614a3b6148a0565b5b5092915050565b7f4e6f7420656e6f7567682045544821204174206c656173742000000000000000600082015250565b6000614a796019836144fe565b9150614a8482614a43565b601982019050919050565b6000614a9a8261390a565b614aa481856144fe565b9350614ab4818560208601613926565b80840191505092915050565b7f207765692068617320746f2062652073656e7421000000000000000000000000600082015250565b6000614af66014836144fe565b9150614b0182614ac0565b601482019050919050565b6000614b1782614a6c565b9150614b238284614a8f565b9150614b2e82614ae9565b915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f43616e2774206d696e74206d6f7265207468616e206d617820737570706c7900600082015250565b6000614b9e601f83613915565b9150614ba982614b68565b602082019050919050565b60006020820190508181036000830152614bcd81614b91565b9050919050565b7f416c6c6f776c6973742073616c65206973206e6f742061637469766500000000600082015250565b6000614c0a601c83613915565b9150614c1582614bd4565b602082019050919050565b60006020820190508181036000830152614c3981614bfd565b9050919050565b7f41646472657373206973206e6f7420696e20616c6c6f776c6973740000000000600082015250565b6000614c76601b83613915565b9150614c8182614c40565b602082019050919050565b60006020820190508181036000830152614ca581614c69565b9050919050565b6000614cb78261377b565b9150614cc28361377b565b9250828203905081811115614cda57614cd96148a0565b5b92915050565b6000614cec8285614a8f565b9150614cf88284614a8f565b91508190509392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614d60602683613915565b9150614d6b82614d04565b604082019050919050565b60006020820190508181036000830152614d8f81614d53565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000614dcc602083613915565b9150614dd782614d96565b602082019050919050565b60006020820190508181036000830152614dfb81614dbf565b9050919050565b6000614e0d8261377b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614e3f57614e3e6148a0565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000614e848261377b565b9150614e8f8361377b565b925082614e9f57614e9e614e4a565b5b828204905092915050565b6000614eb58261377b565b9150614ec08361377b565b925082614ed057614ecf614e4a565b5b828206905092915050565b600081519050919050565b600082825260208201905092915050565b6000614f0282614edb565b614f0c8185614ee6565b9350614f1c818560208601613926565b614f2581613950565b840191505092915050565b6000608082019050614f4560008301876139e9565b614f5260208301866139e9565b614f5f6040830185613a53565b8181036060830152614f718184614ef7565b905095945050505050565b600081519050614f8b8161387b565b92915050565b600060208284031215614fa757614fa6613771565b5b6000614fb584828501614f7c565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b6000615023601883613915565b915061502e82614fed565b602082019050919050565b6000602082019050818103600083015261505281615016565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b600061508f601f83613915565b915061509a82615059565b602082019050919050565b600060208201905081810360008301526150be81615082565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b6000615121602283613915565b915061512c826150c5565b604082019050919050565b6000602082019050818103600083015261515081615114565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b60006151b3602283613915565b91506151be82615157565b604082019050919050565b600060208201905081810360008301526151e2816151a6565b9050919050565b600060ff82169050919050565b6151ff816151e9565b82525050565b600060808201905061521a60008301876144b8565b61522760208301866151f6565b61523460408301856144b8565b61524160608301846144b8565b9594505050505056fea264697066735822122093307938c8f90ee5880a25af00d924b7d5099a50e4aac1f2250859e2e098840964736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: No
ECDSA.sol 218 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
Strings.sol 75 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
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);
}
}
ERC721A.sol 612 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v3.3.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import './IERC721A.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension. Built to optimize for lower gas during batch mints.
*
* Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..).
*
* Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
*
* Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is Context, ERC165, IERC721A {
using Address for address;
using Strings for uint256;
// The tokenId of the next token to be minted.
uint256 internal _currentIndex;
// The number of tokens burned.
uint256 internal _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 _ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
}
/**
* To change the starting tokenId, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens.
*/
function totalSupply() public view override returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than _currentIndex - _startTokenId() times
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
/**
* Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view returns (uint256) {
// Counter underflow is impossible as _currentIndex does not decrement,
// and it is initialized to _startTokenId()
unchecked {
return _currentIndex - _startTokenId();
}
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return uint256(_addressData[owner].balance);
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return uint256(_addressData[owner].numberMinted);
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return uint256(_addressData[owner].numberBurned);
}
/**
* Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return _addressData[owner].aux;
}
/**
* Sets the auxillary 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 {
_addressData[owner].aux = aux;
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr) if (curr < _currentIndex) {
TokenOwnership memory ownership = _ownerships[curr];
if (!ownership.burned) {
if (ownership.addr != address(0)) {
return ownership;
}
// Invariant:
// There will always be an ownership that has an address and is not burned
// before an ownership that does not have an address and is not burned.
// Hence, curr will not underflow.
while (true) {
curr--;
ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return _ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = ERC721A.ownerOf(tokenId);
if (to == owner) revert ApprovalToCurrentOwner();
if (_msgSender() != owner) if(!isApprovedForAll(owner, _msgSender())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
if (operator == _msgSender()) revert ApproveToCaller();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
_transfer(from, to, tokenId);
if (to.isContract()) if(!_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned;
}
/**
* @dev Equivalent to `_safeMint(to, quantity, '')`.
*/
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, 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.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
uint256 end = updatedIndex + quantity;
if (to.isContract()) {
do {
emit Transfer(address(0), to, updatedIndex);
if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (updatedIndex < end);
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
} else {
do {
emit Transfer(address(0), to, updatedIndex++);
} while (updatedIndex < end);
}
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @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.
*/
function _mint(address to, uint256 quantity) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
uint256 end = updatedIndex + quantity;
do {
emit Transfer(address(0), to, updatedIndex++);
} while (updatedIndex < end);
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, from);
// 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 {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = to;
currSlot.startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @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 {
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
address from = prevOwnership.addr;
if (approvalCheck) {
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, from);
// 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 {
AddressData storage addressData = _addressData[from];
addressData.balance -= 1;
addressData.numberBurned += 1;
// Keep track of who burned the token, and the timestamp of burning.
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = from;
currSlot.startTimestamp = uint64(block.timestamp);
currSlot.burned = true;
// If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
/**
* @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 {}
}
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;
}
}
IERC721AQueryable.sol 73 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v3.3.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import '../IERC721A.sol';
/**
* @dev Interface of an ERC721AQueryable compliant contract.
*/
interface IERC721AQueryable is IERC721A {
/**
* Invalid query range (`start` >= `stop`).
*/
error InvalidQueryRange();
/**
* @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.
*
* If the `tokenId` is out of bounds:
* - `addr` = `address(0)`
* - `startTimestamp` = `0`
* - `burned` = `false`
*
* If the `tokenId` is burned:
* - `addr` = `<Address of owner before token was burned>`
* - `startTimestamp` = `<Timestamp when token was burned>`
* - `burned = `true`
*
* Otherwise:
* - `addr` = `<Address of owner>`
* - `startTimestamp` = `<Timestamp of start of ownership>`
* - `burned = `false`
*/
function explicitOwnershipOf(uint256 tokenId) external view returns (TokenOwnership memory);
/**
* @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order.
* See {ERC721AQueryable-explicitOwnershipOf}
*/
function explicitOwnershipsOf(uint256[] memory tokenIds) external view returns (TokenOwnership[] memory);
/**
* @dev Returns an array of token IDs owned by `owner`,
* in the range [`start`, `stop`)
* (i.e. `start <= tokenId < stop`).
*
* This function allows for tokens to be queried if the collection
* grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
*
* Requirements:
*
* - `start` < `stop`
*/
function tokensOfOwnerIn(
address owner,
uint256 start,
uint256 stop
) external view returns (uint256[] memory);
/**
* @dev Returns an array of token IDs owned by `owner`.
*
* This function scans the ownership mapping and is O(totalSupply) in complexity.
* It is meant to be called off-chain.
*
* See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
* multiple smaller scans if the collection is large enough to cause
* an out-of-gas error (10K pfp collections should be fine).
*/
function tokensOfOwner(address owner) external view returns (uint256[] memory);
}
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;
}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev 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);
}
tsukimi.sol 205 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "./ERC721A.sol";
import "./ERC721AQueryable.sol";
contract Tsukimi is ERC721A, ERC721AQueryable, Ownable, ReentrancyGuard {
constructor() ERC721A("Tsukimi", "TSUKIMI") {}
event AllowlistSale(bool indexed _type);
event PublicSale(bool indexed _type);
mapping (address => uint256) private tokenBalance;
address public allowlistSigner = 0x51F62DaA652D1827e6912d1B582F9d33Db465CfA;
struct AllowlistSaleConfig {
uint256 allowlistSaleStartTime;
uint256 allowlistSaleEndTime;
bool allowlistStarted;
}
AllowlistSaleConfig public allowlistSaleConfig;
using ECDSA for bytes32;
bytes32 private DOMAIN_VERIFICATION =
keccak256(
abi.encode(
keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
),
keccak256(bytes("TsukimiLoft")),
keccak256(bytes("1")),
1,
address(this)
)
);
bool public isPublicSaleOn = false;
string private _baseTokenURI;
function isAllowlisted(address buyerWalletAddress, bytes memory _signature)
public
view
returns (bool)
{
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_VERIFICATION,
keccak256(
abi.encode(
keccak256(
"daydreamers(address buyerWalletAddress,string saleType)"
),
buyerWalletAddress,
keccak256(bytes("allowlistSale"))
)
)
)
);
return
ECDSA.recover(digest, _signature) == allowlistSigner ? true : false;
}
// sets allowlist signer
function setAllowlistSigner(address _allowlistSigner) external onlyOwner {
allowlistSigner = _allowlistSigner;
}
// toggles public sale
function togglePublicSale() public onlyOwner {
isPublicSaleOn = !isPublicSaleOn;
emit PublicSale(isPublicSaleOn);
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
// sets base URI
function setBaseURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
// starts allowlist sale
function startAllowListSale(uint256 _durationInMinutes) external onlyOwner {
allowlistSaleConfig = AllowlistSaleConfig(
block.timestamp,
block.timestamp + (_durationInMinutes * 60),
true
);
emit AllowlistSale(true);
}
function stopAllowlistSale() external onlyOwner {
allowlistSaleConfig = AllowlistSaleConfig(0, 0, false);
emit AllowlistSale(false);
}
function allowListStarted() public view returns (bool) {
AllowlistSaleConfig memory config = allowlistSaleConfig;
return config.allowlistStarted;
}
function allowListTimeLeft() public view returns (uint256) {
// returns time left in seconds
AllowlistSaleConfig memory config = allowlistSaleConfig;
uint32 startTime = uint32(config.allowlistSaleStartTime);
uint32 endTime = uint32(config.allowlistSaleEndTime);
if (block.timestamp >= startTime && block.timestamp <= endTime) {
return endTime - block.timestamp;
}
return 0;
}
// dev mints
function devMint(address _address, uint256 _amount) external onlyOwner {
require(
totalSupply() + _amount <= 5555,
"Can't mint more than max supply"
);
_mint(_address, _amount);
}
function AllowlistMint(uint256 _amount, bytes memory _signature)
public
payable
{
require(allowListTimeLeft() > 0, "Allowlist sale is not active");
require(
isAllowlisted(msg.sender, _signature),
"Address is not in allowlist"
);
require(
totalSupply() + _amount <= 5555,
"Can't mint more than max tokens"
);
require(
2 >= tokenBalance[msg.sender] + _amount,
"Max token count per wallet exceeded!"
);
_mint(msg.sender, _amount);
tokenBalance[msg.sender]=tokenBalance[msg.sender]+_amount;
}
function mintPublicSale(uint256 _amount) public payable {
require(isPublicSaleOn, "Public sale is not on");
require(
totalSupply() + _amount <= 5555,
"Can't mint more than max tokens"
);
require(
2 >= tokenBalance[msg.sender] + _amount,
"Max token count per wallet exceeded!"
);
require(
msg.value >= 0.02 ether * _amount,
string(
abi.encodePacked(
"Not enough ETH! At least ",
Strings.toString(0.02 ether * _amount),
" wei has to be sent!"
)
)
);
_mint(msg.sender, _amount);
tokenBalance[msg.sender]=tokenBalance[msg.sender]+_amount;
}
function withdrawAll() public onlyOwner nonReentrant {
(bool success, ) = payable(owner()).call{value: address(this).balance}(
""
);
require(success, "");
}
function withdraw(uint256 _weiAmount, address _to)
public
onlyOwner
nonReentrant
{
require(
address(this).balance >= _weiAmount,
"Not enough ETH to withdraw!"
);
(bool success, ) = payable(_to).call{value: _weiAmount}("");
require(success, "");
}
}
ERC721AQueryable.sol 165 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v3.3.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import './IERC721AQueryable.sol';
import '../ERC721A.sol';
/**
* @title ERC721A Queryable
* @dev ERC721A subclass with convenience query functions.
*/
abstract contract ERC721AQueryable is ERC721A, IERC721AQueryable {
/**
* @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.
*
* If the `tokenId` is out of bounds:
* - `addr` = `address(0)`
* - `startTimestamp` = `0`
* - `burned` = `false`
*
* If the `tokenId` is burned:
* - `addr` = `<Address of owner before token was burned>`
* - `startTimestamp` = `<Timestamp when token was burned>`
* - `burned = `true`
*
* Otherwise:
* - `addr` = `<Address of owner>`
* - `startTimestamp` = `<Timestamp of start of ownership>`
* - `burned = `false`
*/
function explicitOwnershipOf(uint256 tokenId) public view override returns (TokenOwnership memory) {
TokenOwnership memory ownership;
if (tokenId < _startTokenId() || tokenId >= _currentIndex) {
return ownership;
}
ownership = _ownerships[tokenId];
if (ownership.burned) {
return ownership;
}
return _ownershipOf(tokenId);
}
/**
* @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order.
* See {ERC721AQueryable-explicitOwnershipOf}
*/
function explicitOwnershipsOf(uint256[] memory tokenIds) external view override returns (TokenOwnership[] memory) {
unchecked {
uint256 tokenIdsLength = tokenIds.length;
TokenOwnership[] memory ownerships = new TokenOwnership[](tokenIdsLength);
for (uint256 i; i != tokenIdsLength; ++i) {
ownerships[i] = explicitOwnershipOf(tokenIds[i]);
}
return ownerships;
}
}
/**
* @dev Returns an array of token IDs owned by `owner`,
* in the range [`start`, `stop`)
* (i.e. `start <= tokenId < stop`).
*
* This function allows for tokens to be queried if the collection
* grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
*
* Requirements:
*
* - `start` < `stop`
*/
function tokensOfOwnerIn(
address owner,
uint256 start,
uint256 stop
) external view override returns (uint256[] memory) {
unchecked {
if (start >= stop) revert InvalidQueryRange();
uint256 tokenIdsIdx;
uint256 stopLimit = _currentIndex;
// Set `start = max(start, _startTokenId())`.
if (start < _startTokenId()) {
start = _startTokenId();
}
// Set `stop = min(stop, _currentIndex)`.
if (stop > stopLimit) {
stop = stopLimit;
}
uint256 tokenIdsMaxLength = balanceOf(owner);
// Set `tokenIdsMaxLength = min(balanceOf(owner), stop - start)`,
// to cater for cases where `balanceOf(owner)` is too big.
if (start < stop) {
uint256 rangeLength = stop - start;
if (rangeLength < tokenIdsMaxLength) {
tokenIdsMaxLength = rangeLength;
}
} else {
tokenIdsMaxLength = 0;
}
uint256[] memory tokenIds = new uint256[](tokenIdsMaxLength);
if (tokenIdsMaxLength == 0) {
return tokenIds;
}
// We need to call `explicitOwnershipOf(start)`,
// because the slot at `start` may not be initialized.
TokenOwnership memory ownership = explicitOwnershipOf(start);
address currOwnershipAddr;
// If the starting slot exists (i.e. not burned), initialize `currOwnershipAddr`.
// `ownership.address` will not be zero, as `start` is clamped to the valid token ID range.
if (!ownership.burned) {
currOwnershipAddr = ownership.addr;
}
for (uint256 i = start; i != stop && tokenIdsIdx != tokenIdsMaxLength; ++i) {
ownership = _ownerships[i];
if (ownership.burned) {
continue;
}
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
// Downsize the array to fit.
assembly {
mstore(tokenIds, tokenIdsIdx)
}
return tokenIds;
}
}
/**
* @dev Returns an array of token IDs owned by `owner`.
*
* This function scans the ownership mapping and is O(totalSupply) in complexity.
* It is meant to be called off-chain.
*
* See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
* multiple smaller scans if the collection is large enough to cause
* an out-of-gas error (10K pfp collections should be fine).
*/
function tokensOfOwner(address owner) external view override returns (uint256[] memory) {
unchecked {
uint256 tokenIdsIdx;
address currOwnershipAddr;
uint256 tokenIdsLength = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
TokenOwnership memory ownership;
for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
ownership = _ownerships[i];
if (ownership.burned) {
continue;
}
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
return tokenIds;
}
}
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
IERC721A.sol 109 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v3.3.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
/**
* @dev Interface of an ERC721A compliant contract.
*/
interface IERC721A is IERC721, IERC721Metadata {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* The caller cannot approve to their own address.
*/
error ApproveToCaller();
/**
* The caller cannot approve to the current owner.
*/
error ApprovalToCurrentOwner();
/**
* 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();
// Compiler will pack this into a single 256bit word.
struct TokenOwnership {
// The address of the owner.
address addr;
// Keeps track of the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
}
// Compiler will pack this into a single 256bit word.
struct AddressData {
// Realistically, 2**64-1 is more than enough.
uint64 balance;
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
// For miscellaneous variable(s) pertaining to the address
// (e.g. number of whitelist mint slots used).
// If there are multiple variables, please pack them into a uint64.
uint64 aux;
}
/**
* @dev Returns the total amount of tokens stored by the contract.
*
* Burned tokens are calculated here, use `_totalMinted()` if you want to count just minted tokens.
*/
function totalSupply() external view returns (uint256);
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Read Contract
allowListStarted 0x49985a79 → bool
allowListTimeLeft 0xc12f0396 → uint256
allowlistSaleConfig 0xd5e2eb55 → uint256, uint256, bool
allowlistSigner 0xc32fe11b → address
balanceOf 0x70a08231 → uint256
explicitOwnershipOf 0xc23dc68f → tuple
explicitOwnershipsOf 0x5bbb2177 → tuple[]
getApproved 0x081812fc → address
isAllowlisted 0x50cee227 → bool
isApprovedForAll 0xe985e9c5 → bool
isPublicSaleOn 0x3f5e4741 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
tokensOfOwner 0x8462151c → uint256[]
tokensOfOwnerIn 0x99a2557a → uint256[]
totalSupply 0x18160ddd → uint256
Write Contract 17 functions
These functions modify contract state and require a wallet transaction to execute.
AllowlistMint 0x92ed4b10
uint256 _amount
bytes _signature
approve 0x095ea7b3
address to
uint256 tokenId
devMint 0x627804af
address _address
uint256 _amount
mintPublicSale 0x5a5e5d58
uint256 _amount
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setAllowlistSigner 0xe474def4
address _allowlistSigner
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string baseURI
startAllowListSale 0x92f6f745
uint256 _durationInMinutes
stopAllowlistSale 0xebc90e1b
No parameters
togglePublicSale 0xe222c7f9
No parameters
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x00f714ce
uint256 _weiAmount
address _to
withdrawAll 0x853828b6
No parameters
Recent Transactions
No transactions found for this address