Address Contract Verified
Address
0x8edd8e175DFC8644A11C7a79C444744660f44A1A
Balance
0.030000 ETH
Nonce
1
Code Size
18312 bytes
Creator
0xFa2D5991...2330 at tx 0x555effdf...3cb47d
Indexed Transactions
0
Contract Bytecode
18312 bytes
0x6080604052600436106102045760003560e01c80636352211e11610118578063b11560c5116100a0578063c87b56dd1161006f578063c87b56dd14610735578063d5abeb0114610772578063e985e9c51461079d578063f2fde38b146107da578063fdea8e0b1461080357610204565b8063b11560c514610691578063b88d4fde146106ba578063bedb86fb146106e3578063c54e73e31461070c57610204565b8063740d73f3116100e7578063740d73f3146105c05780637f00c7a6146105e95780638da5cb5b1461061257806395d89b411461063d578063a22cb4651461066857610204565b80636352211e146105045780636c0360eb1461054157806370a082311461056c578063715018a6146105a957610204565b80632f745c591161019b578063438b63001161016a578063438b63001461040d57806344a0d68a1461044a5780634f6ccce71461047357806355f804b3146104b05780635c975abb146104d957610204565b80632f745c59146103815780633ccfd60b146103be57806340c10f19146103c857806342842e0e146103e457610204565b806313faede6116101d757806313faede6146102d757806318160ddd14610302578063239c70ae1461032d57806323b872dd1461035857610204565b806301ffc9a71461020957806306fdde0314610246578063081812fc14610271578063095ea7b3146102ae575b600080fd5b34801561021557600080fd5b50610230600480360381019061022b919061327e565b61082e565b60405161023d9190613898565b60405180910390f35b34801561025257600080fd5b5061025b6108a8565b60405161026891906138b3565b60405180910390f35b34801561027d57600080fd5b5061029860048036038101906102939190613321565b61093a565b6040516102a5919061380f565b60405180910390f35b3480156102ba57600080fd5b506102d560048036038101906102d091906131c4565b6109bf565b005b3480156102e357600080fd5b506102ec610ad7565b6040516102f99190613bd5565b60405180910390f35b34801561030e57600080fd5b50610317610add565b6040516103249190613bd5565b60405180910390f35b34801561033957600080fd5b50610342610aea565b60405161034f9190613bd5565b60405180910390f35b34801561036457600080fd5b5061037f600480360381019061037a91906130ae565b610af0565b005b34801561038d57600080fd5b506103a860048036038101906103a391906131c4565b610b50565b6040516103b59190613bd5565b60405180910390f35b6103c6610bf5565b005b6103e260048036038101906103dd91906131c4565b610cb1565b005b3480156103f057600080fd5b5061040b600480360381019061040691906130ae565b610f4e565b005b34801561041957600080fd5b50610434600480360381019061042f9190613041565b610f6e565b6040516104419190613876565b60405180910390f35b34801561045657600080fd5b50610471600480360381019061046c9190613321565b61101c565b005b34801561047f57600080fd5b5061049a60048036038101906104959190613321565b6110a2565b6040516104a79190613bd5565b60405180910390f35b3480156104bc57600080fd5b506104d760048036038101906104d291906132d8565b611113565b005b3480156104e557600080fd5b506104ee6111a9565b6040516104fb9190613898565b60405180910390f35b34801561051057600080fd5b5061052b60048036038101906105269190613321565b6111bc565b604051610538919061380f565b60405180910390f35b34801561054d57600080fd5b5061055661126e565b60405161056391906138b3565b60405180910390f35b34801561057857600080fd5b50610593600480360381019061058e9190613041565b6112fc565b6040516105a09190613bd5565b60405180910390f35b3480156105b557600080fd5b506105be6113b4565b005b3480156105cc57600080fd5b506105e760048036038101906105e29190613204565b61143c565b005b3480156105f557600080fd5b50610610600480360381019061060b9190613321565b61155d565b005b34801561061e57600080fd5b506106276115e3565b604051610634919061380f565b60405180910390f35b34801561064957600080fd5b5061065261160d565b60405161065f91906138b3565b60405180910390f35b34801561067457600080fd5b5061068f600480360381019061068a9190613184565b61169f565b005b34801561069d57600080fd5b506106b860048036038101906106b39190613204565b6116b5565b005b3480156106c657600080fd5b506106e160048036038101906106dc9190613101565b6117cd565b005b3480156106ef57600080fd5b5061070a60048036038101906107059190613251565b61182f565b005b34801561071857600080fd5b50610733600480360381019061072e9190613251565b6118c8565b005b34801561074157600080fd5b5061075c60048036038101906107579190613321565b611961565b60405161076991906138b3565b60405180910390f35b34801561077e57600080fd5b506107876119e9565b6040516107949190613bd5565b60405180910390f35b3480156107a957600080fd5b506107c460048036038101906107bf919061306e565b6119ef565b6040516107d19190613898565b60405180910390f35b3480156107e657600080fd5b5061080160048036038101906107fc9190613041565b611a83565b005b34801561080f57600080fd5b50610818611b7b565b6040516108259190613898565b60405180910390f35b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806108a157506108a082611b8e565b5b9050919050565b6060600080546108b790613ebe565b80601f01602080910402602001604051908101604052809291908181526020018280546108e390613ebe565b80156109305780601f1061090557610100808354040283529160200191610930565b820191906000526020600020905b81548152906001019060200180831161091357829003601f168201915b5050505050905090565b600061094582611c70565b610984576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097b90613a55565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006109ca826111bc565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3290613ad5565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610a5a611cdc565b73ffffffffffffffffffffffffffffffffffffffff161480610a895750610a8881610a83611cdc565b6119ef565b5b610ac8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610abf906139d5565b60405180910390fd5b610ad28383611ce4565b505050565b600c5481565b6000600880549050905090565b600e5481565b610b01610afb611cdc565b82611d9d565b610b40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3790613b15565b60405180910390fd5b610b4b838383611e7b565b505050565b6000610b5b836112fc565b8210610b9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b93906138d5565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610bfd611cdc565b73ffffffffffffffffffffffffffffffffffffffff16610c1b6115e3565b73ffffffffffffffffffffffffffffffffffffffff1614610c71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6890613a75565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050610caf57600080fd5b565b6000610cbb610add565b9050600f60019054906101000a900460ff1615610d0d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0490613b75565b60405180910390fd5b60008211610d50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4790613bb5565b60405180910390fd5b600e54821115610d95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d8c90613b95565b60405180910390fd5b600d548282610da49190613cf3565b1115610de5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ddc90613b55565b60405180910390fd5b610ded6115e3565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f125781600c54610e2d9190613d7a565b341015610e6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6690613ab5565b60405180910390fd5b600f60009054906101000a900460ff1615610f1157601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610f10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0790613af5565b60405180910390fd5b5b5b6000600190505b828111610f4857610f35848284610f309190613cf3565b6120e2565b8080610f4090613f21565b915050610f19565b50505050565b610f69838383604051806020016040528060008152506117cd565b505050565b60606000610f7b836112fc565b905060008167ffffffffffffffff811115610f9957610f98614086565b5b604051908082528060200260200182016040528015610fc75781602001602082028036833780820191505090505b50905060005b8281101561101157610fdf8582610b50565b828281518110610ff257610ff1614057565b5b602002602001018181525050808061100990613f21565b915050610fcd565b508092505050919050565b611024611cdc565b73ffffffffffffffffffffffffffffffffffffffff166110426115e3565b73ffffffffffffffffffffffffffffffffffffffff1614611098576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108f90613a75565b60405180910390fd5b80600c8190555050565b60006110ac610add565b82106110ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e490613b35565b60405180910390fd5b6008828154811061110157611100614057565b5b90600052602060002001549050919050565b61111b611cdc565b73ffffffffffffffffffffffffffffffffffffffff166111396115e3565b73ffffffffffffffffffffffffffffffffffffffff161461118f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118690613a75565b60405180910390fd5b80600b90805190602001906111a5929190612dff565b5050565b600f60019054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611265576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125c90613a15565b60405180910390fd5b80915050919050565b600b805461127b90613ebe565b80601f01602080910402602001604051908101604052809291908181526020018280546112a790613ebe565b80156112f45780601f106112c9576101008083540402835291602001916112f4565b820191906000526020600020905b8154815290600101906020018083116112d757829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561136d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611364906139f5565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6113bc611cdc565b73ffffffffffffffffffffffffffffffffffffffff166113da6115e3565b73ffffffffffffffffffffffffffffffffffffffff1614611430576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142790613a75565b60405180910390fd5b61143a6000612100565b565b611444611cdc565b73ffffffffffffffffffffffffffffffffffffffff166114626115e3565b73ffffffffffffffffffffffffffffffffffffffff16146114b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114af90613a75565b60405180910390fd5b60005b82829050811015611558576001601060008585858181106114df576114de614057565b5b90506020020160208101906114f49190613041565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061155090613f21565b9150506114bb565b505050565b611565611cdc565b73ffffffffffffffffffffffffffffffffffffffff166115836115e3565b73ffffffffffffffffffffffffffffffffffffffff16146115d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115d090613a75565b60405180910390fd5b80600e8190555050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606001805461161c90613ebe565b80601f016020809104026020016040519081016040528092919081815260200182805461164890613ebe565b80156116955780601f1061166a57610100808354040283529160200191611695565b820191906000526020600020905b81548152906001019060200180831161167857829003601f168201915b5050505050905090565b6116b16116aa611cdc565b83836121c6565b5050565b6116bd611cdc565b73ffffffffffffffffffffffffffffffffffffffff166116db6115e3565b73ffffffffffffffffffffffffffffffffffffffff1614611731576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172890613a75565b60405180910390fd5b60005b828290508110156117c8576010600084848481811061175657611755614057565b5b905060200201602081019061176b9190613041565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905580806117c090613f21565b915050611734565b505050565b6117de6117d8611cdc565b83611d9d565b61181d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161181490613b15565b60405180910390fd5b61182984848484612333565b50505050565b611837611cdc565b73ffffffffffffffffffffffffffffffffffffffff166118556115e3565b73ffffffffffffffffffffffffffffffffffffffff16146118ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118a290613a75565b60405180910390fd5b80600f60016101000a81548160ff02191690831515021790555050565b6118d0611cdc565b73ffffffffffffffffffffffffffffffffffffffff166118ee6115e3565b73ffffffffffffffffffffffffffffffffffffffff1614611944576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193b90613a75565b60405180910390fd5b80600f60006101000a81548160ff02191690831515021790555050565b606061196c82611c70565b6119ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119a290613a95565b60405180910390fd5b60006119b561238f565b9050806119c184612421565b6040516020016119d29291906137eb565b604051602081830303815290604052915050919050565b600d5481565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611a8b611cdc565b73ffffffffffffffffffffffffffffffffffffffff16611aa96115e3565b73ffffffffffffffffffffffffffffffffffffffff1614611aff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611af690613a75565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611b6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6690613915565b60405180910390fd5b611b7881612100565b50565b600f60009054906101000a900460ff1681565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611c5957507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611c695750611c6882612582565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611d57836111bc565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611da882611c70565b611de7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dde906139b5565b60405180910390fd5b6000611df2836111bc565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611e6157508373ffffffffffffffffffffffffffffffffffffffff16611e498461093a565b73ffffffffffffffffffffffffffffffffffffffff16145b80611e725750611e7181856119ef565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611e9b826111bc565b73ffffffffffffffffffffffffffffffffffffffff1614611ef1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ee890613935565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611f61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5890613975565b60405180910390fd5b611f6c8383836125ec565b611f77600082611ce4565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611fc79190613dd4565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461201e9190613cf3565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46120dd838383612700565b505050565b6120fc828260405180602001604052806000815250612705565b5050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612235576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161222c90613995565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516123269190613898565b60405180910390a3505050565b61233e848484611e7b565b61234a84848484612760565b612389576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612380906138f5565b60405180910390fd5b50505050565b6060600b805461239e90613ebe565b80601f01602080910402602001604051908101604052809291908181526020018280546123ca90613ebe565b80156124175780601f106123ec57610100808354040283529160200191612417565b820191906000526020600020905b8154815290600101906020018083116123fa57829003601f168201915b5050505050905090565b60606000821415612469576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061257d565b600082905060005b6000821461249b57808061248490613f21565b915050600a826124949190613d49565b9150612471565b60008167ffffffffffffffff8111156124b7576124b6614086565b5b6040519080825280601f01601f1916602001820160405280156124e95781602001600182028036833780820191505090505b5090505b60008514612576576001826125029190613dd4565b9150600a856125119190613f6a565b603061251d9190613cf3565b60f81b81838151811061253357612532614057565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561256f9190613d49565b94506124ed565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6125f78383836128f7565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561263a57612635816128fc565b612679565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612678576126778382612945565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126bc576126b781612ab2565b6126fb565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146126fa576126f98282612b83565b5b5b505050565b505050565b61270f8383612c02565b61271c6000848484612760565b61275b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612752906138f5565b60405180910390fd5b505050565b60006127818473ffffffffffffffffffffffffffffffffffffffff16612ddc565b156128ea578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026127aa611cdc565b8786866040518563ffffffff1660e01b81526004016127cc949392919061382a565b602060405180830381600087803b1580156127e657600080fd5b505af192505050801561281757506040513d601f19601f8201168201806040525081019061281491906132ab565b60015b61289a573d8060008114612847576040519150601f19603f3d011682016040523d82523d6000602084013e61284c565b606091505b50600081511415612892576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612889906138f5565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506128ef565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612952846112fc565b61295c9190613dd4565b9050600060076000848152602001908152602001600020549050818114612a41576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612ac69190613dd4565b9050600060096000848152602001908152602001600020549050600060088381548110612af657612af5614057565b5b906000526020600020015490508060088381548110612b1857612b17614057565b5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612b6757612b66614028565b5b6001900381819060005260206000200160009055905550505050565b6000612b8e836112fc565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612c72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c6990613a35565b60405180910390fd5b612c7b81611c70565b15612cbb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cb290613955565b60405180910390fd5b612cc7600083836125ec565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612d179190613cf3565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612dd860008383612700565b5050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b828054612e0b90613ebe565b90600052602060002090601f016020900481019282612e2d5760008555612e74565b82601f10612e4657805160ff1916838001178555612e74565b82800160010185558215612e74579182015b82811115612e73578251825591602001919060010190612e58565b5b509050612e819190612e85565b5090565b5b80821115612e9e576000816000905550600101612e86565b5090565b6000612eb5612eb084613c15565b613bf0565b905082815260208101848484011115612ed157612ed06140c4565b5b612edc848285613e7c565b509392505050565b6000612ef7612ef284613c46565b613bf0565b905082815260208101848484011115612f1357612f126140c4565b5b612f1e848285613e7c565b509392505050565b600081359050612f35816146f6565b92915050565b60008083601f840112612f5157612f506140ba565b5b8235905067ffffffffffffffff811115612f6e57612f6d6140b5565b5b602083019150836020820283011115612f8a57612f896140bf565b5b9250929050565b600081359050612fa08161470d565b92915050565b600081359050612fb581614724565b92915050565b600081519050612fca81614724565b92915050565b600082601f830112612fe557612fe46140ba565b5b8135612ff5848260208601612ea2565b91505092915050565b600082601f830112613013576130126140ba565b5b8135613023848260208601612ee4565b91505092915050565b60008135905061303b8161473b565b92915050565b600060208284031215613057576130566140ce565b5b600061306584828501612f26565b91505092915050565b60008060408385031215613085576130846140ce565b5b600061309385828601612f26565b92505060206130a485828601612f26565b9150509250929050565b6000806000606084860312156130c7576130c66140ce565b5b60006130d586828701612f26565b93505060206130e686828701612f26565b92505060406130f78682870161302c565b9150509250925092565b6000806000806080858703121561311b5761311a6140ce565b5b600061312987828801612f26565b945050602061313a87828801612f26565b935050604061314b8782880161302c565b925050606085013567ffffffffffffffff81111561316c5761316b6140c9565b5b61317887828801612fd0565b91505092959194509250565b6000806040838503121561319b5761319a6140ce565b5b60006131a985828601612f26565b92505060206131ba85828601612f91565b9150509250929050565b600080604083850312156131db576131da6140ce565b5b60006131e985828601612f26565b92505060206131fa8582860161302c565b9150509250929050565b6000806020838503121561321b5761321a6140ce565b5b600083013567ffffffffffffffff811115613239576132386140c9565b5b61324585828601612f3b565b92509250509250929050565b600060208284031215613267576132666140ce565b5b600061327584828501612f91565b91505092915050565b600060208284031215613294576132936140ce565b5b60006132a284828501612fa6565b91505092915050565b6000602082840312156132c1576132c06140ce565b5b60006132cf84828501612fbb565b91505092915050565b6000602082840312156132ee576132ed6140ce565b5b600082013567ffffffffffffffff81111561330c5761330b6140c9565b5b61331884828501612ffe565b91505092915050565b600060208284031215613337576133366140ce565b5b60006133458482850161302c565b91505092915050565b600061335a83836137cd565b60208301905092915050565b61336f81613e08565b82525050565b600061338082613c87565b61338a8185613cb5565b935061339583613c77565b8060005b838110156133c65781516133ad888261334e565b97506133b883613ca8565b925050600181019050613399565b5085935050505092915050565b6133dc81613e1a565b82525050565b60006133ed82613c92565b6133f78185613cc6565b9350613407818560208601613e8b565b613410816140d3565b840191505092915050565b600061342682613c9d565b6134308185613cd7565b9350613440818560208601613e8b565b613449816140d3565b840191505092915050565b600061345f82613c9d565b6134698185613ce8565b9350613479818560208601613e8b565b80840191505092915050565b6000613492602b83613cd7565b915061349d826140e4565b604082019050919050565b60006134b5603283613cd7565b91506134c082614133565b604082019050919050565b60006134d8602683613cd7565b91506134e382614182565b604082019050919050565b60006134fb602583613cd7565b9150613506826141d1565b604082019050919050565b600061351e601c83613cd7565b915061352982614220565b602082019050919050565b6000613541602483613cd7565b915061354c82614249565b604082019050919050565b6000613564601983613cd7565b915061356f82614298565b602082019050919050565b6000613587602c83613cd7565b9150613592826142c1565b604082019050919050565b60006135aa603883613cd7565b91506135b582614310565b604082019050919050565b60006135cd602a83613cd7565b91506135d88261435f565b604082019050919050565b60006135f0602983613cd7565b91506135fb826143ae565b604082019050919050565b6000613613602083613cd7565b915061361e826143fd565b602082019050919050565b6000613636602c83613cd7565b915061364182614426565b604082019050919050565b6000613659602083613cd7565b915061366482614475565b602082019050919050565b600061367c602f83613cd7565b91506136878261449e565b604082019050919050565b600061369f601283613cd7565b91506136aa826144ed565b602082019050919050565b60006136c2602183613cd7565b91506136cd82614516565b604082019050919050565b60006136e5601a83613cd7565b91506136f082614565565b602082019050919050565b6000613708603183613cd7565b91506137138261458e565b604082019050919050565b600061372b602c83613cd7565b9150613736826145dd565b604082019050919050565b600061374e602783613cd7565b91506137598261462c565b604082019050919050565b6000613771600e83613cd7565b915061377c8261467b565b602082019050919050565b6000613794601d83613cd7565b915061379f826146a4565b602082019050919050565b60006137b7601c83613cd7565b91506137c2826146cd565b602082019050919050565b6137d681613e72565b82525050565b6137e581613e72565b82525050565b60006137f78285613454565b91506138038284613454565b91508190509392505050565b60006020820190506138246000830184613366565b92915050565b600060808201905061383f6000830187613366565b61384c6020830186613366565b61385960408301856137dc565b818103606083015261386b81846133e2565b905095945050505050565b600060208201905081810360008301526138908184613375565b905092915050565b60006020820190506138ad60008301846133d3565b92915050565b600060208201905081810360008301526138cd818461341b565b905092915050565b600060208201905081810360008301526138ee81613485565b9050919050565b6000602082019050818103600083015261390e816134a8565b9050919050565b6000602082019050818103600083015261392e816134cb565b9050919050565b6000602082019050818103600083015261394e816134ee565b9050919050565b6000602082019050818103600083015261396e81613511565b9050919050565b6000602082019050818103600083015261398e81613534565b9050919050565b600060208201905081810360008301526139ae81613557565b9050919050565b600060208201905081810360008301526139ce8161357a565b9050919050565b600060208201905081810360008301526139ee8161359d565b9050919050565b60006020820190508181036000830152613a0e816135c0565b9050919050565b60006020820190508181036000830152613a2e816135e3565b9050919050565b60006020820190508181036000830152613a4e81613606565b9050919050565b60006020820190508181036000830152613a6e81613629565b9050919050565b60006020820190508181036000830152613a8e8161364c565b9050919050565b60006020820190508181036000830152613aae8161366f565b9050919050565b60006020820190508181036000830152613ace81613692565b9050919050565b60006020820190508181036000830152613aee816136b5565b9050919050565b60006020820190508181036000830152613b0e816136d8565b9050919050565b60006020820190508181036000830152613b2e816136fb565b9050919050565b60006020820190508181036000830152613b4e8161371e565b9050919050565b60006020820190508181036000830152613b6e81613741565b9050919050565b60006020820190508181036000830152613b8e81613764565b9050919050565b60006020820190508181036000830152613bae81613787565b9050919050565b60006020820190508181036000830152613bce816137aa565b9050919050565b6000602082019050613bea60008301846137dc565b92915050565b6000613bfa613c0b565b9050613c068282613ef0565b919050565b6000604051905090565b600067ffffffffffffffff821115613c3057613c2f614086565b5b613c39826140d3565b9050602081019050919050565b600067ffffffffffffffff821115613c6157613c60614086565b5b613c6a826140d3565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613cfe82613e72565b9150613d0983613e72565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613d3e57613d3d613f9b565b5b828201905092915050565b6000613d5482613e72565b9150613d5f83613e72565b925082613d6f57613d6e613fca565b5b828204905092915050565b6000613d8582613e72565b9150613d9083613e72565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613dc957613dc8613f9b565b5b828202905092915050565b6000613ddf82613e72565b9150613dea83613e72565b925082821015613dfd57613dfc613f9b565b5b828203905092915050565b6000613e1382613e52565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613ea9578082015181840152602081019050613e8e565b83811115613eb8576000848401525b50505050565b60006002820490506001821680613ed657607f821691505b60208210811415613eea57613ee9613ff9565b5b50919050565b613ef9826140d3565b810181811067ffffffffffffffff82111715613f1857613f17614086565b5b80604052505050565b6000613f2c82613e72565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613f5f57613f5e613f9b565b5b600182019050919050565b6000613f7582613e72565b9150613f8083613e72565b925082613f9057613f8f613fca565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f496e73756666696369656e742076616c75650000000000000000000000000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f596f75206e65656420746f2062652077686974656c6973746564000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f4d696e74696e672070617374206d617820737570706c79206973206e6f74207060008201527f6f737369626c6500000000000000000000000000000000000000000000000000602082015250565b7f53616c6520697320706175736564000000000000000000000000000000000000600082015250565b7f4d696e7420616d6f756e74206d6f7265207468616e206d6178696d756d000000600082015250565b7f4d696e7420616d6f756e74206d75737420626520706f73697469766500000000600082015250565b6146ff81613e08565b811461470a57600080fd5b50565b61471681613e1a565b811461472157600080fd5b50565b61472d81613e26565b811461473857600080fd5b50565b61474481613e72565b811461474f57600080fd5b5056fea2646970667358221220c50d77837044a2cff6a3238177d54cb4b3b74c4633314679411950212870487b64736f6c63430008070033
Verified Source Code Full Match
Compiler: v0.8.7+commit.e28d00a7
EVM: london
Optimization: No
SmartContract.sol 103 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 SmartContract is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
uint256 public cost = 0.03 ether;
uint256 public maxSupply = 8000;
uint256 public maxMintAmount = 10;
bool public presale = true;
bool public paused = true;
mapping (address => bool) private whitelist;
constructor(string memory _name, string memory _symbol, string memory _initBaseURI) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
}
// internal function
function _baseURI() internal view virtual override returns (string memory) {
return baseURI; // we created a func in case we'll need to change the base URI
}
// public
function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused, "Sale is paused");
require(_mintAmount > 0, "Mint amount must be positive");
require(_mintAmount <= maxMintAmount, "Mint amount more than maximum");
require(supply + _mintAmount <= maxSupply, "Minting past max supply is not possible");
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount, "Insufficient value"); // if a minter is not a SC owner he will be charged
if (presale) {
require(whitelist[_to], "You need to be whitelisted");
}
}
for (uint256 i = 1; i <= _mintAmount; i++) { // uint256 i = 1 cause we want our token id to start from 1
_safeMint(_to, supply + i); // supply + i - current token id for a current minter; address and tokenId should be passed
}
}
function walletOfOwner(address _owner) public view returns (uint256[] memory) {
uint256 ownerTokenCount = balanceOf(_owner); // returns number of tokens owned
uint256[] memory tokenIds = new uint256[](ownerTokenCount); // initialize an array of tokenIds with the length = ownerTokenCount
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i); // return an array of the tokenIds owned by a minter
}
return tokenIds;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory){ // this func returns metadata in right format
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); // check if the tocken with this tokenId exists
string memory currentBaseURI = _baseURI(); // from base ORI func - see above
return string(abi.encodePacked(currentBaseURI, tokenId.toString()));
} // a string with a full file name will be returned
// only owner functions
function setCost(uint256 _newCost) public onlyOwner() {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() {
maxMintAmount = _newmaxMintAmount;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function withdraw() public payable onlyOwner {
require(payable(msg.sender).send(address(this).balance));
}
function setPresale(bool _presale) public onlyOwner {
presale = _presale;
}
function setPause(bool _state) public onlyOwner {
paused = _state;
}
function addToWhiteList(address[] calldata addresses) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
whitelist[addresses[i]] = true;
}
}
function removeFromWhiteList(address[] calldata addresses) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
delete whitelist[addresses[i]];
}
}
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 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 {
_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);
}
}
ERC721.sol 447 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(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);
_afterTokenTransfer(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 from incorrect owner");
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);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
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);
}
ERC721Enumerable.sol 163 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)
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 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
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);
/**
* @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
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
cost 0x13faede6 → uint256
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
maxMintAmount 0x239c70ae → uint256
maxSupply 0xd5abeb01 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
presale 0xfdea8e0b → bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
walletOfOwner 0x438b6300 → uint256[]
Write Contract 16 functions
These functions modify contract state and require a wallet transaction to execute.
addToWhiteList 0x740d73f3
address[] addresses
approve 0x095ea7b3
address to
uint256 tokenId
mint 0x40c10f19
address _to
uint256 _mintAmount
removeFromWhiteList 0xb11560c5
address[] addresses
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
setCost 0x44a0d68a
uint256 _newCost
setPause 0xbedb86fb
bool _state
setPresale 0xc54e73e3
bool _presale
setmaxMintAmount 0x7f00c7a6
uint256 _newmaxMintAmount
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address