Address Contract Verified
Address
0xdDcfb47662095CF1c82063F9A0227110C65E22dC
Balance
0.035000 ETH
Nonce
1
Code Size
17820 bytes
Creator
0xa48Cb273...75F3 at tx 0xbde42d76...5b4692
Indexed Transactions
0
Contract Bytecode
17820 bytes
0x6080604052600436106101ee5760003560e01c80635c975abb1161010d578063a0712d68116100a0578063c87b56dd1161006f578063c87b56dd146106cf578063d5abeb011461070c578063da3ef23f14610737578063e985e9c514610760578063f2fde38b1461079d576101ee565b8063a0712d6814610636578063a22cb46514610652578063b88d4fde1461067b578063c6682862146106a4576101ee565b8063715018a6116100dc578063715018a6146105a05780637f00c7a6146105b75780638da5cb5b146105e057806395d89b411461060b576101ee565b80635c975abb146104d05780636352211e146104fb5780636c0360eb1461053857806370a0823114610563576101ee565b806323b872dd11610185578063438b630011610154578063438b63001461040457806344a0d68a146104415780634f6ccce71461046a57806355f804b3146104a7576101ee565b806323b872dd1461036b5780632f745c59146103945780633ccfd60b146103d157806342842e0e146103db576101ee565b8063095ea7b3116101c1578063095ea7b3146102c157806313faede6146102ea57806318160ddd14610315578063239c70ae14610340576101ee565b806301ffc9a7146101f357806302329a291461023057806306fdde0314610259578063081812fc14610284575b600080fd5b3480156101ff57600080fd5b5061021a60048036038101906102159190612fb5565b6107c6565b6040516102279190613693565b60405180910390f35b34801561023c57600080fd5b5061025760048036038101906102529190612f88565b610840565b005b34801561026557600080fd5b5061026e6108d9565b60405161027b91906136ae565b60405180910390f35b34801561029057600080fd5b506102ab60048036038101906102a69190613058565b61096b565b6040516102b8919061360a565b60405180910390f35b3480156102cd57600080fd5b506102e860048036038101906102e39190612f48565b6109f0565b005b3480156102f657600080fd5b506102ff610b08565b60405161030c91906139d0565b60405180910390f35b34801561032157600080fd5b5061032a610b0e565b60405161033791906139d0565b60405180910390f35b34801561034c57600080fd5b50610355610b1b565b60405161036291906139d0565b60405180910390f35b34801561037757600080fd5b50610392600480360381019061038d9190612e32565b610b21565b005b3480156103a057600080fd5b506103bb60048036038101906103b69190612f48565b610b81565b6040516103c891906139d0565b60405180910390f35b6103d9610c26565b005b3480156103e757600080fd5b5061040260048036038101906103fd9190612e32565b610d51565b005b34801561041057600080fd5b5061042b60048036038101906104269190612dc5565b610d71565b6040516104389190613671565b60405180910390f35b34801561044d57600080fd5b5061046860048036038101906104639190613058565b610e1f565b005b34801561047657600080fd5b50610491600480360381019061048c9190613058565b610ea5565b60405161049e91906139d0565b60405180910390f35b3480156104b357600080fd5b506104ce60048036038101906104c9919061300f565b610f16565b005b3480156104dc57600080fd5b506104e5610fac565b6040516104f29190613693565b60405180910390f35b34801561050757600080fd5b50610522600480360381019061051d9190613058565b610fbf565b60405161052f919061360a565b60405180910390f35b34801561054457600080fd5b5061054d611071565b60405161055a91906136ae565b60405180910390f35b34801561056f57600080fd5b5061058a60048036038101906105859190612dc5565b6110ff565b60405161059791906139d0565b60405180910390f35b3480156105ac57600080fd5b506105b56111b7565b005b3480156105c357600080fd5b506105de60048036038101906105d99190613058565b61123f565b005b3480156105ec57600080fd5b506105f56112c5565b604051610602919061360a565b60405180910390f35b34801561061757600080fd5b506106206112ef565b60405161062d91906136ae565b60405180910390f35b610650600480360381019061064b9190613058565b611381565b005b34801561065e57600080fd5b5061067960048036038101906106749190612f08565b611582565b005b34801561068757600080fd5b506106a2600480360381019061069d9190612e85565b611598565b005b3480156106b057600080fd5b506106b96115fa565b6040516106c691906136ae565b60405180910390f35b3480156106db57600080fd5b506106f660048036038101906106f19190613058565b611688565b60405161070391906136ae565b60405180910390f35b34801561071857600080fd5b50610721611732565b60405161072e91906139d0565b60405180910390f35b34801561074357600080fd5b5061075e6004803603810190610759919061300f565b611738565b005b34801561076c57600080fd5b5061078760048036038101906107829190612df2565b6117ce565b6040516107949190613693565b60405180910390f35b3480156107a957600080fd5b506107c460048036038101906107bf9190612dc5565b611862565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610839575061083882611972565b5b9050919050565b610848611a54565b73ffffffffffffffffffffffffffffffffffffffff166108666112c5565b73ffffffffffffffffffffffffffffffffffffffff16146108bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b3906138b0565b60405180910390fd5b80601060006101000a81548160ff02191690831515021790555050565b6060600080546108e890613cd9565b80601f016020809104026020016040519081016040528092919081815260200182805461091490613cd9565b80156109615780601f1061093657610100808354040283529160200191610961565b820191906000526020600020905b81548152906001019060200180831161094457829003601f168201915b5050505050905090565b600061097682611a5c565b6109b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ac90613890565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006109fb82610fbf565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a6390613930565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610a8b611a54565b73ffffffffffffffffffffffffffffffffffffffff161480610aba5750610ab981610ab4611a54565b6117ce565b5b610af9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610af0906137d0565b60405180910390fd5b610b038383611ac8565b505050565b600d5481565b6000600880549050905090565b600f5481565b610b32610b2c611a54565b82611b81565b610b71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6890613970565b60405180910390fd5b610b7c838383611c5f565b505050565b6000610b8c836110ff565b8210610bcd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bc4906136d0565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610c2e611a54565b73ffffffffffffffffffffffffffffffffffffffff16610c4c6112c5565b73ffffffffffffffffffffffffffffffffffffffff1614610ca2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c99906138b0565b60405180910390fd5b60003373ffffffffffffffffffffffffffffffffffffffff1647604051610cc8906135f5565b60006040518083038185875af1925050503d8060008114610d05576040519150601f19603f3d011682016040523d82523d6000602084013e610d0a565b606091505b5050905080610d4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4590613790565b60405180910390fd5b50565b610d6c83838360405180602001604052806000815250611598565b505050565b60606000610d7e836110ff565b905060008167ffffffffffffffff811115610d9c57610d9b613ea1565b5b604051908082528060200260200182016040528015610dca5781602001602082028036833780820191505090505b50905060005b82811015610e1457610de28582610b81565b828281518110610df557610df4613e72565b5b6020026020010181815250508080610e0c90613d3c565b915050610dd0565b508092505050919050565b610e27611a54565b73ffffffffffffffffffffffffffffffffffffffff16610e456112c5565b73ffffffffffffffffffffffffffffffffffffffff1614610e9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e92906138b0565b60405180910390fd5b80600d8190555050565b6000610eaf610b0e565b8210610ef0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee790613990565b60405180910390fd5b60088281548110610f0457610f03613e72565b5b90600052602060002001549050919050565b610f1e611a54565b73ffffffffffffffffffffffffffffffffffffffff16610f3c6112c5565b73ffffffffffffffffffffffffffffffffffffffff1614610f92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f89906138b0565b60405180910390fd5b80600b9080519060200190610fa8929190612bd9565b5050565b601060009054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611068576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105f90613810565b60405180910390fd5b80915050919050565b600b805461107e90613cd9565b80601f01602080910402602001604051908101604052809291908181526020018280546110aa90613cd9565b80156110f75780601f106110cc576101008083540402835291602001916110f7565b820191906000526020600020905b8154815290600101906020018083116110da57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611170576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611167906137f0565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6111bf611a54565b73ffffffffffffffffffffffffffffffffffffffff166111dd6112c5565b73ffffffffffffffffffffffffffffffffffffffff1614611233576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122a906138b0565b60405180910390fd5b61123d6000611ebb565b565b611247611a54565b73ffffffffffffffffffffffffffffffffffffffff166112656112c5565b73ffffffffffffffffffffffffffffffffffffffff16146112bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b2906138b0565b60405180910390fd5b80600f8190555050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546112fe90613cd9565b80601f016020809104026020016040519081016040528092919081815260200182805461132a90613cd9565b80156113775780601f1061134c57610100808354040283529160200191611377565b820191906000526020600020905b81548152906001019060200180831161135a57829003601f168201915b5050505050905090565b601060009054906101000a900460ff16156113d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113c8906138d0565b60405180910390fd5b60006113db610b0e565b905060008211611420576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611417906139b0565b60405180910390fd5b600f54821115611465576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161145c90613850565b60405180910390fd5b600e5482826114749190613b0e565b11156114b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114ac90613830565b60405180910390fd5b6114bd6112c5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461154757816114fa8284611f81565b6115049190613b95565b341015611546576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161153d90613950565b60405180910390fd5b5b6000600190505b82811161157d5761156a3382846115659190613b0e565b611fbb565b808061157590613d3c565b91505061154e565b505050565b61159461158d611a54565b8383611fd9565b5050565b6115a96115a3611a54565b83611b81565b6115e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115df90613970565b60405180910390fd5b6115f484848484612146565b50505050565b600c805461160790613cd9565b80601f016020809104026020016040519081016040528092919081815260200182805461163390613cd9565b80156116805780601f1061165557610100808354040283529160200191611680565b820191906000526020600020905b81548152906001019060200180831161166357829003601f168201915b505050505081565b606061169382611a5c565b6116d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116c990613910565b60405180910390fd5b60006116dc6121a2565b905060008151116116fc576040518060200160405280600081525061172a565b8061170684612234565b600c60405160200161171a939291906135c4565b6040516020818303038152906040525b915050919050565b600e5481565b611740611a54565b73ffffffffffffffffffffffffffffffffffffffff1661175e6112c5565b73ffffffffffffffffffffffffffffffffffffffff16146117b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117ab906138b0565b60405180910390fd5b80600c90805190602001906117ca929190612bd9565b5050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61186a611a54565b73ffffffffffffffffffffffffffffffffffffffff166118886112c5565b73ffffffffffffffffffffffffffffffffffffffff16146118de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d5906138b0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561194e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194590613710565b60405180910390fd5b61195781611ebb565b50565b600080823b905060008111915050919050565b505050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611a3d57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611a4d5750611a4c82612395565b5b9050919050565b600033905090565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611b3b83610fbf565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611b8c82611a5c565b611bcb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bc2906137b0565b60405180910390fd5b6000611bd683610fbf565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611c4557508373ffffffffffffffffffffffffffffffffffffffff16611c2d8461096b565b73ffffffffffffffffffffffffffffffffffffffff16145b80611c565750611c5581856117ce565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611c7f82610fbf565b73ffffffffffffffffffffffffffffffffffffffff1614611cd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ccc906138f0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d3c90613750565b60405180910390fd5b611d508383836123ff565b611d5b600082611ac8565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611dab9190613bef565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e029190613b0e565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60006101f58284611f929190613b0e565b1015611fa15760009050611fb5565b600e548311611fb457600d549050611fb5565b5b92915050565b611fd5828260405180602001604052806000815250612513565b5050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612048576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161203f90613770565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516121399190613693565b60405180910390a3505050565b612151848484611c5f565b61215d8484848461256e565b61219c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612193906136f0565b60405180910390fd5b50505050565b6060600b80546121b190613cd9565b80601f01602080910402602001604051908101604052809291908181526020018280546121dd90613cd9565b801561222a5780601f106121ff5761010080835404028352916020019161222a565b820191906000526020600020905b81548152906001019060200180831161220d57829003601f168201915b5050505050905090565b6060600082141561227c576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612390565b600082905060005b600082146122ae57808061229790613d3c565b915050600a826122a79190613b64565b9150612284565b60008167ffffffffffffffff8111156122ca576122c9613ea1565b5b6040519080825280601f01601f1916602001820160405280156122fc5781602001600182028036833780820191505090505b5090505b60008514612389576001826123159190613bef565b9150600a856123249190613d85565b60306123309190613b0e565b60f81b81838151811061234657612345613e72565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856123829190613b64565b9450612300565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b61240a83838361196d565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561244d5761244881612705565b61248c565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461248b5761248a838261274e565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156124cf576124ca816128bb565b61250e565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161461250d5761250c828261298c565b5b5b505050565b61251d8383612a0b565b61252a600084848461256e565b612569576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612560906136f0565b60405180910390fd5b505050565b600061258f8473ffffffffffffffffffffffffffffffffffffffff1661195a565b156126f8578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026125b8611a54565b8786866040518563ffffffff1660e01b81526004016125da9493929190613625565b602060405180830381600087803b1580156125f457600080fd5b505af192505050801561262557506040513d601f19601f820116820180604052508101906126229190612fe2565b60015b6126a8573d8060008114612655576040519150601f19603f3d011682016040523d82523d6000602084013e61265a565b606091505b506000815114156126a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612697906136f0565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506126fd565b600190505b949350505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161275b846110ff565b6127659190613bef565b905060006007600084815260200190815260200160002054905081811461284a576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016008805490506128cf9190613bef565b90506000600960008481526020019081526020016000205490506000600883815481106128ff576128fe613e72565b5b90600052602060002001549050806008838154811061292157612920613e72565b5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806129705761296f613e43565b5b6001900381819060005260206000200160009055905550505050565b6000612997836110ff565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612a7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a7290613870565b60405180910390fd5b612a8481611a5c565b15612ac4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612abb90613730565b60405180910390fd5b612ad0600083836123ff565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612b209190613b0e565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b828054612be590613cd9565b90600052602060002090601f016020900481019282612c075760008555612c4e565b82601f10612c2057805160ff1916838001178555612c4e565b82800160010185558215612c4e579182015b82811115612c4d578251825591602001919060010190612c32565b5b509050612c5b9190612c5f565b5090565b5b80821115612c78576000816000905550600101612c60565b5090565b6000612c8f612c8a84613a10565b6139eb565b905082815260208101848484011115612cab57612caa613ed5565b5b612cb6848285613c97565b509392505050565b6000612cd1612ccc84613a41565b6139eb565b905082815260208101848484011115612ced57612cec613ed5565b5b612cf8848285613c97565b509392505050565b600081359050612d0f8161450a565b92915050565b600081359050612d2481614521565b92915050565b600081359050612d3981614538565b92915050565b600081519050612d4e81614538565b92915050565b600082601f830112612d6957612d68613ed0565b5b8135612d79848260208601612c7c565b91505092915050565b600082601f830112612d9757612d96613ed0565b5b8135612da7848260208601612cbe565b91505092915050565b600081359050612dbf8161454f565b92915050565b600060208284031215612ddb57612dda613edf565b5b6000612de984828501612d00565b91505092915050565b60008060408385031215612e0957612e08613edf565b5b6000612e1785828601612d00565b9250506020612e2885828601612d00565b9150509250929050565b600080600060608486031215612e4b57612e4a613edf565b5b6000612e5986828701612d00565b9350506020612e6a86828701612d00565b9250506040612e7b86828701612db0565b9150509250925092565b60008060008060808587031215612e9f57612e9e613edf565b5b6000612ead87828801612d00565b9450506020612ebe87828801612d00565b9350506040612ecf87828801612db0565b925050606085013567ffffffffffffffff811115612ef057612eef613eda565b5b612efc87828801612d54565b91505092959194509250565b60008060408385031215612f1f57612f1e613edf565b5b6000612f2d85828601612d00565b9250506020612f3e85828601612d15565b9150509250929050565b60008060408385031215612f5f57612f5e613edf565b5b6000612f6d85828601612d00565b9250506020612f7e85828601612db0565b9150509250929050565b600060208284031215612f9e57612f9d613edf565b5b6000612fac84828501612d15565b91505092915050565b600060208284031215612fcb57612fca613edf565b5b6000612fd984828501612d2a565b91505092915050565b600060208284031215612ff857612ff7613edf565b5b600061300684828501612d3f565b91505092915050565b60006020828403121561302557613024613edf565b5b600082013567ffffffffffffffff81111561304357613042613eda565b5b61304f84828501612d82565b91505092915050565b60006020828403121561306e5761306d613edf565b5b600061307c84828501612db0565b91505092915050565b600061309183836135a6565b60208301905092915050565b6130a681613c23565b82525050565b60006130b782613a97565b6130c18185613ac5565b93506130cc83613a72565b8060005b838110156130fd5781516130e48882613085565b97506130ef83613ab8565b9250506001810190506130d0565b5085935050505092915050565b61311381613c35565b82525050565b600061312482613aa2565b61312e8185613ad6565b935061313e818560208601613ca6565b61314781613ee4565b840191505092915050565b600061315d82613aad565b6131678185613af2565b9350613177818560208601613ca6565b61318081613ee4565b840191505092915050565b600061319682613aad565b6131a08185613b03565b93506131b0818560208601613ca6565b80840191505092915050565b600081546131c981613cd9565b6131d38186613b03565b945060018216600081146131ee57600181146131ff57613232565b60ff19831686528186019350613232565b61320885613a82565b60005b8381101561322a5781548189015260018201915060208101905061320b565b838801955050505b50505092915050565b6000613248602b83613af2565b915061325382613ef5565b604082019050919050565b600061326b603283613af2565b915061327682613f44565b604082019050919050565b600061328e602683613af2565b915061329982613f93565b604082019050919050565b60006132b1601c83613af2565b91506132bc82613fe2565b602082019050919050565b60006132d4602483613af2565b91506132df8261400b565b604082019050919050565b60006132f7601983613af2565b91506133028261405a565b602082019050919050565b600061331a600d83613af2565b915061332582614083565b602082019050919050565b600061333d602c83613af2565b9150613348826140ac565b604082019050919050565b6000613360603883613af2565b915061336b826140fb565b604082019050919050565b6000613383602a83613af2565b915061338e8261414a565b604082019050919050565b60006133a6602983613af2565b91506133b182614199565b604082019050919050565b60006133c9601683613af2565b91506133d4826141e8565b602082019050919050565b60006133ec602483613af2565b91506133f782614211565b604082019050919050565b600061340f602083613af2565b915061341a82614260565b602082019050919050565b6000613432602c83613af2565b915061343d82614289565b604082019050919050565b6000613455602083613af2565b9150613460826142d8565b602082019050919050565b6000613478601683613af2565b915061348382614301565b602082019050919050565b600061349b602983613af2565b91506134a68261432a565b604082019050919050565b60006134be602f83613af2565b91506134c982614379565b604082019050919050565b60006134e1602183613af2565b91506134ec826143c8565b604082019050919050565b6000613504600083613ae7565b915061350f82614417565b600082019050919050565b6000613527601283613af2565b91506135328261441a565b602082019050919050565b600061354a603183613af2565b915061355582614443565b604082019050919050565b600061356d602c83613af2565b915061357882614492565b604082019050919050565b6000613590601b83613af2565b915061359b826144e1565b602082019050919050565b6135af81613c8d565b82525050565b6135be81613c8d565b82525050565b60006135d0828661318b565b91506135dc828561318b565b91506135e882846131bc565b9150819050949350505050565b6000613600826134f7565b9150819050919050565b600060208201905061361f600083018461309d565b92915050565b600060808201905061363a600083018761309d565b613647602083018661309d565b61365460408301856135b5565b81810360608301526136668184613119565b905095945050505050565b6000602082019050818103600083015261368b81846130ac565b905092915050565b60006020820190506136a8600083018461310a565b92915050565b600060208201905081810360008301526136c88184613152565b905092915050565b600060208201905081810360008301526136e98161323b565b9050919050565b600060208201905081810360008301526137098161325e565b9050919050565b6000602082019050818103600083015261372981613281565b9050919050565b60006020820190508181036000830152613749816132a4565b9050919050565b60006020820190508181036000830152613769816132c7565b9050919050565b60006020820190508181036000830152613789816132ea565b9050919050565b600060208201905081810360008301526137a98161330d565b9050919050565b600060208201905081810360008301526137c981613330565b9050919050565b600060208201905081810360008301526137e981613353565b9050919050565b6000602082019050818103600083015261380981613376565b9050919050565b6000602082019050818103600083015261382981613399565b9050919050565b60006020820190508181036000830152613849816133bc565b9050919050565b60006020820190508181036000830152613869816133df565b9050919050565b6000602082019050818103600083015261388981613402565b9050919050565b600060208201905081810360008301526138a981613425565b9050919050565b600060208201905081810360008301526138c981613448565b9050919050565b600060208201905081810360008301526138e98161346b565b9050919050565b600060208201905081810360008301526139098161348e565b9050919050565b60006020820190508181036000830152613929816134b1565b9050919050565b60006020820190508181036000830152613949816134d4565b9050919050565b600060208201905081810360008301526139698161351a565b9050919050565b600060208201905081810360008301526139898161353d565b9050919050565b600060208201905081810360008301526139a981613560565b9050919050565b600060208201905081810360008301526139c981613583565b9050919050565b60006020820190506139e560008301846135b5565b92915050565b60006139f5613a06565b9050613a018282613d0b565b919050565b6000604051905090565b600067ffffffffffffffff821115613a2b57613a2a613ea1565b5b613a3482613ee4565b9050602081019050919050565b600067ffffffffffffffff821115613a5c57613a5b613ea1565b5b613a6582613ee4565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000613b1982613c8d565b9150613b2483613c8d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613b5957613b58613db6565b5b828201905092915050565b6000613b6f82613c8d565b9150613b7a83613c8d565b925082613b8a57613b89613de5565b5b828204905092915050565b6000613ba082613c8d565b9150613bab83613c8d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613be457613be3613db6565b5b828202905092915050565b6000613bfa82613c8d565b9150613c0583613c8d565b925082821015613c1857613c17613db6565b5b828203905092915050565b6000613c2e82613c6d565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613cc4578082015181840152602081019050613ca9565b83811115613cd3576000848401525b50505050565b60006002820490506001821680613cf157607f821691505b60208210811415613d0557613d04613e14565b5b50919050565b613d1482613ee4565b810181811067ffffffffffffffff82111715613d3357613d32613ea1565b5b80604052505050565b6000613d4782613c8d565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613d7a57613d79613db6565b5b600182019050919050565b6000613d9082613c8d565b9150613d9b83613c8d565b925082613dab57613daa613de5565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f5472616e73666572204661696c00000000000000000000000000000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f6d6178204e4654206c696d697420657863656564656400000000000000000000600082015250565b7f6d6178206d696e7420616d6f756e74207065722073657373696f6e206578636560008201527f6564656400000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f74686520636f6e74726163742069732070617573656400000000000000000000600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f696e73756666696369656e742066756e64730000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f6e65656420746f206d696e74206174206c656173742031204e46540000000000600082015250565b61451381613c23565b811461451e57600080fd5b50565b61452a81613c35565b811461453557600080fd5b50565b61454181613c41565b811461454c57600080fd5b50565b61455881613c8d565b811461456357600080fd5b5056fea2646970667358221220c2fca982850efc107b7ea0ffcad2356248c278aa53c72424e86d5ae8c0ad537564736f6c63430008070033
Verified Source Code Full Match
Compiler: v0.8.7+commit.e28d00a7
EVM: london
Optimization: No
AlienArena.sol 1389 lines
// SPDX-License-Identifier: GPL-3.0
// File: @openzeppelin/contracts/utils/Strings.sol
// 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);
}
}
// File: @openzeppelin/contracts/utils/Context.sol
// 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;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
}
// File: @openzeppelin/contracts/utils/Address.sol
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
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);
}
/**
* @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);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// 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);
}
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
// 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);
}
// File: @openzeppelin/contracts/utils/introspection/ERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
/**
* @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;
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
/**
* @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;
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
/**
* @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 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 {}
}
// File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)
pragma solidity ^0.8.0;
/**
* @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();
}
}
// File: contracts/ALIEN.sol
pragma solidity >=0.7.0 <0.9.0;
contract Alien_Arena is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.05 ether;
uint256 public maxSupply = 5000;
uint256 public maxMintAmount = 20;
bool public paused = false;
constructor() ERC721("ALIEN ARENA", "ALIEN ARENA") {
setBaseURI("ipfs://QmRiGHfZ1RTboBbNuvNTTpAZVsbXfjSHAQnoDEWvTZWpA7/");
mint(1);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
function calcMintingFee(uint256 _supply, uint256 _mintAmount) internal view returns(uint256 _cost) {
if(_supply + _mintAmount < 501) {
return 0 ether;
}
if(_supply <= maxSupply) {
return cost;
}
}
// Public
function mint(uint256 _mintAmount) public payable {
require(!paused, "the contract is paused");
uint256 supply = totalSupply();
require(_mintAmount > 0, "need to mint at least 1 NFT");
require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded");
require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");
if (msg.sender != owner()) {
require(msg.value >= calcMintingFee(supply, _mintAmount) * _mintAmount, "insufficient funds");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
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 setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{value: address(this).balance}("");
require(success, "Transfer Fail");
}
}
Read Contract
balanceOf 0x70a08231 → uint256
baseExtension 0xc6682862 → string
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
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
mint 0xa0712d68
uint256 _mintAmount
pause 0x02329a29
bool _state
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
setBaseExtension 0xda3ef23f
string _newBaseExtension
setBaseURI 0x55f804b3
string _newBaseURI
setCost 0x44a0d68a
uint256 _newCost
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