Address Contract Partially Verified
Address
0x1401D33B02EE7460e68e4832a96e20FB0552dB14
Balance
0 ETH
Nonce
1
Code Size
19302 bytes
Creator
0xcbCdE7fb...A8b2 at tx 0xde237b41...9d9b50
Indexed Transactions
0
Contract Bytecode
19302 bytes
0x6080604052600436106102935760003560e01c806377e563571161015a578063ba41b0c6116100c1578063d1d192131161007a578063d1d192131461098c578063d5abeb01146109b5578063da3ef23f146109e0578063e985e9c514610a09578063f2c4ce1e14610a46578063f2fde38b14610a6f57610293565b8063ba41b0c614610877578063ba4e5c4914610893578063ba7d2c76146108d0578063c6682862146108fb578063c87b56dd14610926578063d0eb26b01461096357610293565b80638da5cb5b116101135780638da5cb5b1461078d5780638e1f9cfe146107b857806395d89b41146107e3578063a22cb4651461080e578063a475b5dd14610837578063b88d4fde1461084e57610293565b806377e56357146106b95780637cb64759146106d05780637f00c7a6146106f9578063811d2437146107225780638456cb591461074b578063872d10ea1461076257610293565b806323b872dd116101fe57806355f804b3116101b757806355f804b3146105975780635a23dd99146105c05780636352211e146105fd5780636c0360eb1461063a57806370a0823114610665578063715018a6146106a257610293565b806323b872dd146104d0578063295e4c33146104f95780633ccfd60b1461051057806342842e0e1461051a57806344a0d68a14610543578063518302271461056c57610293565b80630c3f6acf116102505780630c3f6acf146103bc57806313093b1d146103e757806313faede61461041257806318160ddd1461043d57806318cae26914610468578063239c70ae146104a557610293565b806301ffc9a71461029857806306afd592146102d557806306fdde0314610300578063081812fc1461032b578063081c8c4414610368578063095ea7b314610393575b600080fd5b3480156102a457600080fd5b506102bf60048036038101906102ba91906135de565b610a98565b6040516102cc9190613cdd565b60405180910390f35b3480156102e157600080fd5b506102ea610b7a565b6040516102f79190614035565b60405180910390f35b34801561030c57600080fd5b50610315610b80565b6040516103229190613d13565b60405180910390f35b34801561033757600080fd5b50610352600480360381019061034d9190613671565b610c12565b60405161035f9190613c76565b60405180910390f35b34801561037457600080fd5b5061037d610c97565b60405161038a9190613d13565b60405180910390f35b34801561039f57600080fd5b506103ba60048036038101906103b59190613579565b610d25565b005b3480156103c857600080fd5b506103d1610e3d565b6040516103de9190614035565b60405180910390f35b3480156103f357600080fd5b506103fc610e43565b6040516104099190614035565b60405180910390f35b34801561041e57600080fd5b50610427610e49565b6040516104349190614035565b60405180910390f35b34801561044957600080fd5b50610452610e4f565b60405161045f9190614035565b60405180910390f35b34801561047457600080fd5b5061048f600480360381019061048a91906133b6565b610e59565b60405161049c9190614035565b60405180910390f35b3480156104b157600080fd5b506104ba610e71565b6040516104c79190614035565b60405180910390f35b3480156104dc57600080fd5b506104f760048036038101906104f2919061341b565b610e77565b005b34801561050557600080fd5b5061050e610ed7565b005b610518610f5d565b005b34801561052657600080fd5b50610541600480360381019061053c919061341b565b611059565b005b34801561054f57600080fd5b5061056a60048036038101906105659190613671565b611079565b005b34801561057857600080fd5b506105816110ff565b60405161058e9190613cdd565b60405180910390f35b3480156105a357600080fd5b506105be60048036038101906105b99190613630565b611112565b005b3480156105cc57600080fd5b506105e760048036038101906105e291906134e5565b6111a8565b6040516105f49190613cdd565b60405180910390f35b34801561060957600080fd5b50610624600480360381019061061f9190613671565b61126d565b6040516106319190613c76565b60405180910390f35b34801561064657600080fd5b5061064f61131f565b60405161065c9190613d13565b60405180910390f35b34801561067157600080fd5b5061068c600480360381019061068791906133b6565b6113ad565b6040516106999190614035565b60405180910390f35b3480156106ae57600080fd5b506106b7611465565b005b3480156106c557600080fd5b506106ce6114ed565b005b3480156106dc57600080fd5b506106f760048036038101906106f291906135b5565b611573565b005b34801561070557600080fd5b50610720600480360381019061071b9190613671565b6115f9565b005b34801561072e57600080fd5b5061074960048036038101906107449190613671565b61167f565b005b34801561075757600080fd5b50610760611705565b005b34801561076e57600080fd5b5061077761178b565b6040516107849190614035565b60405180910390f35b34801561079957600080fd5b506107a2611791565b6040516107af9190613c76565b60405180910390f35b3480156107c457600080fd5b506107cd6117bb565b6040516107da9190613cf8565b60405180910390f35b3480156107ef57600080fd5b506107f86117c1565b6040516108059190613d13565b60405180910390f35b34801561081a57600080fd5b506108356004803603810190610830919061353d565b611853565b005b34801561084357600080fd5b5061084c6119d4565b005b34801561085a57600080fd5b506108756004803603810190610870919061346a565b611a6d565b005b610891600480360381019061088c919061369a565b611acf565b005b34801561089f57600080fd5b506108ba60048036038101906108b59190613671565b611e6d565b6040516108c79190613c76565b60405180910390f35b3480156108dc57600080fd5b506108e5611eac565b6040516108f29190614035565b60405180910390f35b34801561090757600080fd5b50610910611eb2565b60405161091d9190613d13565b60405180910390f35b34801561093257600080fd5b5061094d60048036038101906109489190613671565b611f40565b60405161095a9190613d13565b60405180910390f35b34801561096f57600080fd5b5061098a60048036038101906109859190613671565b612099565b005b34801561099857600080fd5b506109b360048036038101906109ae9190613671565b61211f565b005b3480156109c157600080fd5b506109ca6121a5565b6040516109d79190614035565b60405180910390f35b3480156109ec57600080fd5b50610a076004803603810190610a029190613630565b6121ab565b005b348015610a1557600080fd5b50610a306004803603810190610a2b91906133df565b612241565b604051610a3d9190613cdd565b60405180910390f35b348015610a5257600080fd5b50610a6d6004803603810190610a689190613630565b6122d5565b005b348015610a7b57600080fd5b50610a966004803603810190610a9191906133b6565b61236b565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610b6357507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610b735750610b7282612463565b5b9050919050565b600b5481565b606060008054610b8f9061430f565b80601f0160208091040260200160405190810160405280929190818152602001828054610bbb9061430f565b8015610c085780601f10610bdd57610100808354040283529160200191610c08565b820191906000526020600020905b815481529060010190602001808311610beb57829003601f168201915b5050505050905090565b6000610c1d826124cd565b610c5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5390613ef5565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60098054610ca49061430f565b80601f0160208091040260200160405190810160405280929190818152602001828054610cd09061430f565b8015610d1d5780601f10610cf257610100808354040283529160200191610d1d565b820191906000526020600020905b815481529060010190602001808311610d0057829003601f168201915b505050505081565b6000610d308261126d565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610da1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d9890613f95565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610dc0612539565b73ffffffffffffffffffffffffffffffffffffffff161480610def5750610dee81610de9612539565b612241565b5b610e2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2590613e35565b60405180910390fd5b610e388383612541565b505050565b60145481565b600d5481565b600a5481565b6000601154905090565b60136020528060005260406000206000915090505481565b600e5481565b610e88610e82612539565b826125fa565b610ec7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ebe90613fd5565b60405180910390fd5b610ed28383836126d8565b505050565b610edf612539565b73ffffffffffffffffffffffffffffffffffffffff16610efd611791565b73ffffffffffffffffffffffffffffffffffffffff1614610f53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4a90613f15565b60405180910390fd5b6001601481905550565b610f65612539565b73ffffffffffffffffffffffffffffffffffffffff16610f83611791565b73ffffffffffffffffffffffffffffffffffffffff1614610fd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fd090613f15565b60405180910390fd5b6000610fe3611791565b73ffffffffffffffffffffffffffffffffffffffff164760405161100690613c61565b60006040518083038185875af1925050503d8060008114611043576040519150601f19603f3d011682016040523d82523d6000602084013e611048565b606091505b505090508061105657600080fd5b50565b61107483838360405180602001604052806000815250611a6d565b505050565b611081612539565b73ffffffffffffffffffffffffffffffffffffffff1661109f611791565b73ffffffffffffffffffffffffffffffffffffffff16146110f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110ec90613f15565b60405180910390fd5b80600a8190555050565b601260009054906101000a900460ff1681565b61111a612539565b73ffffffffffffffffffffffffffffffffffffffff16611138611791565b73ffffffffffffffffffffffffffffffffffffffff161461118e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118590613f15565b60405180910390fd5b80600790805190602001906111a492919061317b565b5050565b600080846040516020016111bc9190613be9565b604051602081830303815290604052805190602001209050611222848480806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505060165483612934565b611261576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125890613df5565b60405180910390fd5b60019150509392505050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611316576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130d90613e75565b60405180910390fd5b80915050919050565b6007805461132c9061430f565b80601f01602080910402602001604051908101604052809291908181526020018280546113589061430f565b80156113a55780601f1061137a576101008083540402835291602001916113a5565b820191906000526020600020905b81548152906001019060200180831161138857829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561141e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141590613e55565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61146d612539565b73ffffffffffffffffffffffffffffffffffffffff1661148b611791565b73ffffffffffffffffffffffffffffffffffffffff16146114e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d890613f15565b60405180910390fd5b6114eb600061294b565b565b6114f5612539565b73ffffffffffffffffffffffffffffffffffffffff16611513611791565b73ffffffffffffffffffffffffffffffffffffffff1614611569576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161156090613f15565b60405180910390fd5b6002601481905550565b61157b612539565b73ffffffffffffffffffffffffffffffffffffffff16611599611791565b73ffffffffffffffffffffffffffffffffffffffff16146115ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115e690613f15565b60405180910390fd5b8060168190555050565b611601612539565b73ffffffffffffffffffffffffffffffffffffffff1661161f611791565b73ffffffffffffffffffffffffffffffffffffffff1614611675576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166c90613f15565b60405180910390fd5b80600e8190555050565b611687612539565b73ffffffffffffffffffffffffffffffffffffffff166116a5611791565b73ffffffffffffffffffffffffffffffffffffffff16146116fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f290613f15565b60405180910390fd5b80600a8190555050565b61170d612539565b73ffffffffffffffffffffffffffffffffffffffff1661172b611791565b73ffffffffffffffffffffffffffffffffffffffff1614611781576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161177890613f15565b60405180910390fd5b6000601481905550565b600f5481565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60165481565b6060600180546117d09061430f565b80601f01602080910402602001604051908101604052809291908181526020018280546117fc9061430f565b80156118495780601f1061181e57610100808354040283529160200191611849565b820191906000526020600020905b81548152906001019060200180831161182c57829003601f168201915b5050505050905090565b61185b612539565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c090613dd5565b60405180910390fd5b80600560006118d6612539565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611983612539565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516119c89190613cdd565b60405180910390a35050565b6119dc612539565b73ffffffffffffffffffffffffffffffffffffffff166119fa611791565b73ffffffffffffffffffffffffffffffffffffffff1614611a50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a4790613f15565b60405180910390fd5b6001601260006101000a81548160ff021916908315150217905550565b611a7e611a78612539565b836125fa565b611abd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ab490613fd5565b60405180910390fd5b611ac984848484612a11565b50505050565b6000611ad9610e4f565b905060008411611b1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b1590614015565b60405180910390fd5b600c548482611b2d919061413a565b1115611b6e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6590613e95565b60405180910390fd5b611b76611791565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611dc357600060145411611bed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611be490613f35565b60405180910390fd5b6000601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060016014541415611d7057611c473385856111a8565b611c86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7d90613ff5565b60405180910390fd5b84600b54611c9491906141c1565b341015611cd6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ccd90613fb5565b60405180910390fd5b600d54851115611d1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d1290613eb5565b60405180910390fd5b600f548582611d2a919061413a565b1115611d6b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d6290613d95565b60405180910390fd5b611dc1565b84600a54611d7e91906141c1565b341015611dc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611db790613fb5565b60405180910390fd5b5b505b6000600190505b848111611e6657601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190611e2190614372565b9190505550611e3b338284611e36919061413a565b612a6d565b60116000815480929190611e4e90614372565b91905055508080611e5e90614372565b915050611dca565b5050505050565b60158181548110611e7d57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60105481565b60088054611ebf9061430f565b80601f0160208091040260200160405190810160405280929190818152602001828054611eeb9061430f565b8015611f385780601f10611f0d57610100808354040283529160200191611f38565b820191906000526020600020905b815481529060010190602001808311611f1b57829003601f168201915b505050505081565b6060611f4b826124cd565b611f8a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f8190613f75565b60405180910390fd5b60001515601260009054906101000a900460ff16151514156120385760098054611fb39061430f565b80601f0160208091040260200160405190810160405280929190818152602001828054611fdf9061430f565b801561202c5780601f106120015761010080835404028352916020019161202c565b820191906000526020600020905b81548152906001019060200180831161200f57829003601f168201915b50505050509050612094565b6000612042612a8b565b905060008151116120625760405180602001604052806000815250612090565b8061206c84612b1d565b600860405160200161208093929190613c30565b6040516020818303038152906040525b9150505b919050565b6120a1612539565b73ffffffffffffffffffffffffffffffffffffffff166120bf611791565b73ffffffffffffffffffffffffffffffffffffffff1614612115576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161210c90613f15565b60405180910390fd5b8060108190555050565b612127612539565b73ffffffffffffffffffffffffffffffffffffffff16612145611791565b73ffffffffffffffffffffffffffffffffffffffff161461219b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161219290613f15565b60405180910390fd5b80600b8190555050565b600c5481565b6121b3612539565b73ffffffffffffffffffffffffffffffffffffffff166121d1611791565b73ffffffffffffffffffffffffffffffffffffffff1614612227576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161221e90613f15565b60405180910390fd5b806008908051906020019061223d92919061317b565b5050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6122dd612539565b73ffffffffffffffffffffffffffffffffffffffff166122fb611791565b73ffffffffffffffffffffffffffffffffffffffff1614612351576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161234890613f15565b60405180910390fd5b806009908051906020019061236792919061317b565b5050565b612373612539565b73ffffffffffffffffffffffffffffffffffffffff16612391611791565b73ffffffffffffffffffffffffffffffffffffffff16146123e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123de90613f15565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612457576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161244e90613d55565b60405180910390fd5b6124608161294b565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166125b48361126d565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000612605826124cd565b612644576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161263b90613e15565b60405180910390fd5b600061264f8361126d565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806126be57508373ffffffffffffffffffffffffffffffffffffffff166126a684610c12565b73ffffffffffffffffffffffffffffffffffffffff16145b806126cf57506126ce8185612241565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166126f88261126d565b73ffffffffffffffffffffffffffffffffffffffff161461274e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161274590613f55565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156127be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127b590613db5565b60405180910390fd5b6127c9838383612cca565b6127d4600082612541565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612824919061421b565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461287b919061413a565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000826129418584612ccf565b1490509392505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b612a1c8484846126d8565b612a2884848484612da8565b612a67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a5e90613d35565b60405180910390fd5b50505050565b612a87828260405180602001604052806000815250612f3f565b5050565b606060078054612a9a9061430f565b80601f0160208091040260200160405190810160405280929190818152602001828054612ac69061430f565b8015612b135780601f10612ae857610100808354040283529160200191612b13565b820191906000526020600020905b815481529060010190602001808311612af657829003601f168201915b5050505050905090565b60606000821415612b65576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612cc5565b600082905060005b60008214612b97578080612b8090614372565b915050600a82612b909190614190565b9150612b6d565b60008167ffffffffffffffff811115612bd9577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612c0b5781602001600182028036833780820191505090505b5090505b60008514612cbe57600182612c24919061421b565b9150600a85612c3391906143e9565b6030612c3f919061413a565b60f81b818381518110612c7b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612cb79190614190565b9450612c0f565b8093505050505b919050565b505050565b60008082905060005b8451811015612d9d576000858281518110612d1c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050808311612d5d578281604051602001612d40929190613c04565b604051602081830303815290604052805190602001209250612d89565b8083604051602001612d70929190613c04565b6040516020818303038152906040528051906020012092505b508080612d9590614372565b915050612cd8565b508091505092915050565b6000612dc98473ffffffffffffffffffffffffffffffffffffffff16612f9a565b15612f32578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612df2612539565b8786866040518563ffffffff1660e01b8152600401612e149493929190613c91565b602060405180830381600087803b158015612e2e57600080fd5b505af1925050508015612e5f57506040513d601f19601f82011682018060405250810190612e5c9190613607565b60015b612ee2573d8060008114612e8f576040519150601f19603f3d011682016040523d82523d6000602084013e612e94565b606091505b50600081511415612eda576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ed190613d35565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612f37565b600190505b949350505050565b612f498383612fad565b612f566000848484612da8565b612f95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f8c90613d35565b60405180910390fd5b505050565b600080823b905060008111915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561301d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161301490613ed5565b60405180910390fd5b613026816124cd565b15613066576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161305d90613d75565b60405180910390fd5b61307260008383612cca565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546130c2919061413a565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b8280546131879061430f565b90600052602060002090601f0160209004810192826131a957600085556131f0565b82601f106131c257805160ff19168380011785556131f0565b828001600101855582156131f0579182015b828111156131ef5782518255916020019190600101906131d4565b5b5090506131fd9190613201565b5090565b5b8082111561321a576000816000905550600101613202565b5090565b600061323161322c84614075565b614050565b90508281526020810184848401111561324957600080fd5b6132548482856142cd565b509392505050565b600061326f61326a846140a6565b614050565b90508281526020810184848401111561328757600080fd5b6132928482856142cd565b509392505050565b6000813590506132a981614abd565b92915050565b60008083601f8401126132c157600080fd5b8235905067ffffffffffffffff8111156132da57600080fd5b6020830191508360208202830111156132f257600080fd5b9250929050565b60008135905061330881614ad4565b92915050565b60008135905061331d81614aeb565b92915050565b60008135905061333281614b02565b92915050565b60008151905061334781614b02565b92915050565b600082601f83011261335e57600080fd5b813561336e84826020860161321e565b91505092915050565b600082601f83011261338857600080fd5b813561339884826020860161325c565b91505092915050565b6000813590506133b081614b19565b92915050565b6000602082840312156133c857600080fd5b60006133d68482850161329a565b91505092915050565b600080604083850312156133f257600080fd5b60006134008582860161329a565b92505060206134118582860161329a565b9150509250929050565b60008060006060848603121561343057600080fd5b600061343e8682870161329a565b935050602061344f8682870161329a565b9250506040613460868287016133a1565b9150509250925092565b6000806000806080858703121561348057600080fd5b600061348e8782880161329a565b945050602061349f8782880161329a565b93505060406134b0878288016133a1565b925050606085013567ffffffffffffffff8111156134cd57600080fd5b6134d98782880161334d565b91505092959194509250565b6000806000604084860312156134fa57600080fd5b60006135088682870161329a565b935050602084013567ffffffffffffffff81111561352557600080fd5b613531868287016132af565b92509250509250925092565b6000806040838503121561355057600080fd5b600061355e8582860161329a565b925050602061356f858286016132f9565b9150509250929050565b6000806040838503121561358c57600080fd5b600061359a8582860161329a565b92505060206135ab858286016133a1565b9150509250929050565b6000602082840312156135c757600080fd5b60006135d58482850161330e565b91505092915050565b6000602082840312156135f057600080fd5b60006135fe84828501613323565b91505092915050565b60006020828403121561361957600080fd5b600061362784828501613338565b91505092915050565b60006020828403121561364257600080fd5b600082013567ffffffffffffffff81111561365c57600080fd5b61366884828501613377565b91505092915050565b60006020828403121561368357600080fd5b6000613691848285016133a1565b91505092915050565b6000806000604084860312156136af57600080fd5b60006136bd868287016133a1565b935050602084013567ffffffffffffffff8111156136da57600080fd5b6136e6868287016132af565b92509250509250925092565b6136fb8161424f565b82525050565b61371261370d8261424f565b6143bb565b82525050565b61372181614261565b82525050565b6137308161426d565b82525050565b6137476137428261426d565b6143cd565b82525050565b6000613758826140ec565b6137628185614102565b93506137728185602086016142dc565b61377b816144d6565b840191505092915050565b6000613791826140f7565b61379b818561411e565b93506137ab8185602086016142dc565b6137b4816144d6565b840191505092915050565b60006137ca826140f7565b6137d4818561412f565b93506137e48185602086016142dc565b80840191505092915050565b600081546137fd8161430f565b613807818661412f565b94506001821660008114613822576001811461383357613866565b60ff19831686528186019350613866565b61383c856140d7565b60005b8381101561385e5781548189015260018201915060208101905061383f565b838801955050505b50505092915050565b600061387c60328361411e565b9150613887826144f4565b604082019050919050565b600061389f60268361411e565b91506138aa82614543565b604082019050919050565b60006138c2601c8361411e565b91506138cd82614592565b602082019050919050565b60006138e5601c8361411e565b91506138f0826145bb565b602082019050919050565b600061390860248361411e565b9150613913826145e4565b604082019050919050565b600061392b60198361411e565b915061393682614633565b602082019050919050565b600061394e60158361411e565b91506139598261465c565b602082019050919050565b6000613971602c8361411e565b915061397c82614685565b604082019050919050565b600061399460388361411e565b915061399f826146d4565b604082019050919050565b60006139b7602a8361411e565b91506139c282614723565b604082019050919050565b60006139da60298361411e565b91506139e582614772565b604082019050919050565b60006139fd60168361411e565b9150613a08826147c1565b602082019050919050565b6000613a2060248361411e565b9150613a2b826147ea565b604082019050919050565b6000613a4360208361411e565b9150613a4e82614839565b602082019050919050565b6000613a66602c8361411e565b9150613a7182614862565b604082019050919050565b6000613a8960208361411e565b9150613a94826148b1565b602082019050919050565b6000613aac60168361411e565b9150613ab7826148da565b602082019050919050565b6000613acf60298361411e565b9150613ada82614903565b604082019050919050565b6000613af2602f8361411e565b9150613afd82614952565b604082019050919050565b6000613b1560218361411e565b9150613b20826149a1565b604082019050919050565b6000613b38600083614113565b9150613b43826149f0565b600082019050919050565b6000613b5b60128361411e565b9150613b66826149f3565b602082019050919050565b6000613b7e60318361411e565b9150613b8982614a1c565b604082019050919050565b6000613ba160178361411e565b9150613bac82614a6b565b602082019050919050565b6000613bc4601b8361411e565b9150613bcf82614a94565b602082019050919050565b613be3816142c3565b82525050565b6000613bf58284613701565b60148201915081905092915050565b6000613c108285613736565b602082019150613c208284613736565b6020820191508190509392505050565b6000613c3c82866137bf565b9150613c4882856137bf565b9150613c5482846137f0565b9150819050949350505050565b6000613c6c82613b2b565b9150819050919050565b6000602082019050613c8b60008301846136f2565b92915050565b6000608082019050613ca660008301876136f2565b613cb360208301866136f2565b613cc06040830185613bda565b8181036060830152613cd2818461374d565b905095945050505050565b6000602082019050613cf26000830184613718565b92915050565b6000602082019050613d0d6000830184613727565b92915050565b60006020820190508181036000830152613d2d8184613786565b905092915050565b60006020820190508181036000830152613d4e8161386f565b9050919050565b60006020820190508181036000830152613d6e81613892565b9050919050565b60006020820190508181036000830152613d8e816138b5565b9050919050565b60006020820190508181036000830152613dae816138d8565b9050919050565b60006020820190508181036000830152613dce816138fb565b9050919050565b60006020820190508181036000830152613dee8161391e565b9050919050565b60006020820190508181036000830152613e0e81613941565b9050919050565b60006020820190508181036000830152613e2e81613964565b9050919050565b60006020820190508181036000830152613e4e81613987565b9050919050565b60006020820190508181036000830152613e6e816139aa565b9050919050565b60006020820190508181036000830152613e8e816139cd565b9050919050565b60006020820190508181036000830152613eae816139f0565b9050919050565b60006020820190508181036000830152613ece81613a13565b9050919050565b60006020820190508181036000830152613eee81613a36565b9050919050565b60006020820190508181036000830152613f0e81613a59565b9050919050565b60006020820190508181036000830152613f2e81613a7c565b9050919050565b60006020820190508181036000830152613f4e81613a9f565b9050919050565b60006020820190508181036000830152613f6e81613ac2565b9050919050565b60006020820190508181036000830152613f8e81613ae5565b9050919050565b60006020820190508181036000830152613fae81613b08565b9050919050565b60006020820190508181036000830152613fce81613b4e565b9050919050565b60006020820190508181036000830152613fee81613b71565b9050919050565b6000602082019050818103600083015261400e81613b94565b9050919050565b6000602082019050818103600083015261402e81613bb7565b9050919050565b600060208201905061404a6000830184613bda565b92915050565b600061405a61406b565b90506140668282614341565b919050565b6000604051905090565b600067ffffffffffffffff8211156140905761408f6144a7565b5b614099826144d6565b9050602081019050919050565b600067ffffffffffffffff8211156140c1576140c06144a7565b5b6140ca826144d6565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000614145826142c3565b9150614150836142c3565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156141855761418461441a565b5b828201905092915050565b600061419b826142c3565b91506141a6836142c3565b9250826141b6576141b5614449565b5b828204905092915050565b60006141cc826142c3565b91506141d7836142c3565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156142105761420f61441a565b5b828202905092915050565b6000614226826142c3565b9150614231836142c3565b9250828210156142445761424361441a565b5b828203905092915050565b600061425a826142a3565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156142fa5780820151818401526020810190506142df565b83811115614309576000848401525b50505050565b6000600282049050600182168061432757607f821691505b6020821081141561433b5761433a614478565b5b50919050565b61434a826144d6565b810181811067ffffffffffffffff82111715614369576143686144a7565b5b80604052505050565b600061437d826142c3565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156143b0576143af61441a565b5b600182019050919050565b60006143c6826143d7565b9050919050565b6000819050919050565b60006143e2826144e7565b9050919050565b60006143f4826142c3565b91506143ff836142c3565b92508261440f5761440e614449565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f6d6178204e465420706572206164647265737320657863656564656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f496e76616c6964204d65726b6c652050726f6f662e0000000000000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f6d6178204e4654206c696d697420657863656564656400000000000000000000600082015250565b7f6d6178206d696e7420616d6f756e74207065722073657373696f6e206578636560008201527f6564656400000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f74686520636f6e74726163742069732070617573656400000000000000000000600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f696e73756666696369656e742066756e64730000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f75736572206973206e6f742077686974656c6973746564000000000000000000600082015250565b7f6e65656420746f206d696e74206174206c656173742031204e46540000000000600082015250565b614ac68161424f565b8114614ad157600080fd5b50565b614add81614261565b8114614ae857600080fd5b50565b614af48161426d565b8114614aff57600080fd5b50565b614b0b81614277565b8114614b1657600080fd5b50565b614b22816142c3565b8114614b2d57600080fd5b5056fea264697066735822122015e2b0eee55b93bbfeb484e6deb2ddea0aeb52d134aa9a4b7e7d2bb6c49e64c764736f6c63430008040033
Verified Source Code Partial Match
Compiler: v0.8.4+commit.c7e474f2
EVM: istanbul
Optimization: No
Address.sol 255 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
// File: @openzeppelin/contracts/utils/Address.sol
/**
* @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);
}
}
}
}
Context.sol 23 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.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;
}
}
ERC165.sol 34 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.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;
}
}
ERC721.sol 496 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import './Address.sol';
import './Strings.sol';
import './Context.sol';
import './ERC165.sol';
import './IERC721.sol';
import './IERC721Metadata.sol';
import './IERC721Receiver.sol';
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165, IERC165)
returns (bool)
{
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner)
public
view
virtual
override
returns (uint256)
{
require(
owner != address(0),
"ERC721: balance query for the zero address"
);
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId)
public
view
virtual
override
returns (address)
{
address owner = _owners[tokenId];
require(
owner != address(0),
"ERC721: owner query for nonexistent token"
);
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory baseURI = _baseURI();
return
bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId)
public
view
virtual
override
returns (address)
{
require(
_exists(tokenId),
"ERC721: approved query for nonexistent token"
);
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved)
public
virtual
override
{
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator)
public
view
virtual
override
returns (bool)
{
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"ERC721: transfer caller is not owner nor approved"
);
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"ERC721: transfer caller is not owner nor approved"
);
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId)
internal
view
virtual
returns (bool)
{
require(
_exists(tokenId),
"ERC721: operator query for nonexistent token"
);
address owner = ERC721.ownerOf(tokenId);
return (spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(
ERC721.ownerOf(tokenId) == from,
"ERC721: transfer of token that is not own"
);
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try
IERC721Receiver(to).onERC721Received(
_msgSender(),
from,
tokenId,
_data
)
returns (bytes4 retval) {
return retval == IERC721Receiver.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 {}
}
ERC721Enumerable.sol 189 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.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();
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
/**
* @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);
}
IERC721.sol 161 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import './IERC165.sol';
// File: @openzeppelin/contracts/token/ERC721/IERC721.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;
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import './IERC721.sol';
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index)
external
view
returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.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);
}
IERC721Receiver.sol 25 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.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);
}
MartianMansion.sol 178 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import "./ERC721.sol";
import "./Ownable.sol";
import "./Strings.sol";
import "./Address.sol";
import "./MerkleProof.sol";
contract MartianMansion is ERC721, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
string public notRevealedUri;
uint256 public cost = 0.03 ether;
uint256 public costWL = 0.03 ether;
uint256 public maxSupply = 1200;
uint256 public maxMintAmountWL = 10;
uint256 public maxMintAmount = 10;
uint256 public nftPerAddressLimitWL = 10;
uint256 public nftPerAddressLimit = 10;
uint256 allTokens = 0;
bool public revealed = true;
mapping(address => uint256) public addressMintedBalance;
uint256 public currentState = 1;
address[] public whitelistedAddresses;
bytes32 public merkleRootWhitelist =
0x9d2af9a2bb58d43c5fbe37139a71186dbe2bd63b3c8b1e12f0941b24b8f59bc0;
constructor() ERC721("The Martian Mansion", "TMM") {
setBaseURI(
"ipfs://QmPHcao5BrxiZr2fvSor221x7iF4NFANoEbmKs8AF6DRvy/"
);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
function mint(uint256 _mintAmount, bytes32[] calldata _merkleProof) public payable {
uint256 supply = totalSupply();
require(_mintAmount > 0, "need to mint at least 1 NFT");
require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");
if (msg.sender != owner()) {
require(currentState > 0, "the contract is paused");
uint256 ownerMintedCount = addressMintedBalance[msg.sender];
if (currentState == 1) {
require(isWhitelisted(msg.sender, _merkleProof), "user is not whitelisted");
require(
msg.value >= costWL * _mintAmount,
"insufficient funds"
);
require(
_mintAmount <= maxMintAmountWL,
"max mint amount per session exceeded"
);
require(
ownerMintedCount + _mintAmount <= nftPerAddressLimitWL,
"max NFT per address exceeded"
);
} else {
require(msg.value >= cost * _mintAmount, "insufficient funds");
}
}
for (uint256 i = 1; i <= _mintAmount; i++) {
addressMintedBalance[msg.sender]++;
_safeMint(msg.sender, supply + i);
allTokens++;
}
}
function totalSupply() public view returns (uint256) {
return allTokens;
}
function isWhitelisted(address _user, bytes32[] calldata _merkleProof) public view returns (bool) {
bytes32 leaf = keccak256(abi.encodePacked(_user));
require(
MerkleProof.verify(_merkleProof, merkleRootWhitelist, leaf),
"Invalid Merkle Proof."
);
return true;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function reveal() public onlyOwner {
revealed = true;
}
function setNftPerAddressLimit(uint256 _limit) public onlyOwner {
nftPerAddressLimit = _limit;
}
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 setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function pause() public onlyOwner {
currentState = 0;
}
function setOnlyWhitelisted() public onlyOwner {
currentState = 1;
}
function setPublic() public onlyOwner {
currentState = 2;
}
function setMerkleRoot(bytes32 _newMerkleRoot) public onlyOwner {
merkleRootWhitelist = _newMerkleRoot;
}
function setPublicCost(uint256 _price) public onlyOwner {
cost = _price;
}
function setWLCost(uint256 _price) public onlyOwner {
costWL = _price;
}
function withdraw() public payable onlyOwner {
// This will payout the owner the contract balance.
// Do not remove this otherwise you will not be able to withdraw the funds.
// =============================================================================
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
// =============================================================================
}
}
MerkleProof.sol 52 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Trees proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "./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);
}
}
Strings.sol 70 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.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);
}
}
Read Contract
addressMintedBalance 0x18cae269 → uint256
balanceOf 0x70a08231 → uint256
baseExtension 0xc6682862 → string
baseURI 0x6c0360eb → string
cost 0x13faede6 → uint256
costWL 0x06afd592 → uint256
currentState 0x0c3f6acf → uint256
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
isWhitelisted 0x5a23dd99 → bool
maxMintAmount 0x239c70ae → uint256
maxMintAmountWL 0x13093b1d → uint256
maxSupply 0xd5abeb01 → uint256
merkleRootWhitelist 0x8e1f9cfe → bytes32
name 0x06fdde03 → string
nftPerAddressLimit 0xba7d2c76 → uint256
nftPerAddressLimitWL 0x872d10ea → uint256
notRevealedUri 0x081c8c44 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
revealed 0x51830227 → bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
whitelistedAddresses 0xba4e5c49 → address
Write Contract 22 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
mint 0xba41b0c6
uint256 _mintAmount
bytes32[] _merkleProof
pause 0x8456cb59
No parameters
renounceOwnership 0x715018a6
No parameters
reveal 0xa475b5dd
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
setMerkleRoot 0x7cb64759
bytes32 _newMerkleRoot
setNftPerAddressLimit 0xd0eb26b0
uint256 _limit
setNotRevealedURI 0xf2c4ce1e
string _notRevealedURI
setOnlyWhitelisted 0x295e4c33
No parameters
setPublic 0x77e56357
No parameters
setPublicCost 0x811d2437
uint256 _price
setWLCost 0xd1d19213
uint256 _price
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