Address Contract Verified
Address
0xA8BDf98e632e9d223DEA24Ce0B7f4d7C035170D6
Balance
0 ETH
Nonce
1
Code Size
18036 bytes
Creator
0xdBF83E88...858e at tx 0x021ebf4a...96a6d1
Indexed Transactions
0
Contract Bytecode
18036 bytes
0x6080604052600436106101d85760003560e01c80636352211e1161010257806398d5fdca11610095578063c87b56dd11610064578063c87b56dd14610675578063e985e9c5146106b2578063eb8d2444146106ef578063f2fde38b1461071a576101d8565b806398d5fdca146105e1578063a22cb4651461060c578063b66a0e5d14610635578063b88d4fde1461064c576101d8565b806377097fc8116100d157806377097fc8146105465780638da5cb5b1461056257806391b7f5ed1461058d57806395d89b41146105b6576101d8565b80636352211e1461048a57806370a08231146104c75780637146bd0814610504578063715018a61461052f576101d8565b80632f745c591161017a578063438b630011610149578063438b6300146103d05780634f6ccce71461040d57806355367ba91461044a57806355f804b314610461576101d8565b80632f745c591461032857806332cb6b0c146103655780633ccfd60b1461039057806342842e0e146103a7576101d8565b8063095ea7b3116101b6578063095ea7b3146102825780631703030e146102ab57806318160ddd146102d457806323b872dd146102ff576101d8565b806301ffc9a7146101dd57806306fdde031461021a578063081812fc14610245575b600080fd5b3480156101e957600080fd5b5061020460048036038101906101ff9190613098565b610743565b6040516102119190613715565b60405180910390f35b34801561022657600080fd5b5061022f6107bd565b60405161023c9190613730565b60405180910390f35b34801561025157600080fd5b5061026c6004803603810190610267919061312b565b61084f565b604051610279919061368c565b60405180910390f35b34801561028e57600080fd5b506102a960048036038101906102a49190612ff5565b6108d4565b005b3480156102b757600080fd5b506102d260048036038101906102cd9190613031565b6109ec565b005b3480156102e057600080fd5b506102e9610b89565b6040516102f69190613aa2565b60405180910390f35b34801561030b57600080fd5b5061032660048036038101906103219190612eef565b610b96565b005b34801561033457600080fd5b5061034f600480360381019061034a9190612ff5565b610bf6565b60405161035c9190613aa2565b60405180910390f35b34801561037157600080fd5b5061037a610c9b565b6040516103879190613aa2565b60405180910390f35b34801561039c57600080fd5b506103a5610ca1565b005b3480156103b357600080fd5b506103ce60048036038101906103c99190612eef565b610d85565b005b3480156103dc57600080fd5b506103f760048036038101906103f29190612e8a565b610da5565b60405161040491906136f3565b60405180910390f35b34801561041957600080fd5b50610434600480360381019061042f919061312b565b610e9f565b6040516104419190613aa2565b60405180910390f35b34801561045657600080fd5b5061045f610f36565b005b34801561046d57600080fd5b50610488600480360381019061048391906130ea565b611025565b005b34801561049657600080fd5b506104b160048036038101906104ac919061312b565b6110bb565b6040516104be919061368c565b60405180910390f35b3480156104d357600080fd5b506104ee60048036038101906104e99190612e8a565b61116d565b6040516104fb9190613aa2565b60405180910390f35b34801561051057600080fd5b50610519611225565b6040516105269190613aa2565b60405180910390f35b34801561053b57600080fd5b5061054461122a565b005b610560600480360381019061055b9190613154565b6112b2565b005b34801561056e57600080fd5b506105776114b4565b604051610584919061368c565b60405180910390f35b34801561059957600080fd5b506105b460048036038101906105af919061312b565b6114de565b005b3480156105c257600080fd5b506105cb611564565b6040516105d89190613730565b60405180910390f35b3480156105ed57600080fd5b506105f66115f6565b6040516106039190613aa2565b60405180910390f35b34801561061857600080fd5b50610633600480360381019061062e9190612fb9565b611600565b005b34801561064157600080fd5b5061064a611781565b005b34801561065857600080fd5b50610673600480360381019061066e9190612f3e565b611870565b005b34801561068157600080fd5b5061069c6004803603810190610697919061312b565b6118d2565b6040516106a99190613730565b60405180910390f35b3480156106be57600080fd5b506106d960048036038101906106d49190612eb3565b611979565b6040516106e69190613715565b60405180910390f35b3480156106fb57600080fd5b50610704611a0d565b6040516107119190613715565b60405180910390f35b34801561072657600080fd5b50610741600480360381019061073c9190612e8a565b611a20565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806107b657506107b582611b18565b5b9050919050565b6060600080546107cc90613dd7565b80601f01602080910402602001604051908101604052809291908181526020018280546107f890613dd7565b80156108455780601f1061081a57610100808354040283529160200191610845565b820191906000526020600020905b81548152906001019060200180831161082857829003601f168201915b5050505050905090565b600061085a82611bfa565b610899576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161089090613962565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006108df826110bb565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610950576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094790613a02565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661096f611c66565b73ffffffffffffffffffffffffffffffffffffffff16148061099e575061099d81610998611c66565b611979565b5b6109dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109d490613882565b60405180910390fd5b6109e78383611c6e565b505050565b6109f4611c66565b73ffffffffffffffffffffffffffffffffffffffff16610a126114b4565b73ffffffffffffffffffffffffffffffffffffffff1614610a68576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a5f906139a2565b60405180910390fd5b600e54821115610aad576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aa490613a62565b60405180910390fd5b6000610ab7610b89565b905060005b83811015610b2c5760008183610ad29190613c0c565b9050610ade8682611d27565b807f983d37d8751fcfa80e95e5fe2c0f46fb7b541b280961dc7ac00aa2670e2edd878533604051610b10929190613752565b60405180910390a2508080610b2490613e3a565b915050610abc565b5082600e6000828254610b3f9190613ced565b925050819055507f180c796e1186ac67f477f3cf028fab42df1a095a05d042eb00f7c250484705da81848433604051610b7b9493929190613abd565b60405180910390a150505050565b6000600880549050905090565b610ba7610ba1611c66565b82611d45565b610be6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bdd90613a42565b60405180910390fd5b610bf1838383611e23565b505050565b6000610c018361116d565b8210610c42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3990613782565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b6107d081565b610ca9611c66565b73ffffffffffffffffffffffffffffffffffffffff16610cc76114b4565b73ffffffffffffffffffffffffffffffffffffffff1614610d1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d14906139a2565b60405180910390fd5b6000479050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050610d8257600080fd5b50565b610da083838360405180602001604052806000815250611870565b505050565b60606000610db28361116d565b905060008167ffffffffffffffff811115610df6577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015610e245781602001602082028036833780820191505090505b50905060005b82811015610e9457610e3c8582610bf6565b828281518110610e75577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010181815250508080610e8c90613e3a565b915050610e2a565b508092505050919050565b6000610ea9610b89565b8210610eea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee190613a82565b60405180910390fd5b60088281548110610f24577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610f3e611c66565b73ffffffffffffffffffffffffffffffffffffffff16610f5c6114b4565b73ffffffffffffffffffffffffffffffffffffffff1614610fb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa9906139a2565b60405180910390fd5b60011515600d60009054906101000a900460ff16151514611008576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fff90613922565b60405180910390fd5b6000600d60006101000a81548160ff021916908315150217905550565b61102d611c66565b73ffffffffffffffffffffffffffffffffffffffff1661104b6114b4565b73ffffffffffffffffffffffffffffffffffffffff16146110a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611098906139a2565b60405180910390fd5b80600b90805190602001906110b7929190612cae565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611164576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115b906138c2565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111d5906138a2565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b601481565b611232611c66565b73ffffffffffffffffffffffffffffffffffffffff166112506114b4565b73ffffffffffffffffffffffffffffffffffffffff16146112a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129d906139a2565b60405180910390fd5b6112b0600061207f565b565b60006112bc610b89565b9050600d60009054906101000a900460ff1661130d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130490613a22565b60405180910390fd5b6014831115611351576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134890613862565b60405180910390fd5b600e546107d06113619190613ced565b838261136d9190613c0c565b11156113ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a590613982565b60405180910390fd5b82600c546113bc9190613c93565b3410156113fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113f590613902565b60405180910390fd5b60005b8381101561147157600081836114179190613c0c565b90506114233382611d27565b807f983d37d8751fcfa80e95e5fe2c0f46fb7b541b280961dc7ac00aa2670e2edd878533604051611455929190613752565b60405180910390a250808061146990613e3a565b915050611401565b507f180c796e1186ac67f477f3cf028fab42df1a095a05d042eb00f7c250484705da818484336040516114a79493929190613abd565b60405180910390a1505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6114e6611c66565b73ffffffffffffffffffffffffffffffffffffffff166115046114b4565b73ffffffffffffffffffffffffffffffffffffffff161461155a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611551906139a2565b60405180910390fd5b80600c8190555050565b60606001805461157390613dd7565b80601f016020809104026020016040519081016040528092919081815260200182805461159f90613dd7565b80156115ec5780601f106115c1576101008083540402835291602001916115ec565b820191906000526020600020905b8154815290600101906020018083116115cf57829003601f168201915b5050505050905090565b6000600c54905090565b611608611c66565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611676576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166d90613822565b60405180910390fd5b8060056000611683611c66565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611730611c66565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516117759190613715565b60405180910390a35050565b611789611c66565b73ffffffffffffffffffffffffffffffffffffffff166117a76114b4565b73ffffffffffffffffffffffffffffffffffffffff16146117fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f4906139a2565b60405180910390fd5b60001515600d60009054906101000a900460ff16151514611853576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161184a906138e2565b60405180910390fd5b6001600d60006101000a81548160ff021916908315150217905550565b61188161187b611c66565b83611d45565b6118c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118b790613a42565b60405180910390fd5b6118cc84848484612145565b50505050565b60606118dd82611bfa565b61191c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611913906139e2565b60405180910390fd5b60006119266121a1565b905060008151116119465760405180602001604052806000815250611971565b8061195084612233565b604051602001611961929190613668565b6040516020818303038152906040525b915050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600d60009054906101000a900460ff1681565b611a28611c66565b73ffffffffffffffffffffffffffffffffffffffff16611a466114b4565b73ffffffffffffffffffffffffffffffffffffffff1614611a9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a93906139a2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611b0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b03906137c2565b60405180910390fd5b611b158161207f565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611be357507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611bf35750611bf2826123e0565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611ce1836110bb565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b611d4182826040518060200160405280600081525061244a565b5050565b6000611d5082611bfa565b611d8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d8690613842565b60405180910390fd5b6000611d9a836110bb565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611e0957508373ffffffffffffffffffffffffffffffffffffffff16611df18461084f565b73ffffffffffffffffffffffffffffffffffffffff16145b80611e1a5750611e198185611979565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611e43826110bb565b73ffffffffffffffffffffffffffffffffffffffff1614611e99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e90906139c2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611f09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f0090613802565b60405180910390fd5b611f148383836124a5565b611f1f600082611c6e565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611f6f9190613ced565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611fc69190613c0c565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b612150848484611e23565b61215c848484846125b9565b61219b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612192906137a2565b60405180910390fd5b50505050565b6060600b80546121b090613dd7565b80601f01602080910402602001604051908101604052809291908181526020018280546121dc90613dd7565b80156122295780601f106121fe57610100808354040283529160200191612229565b820191906000526020600020905b81548152906001019060200180831161220c57829003601f168201915b5050505050905090565b6060600082141561227b576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506123db565b600082905060005b600082146122ad57808061229690613e3a565b915050600a826122a69190613c62565b9150612283565b60008167ffffffffffffffff8111156122ef577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156123215781602001600182028036833780820191505090505b5090505b600085146123d45760018261233a9190613ced565b9150600a856123499190613e83565b60306123559190613c0c565b60f81b818381518110612391577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856123cd9190613c62565b9450612325565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6124548383612750565b61246160008484846125b9565b6124a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612497906137a2565b60405180910390fd5b505050565b6124b083838361291e565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156124f3576124ee81612923565b612532565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461253157612530838261296c565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156125755761257081612ad9565b6125b4565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146125b3576125b28282612c1c565b5b5b505050565b60006125da8473ffffffffffffffffffffffffffffffffffffffff16612c9b565b15612743578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612603611c66565b8786866040518563ffffffff1660e01b815260040161262594939291906136a7565b602060405180830381600087803b15801561263f57600080fd5b505af192505050801561267057506040513d601f19601f8201168201806040525081019061266d91906130c1565b60015b6126f3573d80600081146126a0576040519150601f19603f3d011682016040523d82523d6000602084013e6126a5565b606091505b506000815114156126eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126e2906137a2565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612748565b600190505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156127c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127b790613942565b60405180910390fd5b6127c981611bfa565b15612809576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612800906137e2565b60405180910390fd5b612815600083836124a5565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546128659190613c0c565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016129798461116d565b6129839190613ced565b9050600060076000848152602001908152602001600020549050818114612a68576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612aed9190613ced565b9050600060096000848152602001908152602001600020549050600060088381548110612b43577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612b8b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612c00577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612c278361116d565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600080823b905060008111915050919050565b828054612cba90613dd7565b90600052602060002090601f016020900481019282612cdc5760008555612d23565b82601f10612cf557805160ff1916838001178555612d23565b82800160010185558215612d23579182015b82811115612d22578251825591602001919060010190612d07565b5b509050612d309190612d34565b5090565b5b80821115612d4d576000816000905550600101612d35565b5090565b6000612d64612d5f84613b2e565b613b09565b905082815260208101848484011115612d7c57600080fd5b612d87848285613d95565b509392505050565b6000612da2612d9d84613b5f565b613b09565b905082815260208101848484011115612dba57600080fd5b612dc5848285613d95565b509392505050565b600081359050612ddc816145e2565b92915050565b600081359050612df1816145f9565b92915050565b600081359050612e0681614610565b92915050565b600081519050612e1b81614610565b92915050565b600082601f830112612e3257600080fd5b8135612e42848260208601612d51565b91505092915050565b600082601f830112612e5c57600080fd5b8135612e6c848260208601612d8f565b91505092915050565b600081359050612e8481614627565b92915050565b600060208284031215612e9c57600080fd5b6000612eaa84828501612dcd565b91505092915050565b60008060408385031215612ec657600080fd5b6000612ed485828601612dcd565b9250506020612ee585828601612dcd565b9150509250929050565b600080600060608486031215612f0457600080fd5b6000612f1286828701612dcd565b9350506020612f2386828701612dcd565b9250506040612f3486828701612e75565b9150509250925092565b60008060008060808587031215612f5457600080fd5b6000612f6287828801612dcd565b9450506020612f7387828801612dcd565b9350506040612f8487828801612e75565b925050606085013567ffffffffffffffff811115612fa157600080fd5b612fad87828801612e21565b91505092959194509250565b60008060408385031215612fcc57600080fd5b6000612fda85828601612dcd565b9250506020612feb85828601612de2565b9150509250929050565b6000806040838503121561300857600080fd5b600061301685828601612dcd565b925050602061302785828601612e75565b9150509250929050565b60008060006060848603121561304657600080fd5b600061305486828701612dcd565b935050602061306586828701612e75565b925050604084013567ffffffffffffffff81111561308257600080fd5b61308e86828701612e4b565b9150509250925092565b6000602082840312156130aa57600080fd5b60006130b884828501612df7565b91505092915050565b6000602082840312156130d357600080fd5b60006130e184828501612e0c565b91505092915050565b6000602082840312156130fc57600080fd5b600082013567ffffffffffffffff81111561311657600080fd5b61312284828501612e4b565b91505092915050565b60006020828403121561313d57600080fd5b600061314b84828501612e75565b91505092915050565b6000806040838503121561316757600080fd5b600061317585828601612e75565b925050602083013567ffffffffffffffff81111561319257600080fd5b61319e85828601612e4b565b9150509250929050565b60006131b4838361364a565b60208301905092915050565b6131c981613d21565b82525050565b60006131da82613ba0565b6131e48185613bce565b93506131ef83613b90565b8060005b8381101561322057815161320788826131a8565b975061321283613bc1565b9250506001810190506131f3565b5085935050505092915050565b61323681613d33565b82525050565b600061324782613bab565b6132518185613bdf565b9350613261818560208601613da4565b61326a81613f70565b840191505092915050565b600061328082613bb6565b61328a8185613bf0565b935061329a818560208601613da4565b6132a381613f70565b840191505092915050565b60006132b982613bb6565b6132c38185613c01565b93506132d3818560208601613da4565b80840191505092915050565b60006132ec602b83613bf0565b91506132f782613f81565b604082019050919050565b600061330f603283613bf0565b915061331a82613fd0565b604082019050919050565b6000613332602683613bf0565b915061333d8261401f565b604082019050919050565b6000613355601c83613bf0565b91506133608261406e565b602082019050919050565b6000613378602483613bf0565b915061338382614097565b604082019050919050565b600061339b601983613bf0565b91506133a6826140e6565b602082019050919050565b60006133be602c83613bf0565b91506133c98261410f565b604082019050919050565b60006133e1602183613bf0565b91506133ec8261415e565b604082019050919050565b6000613404603883613bf0565b915061340f826141ad565b604082019050919050565b6000613427602a83613bf0565b9150613432826141fc565b604082019050919050565b600061344a602983613bf0565b91506134558261424b565b604082019050919050565b600061346d601883613bf0565b91506134788261429a565b602082019050919050565b6000613490601983613bf0565b915061349b826142c3565b602082019050919050565b60006134b3601683613bf0565b91506134be826142ec565b602082019050919050565b60006134d6602083613bf0565b91506134e182614315565b602082019050919050565b60006134f9602c83613bf0565b91506135048261433e565b604082019050919050565b600061351c602483613bf0565b91506135278261438d565b604082019050919050565b600061353f602083613bf0565b915061354a826143dc565b602082019050919050565b6000613562602983613bf0565b915061356d82614405565b604082019050919050565b6000613585602f83613bf0565b915061359082614454565b604082019050919050565b60006135a8602183613bf0565b91506135b3826144a3565b604082019050919050565b60006135cb601c83613bf0565b91506135d6826144f2565b602082019050919050565b60006135ee603183613bf0565b91506135f98261451b565b604082019050919050565b6000613611601d83613bf0565b915061361c8261456a565b602082019050919050565b6000613634602c83613bf0565b915061363f82614593565b604082019050919050565b61365381613d8b565b82525050565b61366281613d8b565b82525050565b600061367482856132ae565b915061368082846132ae565b91508190509392505050565b60006020820190506136a160008301846131c0565b92915050565b60006080820190506136bc60008301876131c0565b6136c960208301866131c0565b6136d66040830185613659565b81810360608301526136e8818461323c565b905095945050505050565b6000602082019050818103600083015261370d81846131cf565b905092915050565b600060208201905061372a600083018461322d565b92915050565b6000602082019050818103600083015261374a8184613275565b905092915050565b6000604082019050818103600083015261376c8185613275565b905061377b60208301846131c0565b9392505050565b6000602082019050818103600083015261379b816132df565b9050919050565b600060208201905081810360008301526137bb81613302565b9050919050565b600060208201905081810360008301526137db81613325565b9050919050565b600060208201905081810360008301526137fb81613348565b9050919050565b6000602082019050818103600083015261381b8161336b565b9050919050565b6000602082019050818103600083015261383b8161338e565b9050919050565b6000602082019050818103600083015261385b816133b1565b9050919050565b6000602082019050818103600083015261387b816133d4565b9050919050565b6000602082019050818103600083015261389b816133f7565b9050919050565b600060208201905081810360008301526138bb8161341a565b9050919050565b600060208201905081810360008301526138db8161343d565b9050919050565b600060208201905081810360008301526138fb81613460565b9050919050565b6000602082019050818103600083015261391b81613483565b9050919050565b6000602082019050818103600083015261393b816134a6565b9050919050565b6000602082019050818103600083015261395b816134c9565b9050919050565b6000602082019050818103600083015261397b816134ec565b9050919050565b6000602082019050818103600083015261399b8161350f565b9050919050565b600060208201905081810360008301526139bb81613532565b9050919050565b600060208201905081810360008301526139db81613555565b9050919050565b600060208201905081810360008301526139fb81613578565b9050919050565b60006020820190508181036000830152613a1b8161359b565b9050919050565b60006020820190508181036000830152613a3b816135be565b9050919050565b60006020820190508181036000830152613a5b816135e1565b9050919050565b60006020820190508181036000830152613a7b81613604565b9050919050565b60006020820190508181036000830152613a9b81613627565b9050919050565b6000602082019050613ab76000830184613659565b92915050565b6000608082019050613ad26000830187613659565b613adf6020830186613659565b8181036040830152613af18185613275565b9050613b0060608301846131c0565b95945050505050565b6000613b13613b24565b9050613b1f8282613e09565b919050565b6000604051905090565b600067ffffffffffffffff821115613b4957613b48613f41565b5b613b5282613f70565b9050602081019050919050565b600067ffffffffffffffff821115613b7a57613b79613f41565b5b613b8382613f70565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613c1782613d8b565b9150613c2283613d8b565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613c5757613c56613eb4565b5b828201905092915050565b6000613c6d82613d8b565b9150613c7883613d8b565b925082613c8857613c87613ee3565b5b828204905092915050565b6000613c9e82613d8b565b9150613ca983613d8b565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613ce257613ce1613eb4565b5b828202905092915050565b6000613cf882613d8b565b9150613d0383613d8b565b925082821015613d1657613d15613eb4565b5b828203905092915050565b6000613d2c82613d6b565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613dc2578082015181840152602081019050613da7565b83811115613dd1576000848401525b50505050565b60006002820490506001821680613def57607f821691505b60208210811415613e0357613e02613f12565b5b50919050565b613e1282613f70565b810181811067ffffffffffffffff82111715613e3157613e30613f41565b5b80604052505050565b6000613e4582613d8b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613e7857613e77613eb4565b5b600182019050919050565b6000613e8e82613d8b565b9150613e9983613d8b565b925082613ea957613ea8613ee3565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f43616e206f6e6c79206d696e7420323020746f6b656e7320617420612074696d60008201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f53616c652068617320616c726561647920737461727465640000000000000000600082015250565b7f56616c75652073656e74206973206e6f7420636f727265637400000000000000600082015250565b7f53616c6520697320616c72656164792070617573656400000000000000000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f507572636861736520776f756c6420657863656564206d6178696d756d20737560008201527f70706c7900000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f53616c65206973206e6f742063757272656e746c792061637469766500000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f4578636565647320726573657276656420746f6b656e20737570706c79000000600082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b6145eb81613d21565b81146145f657600080fd5b50565b61460281613d33565b811461460d57600080fd5b50565b61461981613d3f565b811461462457600080fd5b50565b61463081613d8b565b811461463b57600080fd5b5056fea2646970667358221220a188623630e1303e3e8baa4c8edcf994f990349a5021c5bcd5f3acc40e6f797d64736f6c63430008040033
Verified Source Code Full Match
Compiler: v0.8.4+commit.c7e474f2
EVM: istanbul
Optimization: No
PsychoPunks.sol 133 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
contract PsychoPunks is ERC721Enumerable, Ownable {
using Strings for uint256;
// baseURI
string private baseURI;
// Price
uint256 private price = 0.03 ether;
// Minting
uint256 public constant MAX_SUPPLY = 2000;
uint256 public constant MAX_PURCHASE = 20;
// Sale state
bool public saleIsActive = false;
// Giveaways
uint256 private reserved = 40;
// Withdraw address
address withdrawAddress = 0x6907495b99FF6270B6de708c04f3DaCAedD40A40;
// Events
event Mint(uint256 indexed tokenId, string twitterUsername, address owner);
event MintBatch(uint256 fromTokenId, uint256 amount, string twitterUsername, address owner);
/*
* Constructor
*/
constructor(string memory newBaseURI) ERC721("PsychoPunks", "PsychoPunks") {
setBaseURI(newBaseURI);
}
/*
* Minting
*/
function mint(uint256 _amount, string memory _twitterUsername) public payable {
uint256 supply = totalSupply();
require( saleIsActive, "Sale is not currently active" );
require( _amount <= MAX_PURCHASE, "Can only mint 20 tokens at a time" );
require( (supply + _amount) <= (MAX_SUPPLY - reserved), "Purchase would exceed maximum supply" );
require( msg.value >= (price * _amount), "Value sent is not correct" );
for (uint256 i; i < _amount; i++) {
uint256 tokenId = (supply + i);
_safeMint(msg.sender, tokenId);
emit Mint(tokenId, _twitterUsername, msg.sender);
}
emit MintBatch(supply, _amount, _twitterUsername, msg.sender);
}
/*
* baseURI
*/
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
function setBaseURI(string memory newBaseURI) public onlyOwner {
baseURI = newBaseURI;
}
/*
* Price
*/
function getPrice() public view returns (uint256) {
return price;
}
function setPrice(uint256 _price) public onlyOwner() {
price = _price;
}
/*
* Sale state
*/
function pauseSale() public onlyOwner() {
require(saleIsActive == true, "Sale is already paused");
saleIsActive = false;
}
function startSale() public onlyOwner() {
require(saleIsActive == false, "Sale has already started");
saleIsActive = true;
}
/*
* Giveaways
*/
function giveAway(address _to, uint256 _amount, string memory _twitterUsername) external onlyOwner() {
require(_amount <= reserved, "Exceeds reserved token supply" );
uint256 supply = totalSupply();
for (uint256 i; i < _amount; i++) {
uint256 tokenId = (supply + i);
_safeMint(_to, tokenId);
emit Mint(tokenId, _twitterUsername, msg.sender);
}
reserved -= _amount;
emit MintBatch(supply, _amount, _twitterUsername, msg.sender);
}
/*
* Tokens at address
*/
function walletOfOwner(address _owner) public view returns(uint256[] memory) {
uint256 tokenCount = balanceOf(_owner);
uint256[] memory tokensId = new uint256[](tokenCount);
for(uint256 i; i < tokenCount; i++){
tokensId[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokensId;
}
/*
* Withdraw
*/
function withdraw() public onlyOwner {
uint balance = address(this).balance;
require(payable(withdrawAddress).send(balance));
}
}
Address.sol 210 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) private pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 23 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 66 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Ownable.sol 71 lines
// SPDX-License-Identifier: MIT
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() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
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 {
_setOwner(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");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
ERC721.sol 411 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_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 {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
IERC721.sol 142 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
ERC165.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 26 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
IERC721Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
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);
}
ERC721Enumerable.sol 162 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "./IERC721Enumerable.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
IERC721Enumerable.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
Read Contract
MAX_PURCHASE 0x7146bd08 → uint256
MAX_SUPPLY 0x32cb6b0c → uint256
balanceOf 0x70a08231 → uint256
getApproved 0x081812fc → address
getPrice 0x98d5fdca → uint256
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
saleIsActive 0xeb8d2444 → bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
walletOfOwner 0x438b6300 → uint256[]
Write Contract 14 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
giveAway 0x1703030e
address _to
uint256 _amount
string _twitterUsername
mint 0x77097fc8
uint256 _amount
string _twitterUsername
pauseSale 0x55367ba9
No parameters
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string newBaseURI
setPrice 0x91b7f5ed
uint256 _price
startSale 0xb66a0e5d
No parameters
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address