Address Contract Partially Verified
Address
0x8009250878eD378050eF5D2a48c70E24EB2edE7E
Balance
0 ETH
Nonce
1
Code Size
14738 bytes
Creator
0xa64ded68...6B6c at tx 0xa2438022...2b333d
Indexed Transactions
0
Contract Bytecode
14738 bytes
0x6080604052600436106102ae5760003560e01c806376d5de8511610175578063c30f4a5a116100dc578063eac989f811610095578063f2fde38b1161006f578063f2fde38b14610844578063f7073c3a14610864578063fe60d12c14610879578063fe6feca21461088f576102ae565b8063eac989f8146107ec578063eced387314610801578063ee25560b14610817576102ae565b8063c30f4a5a14610721578063c87b56dd14610741578063de31c97214610761578063e2eedf921461077b578063e985e9c51461078e578063ea156a9b146107d7576102ae565b80639b9a5ef91161012e5780639b9a5ef9146106515780639e34070f146106715780639e8e54e114610691578063a22cb465146106c1578063a2e4b12e146106e1578063b88d4fde14610701576102ae565b806376d5de85146105a2578063827c3805146105c25780638421b687146105e25780638d859f3e146106025780638da5cb5b1461061e57806395d89b411461063c576102ae565b80633cef28d2116102195780634f6ccce7116101d25780634f6ccce7146104e05780636352211e146105005780636ec0578a1461052057806370a0823114610540578063715018a614610560578063736f6cff14610575576102ae565b80633cef28d2146104385780633d18b9121461046557806342842e0e1461047a57806343fc665f1461049a57806344081ca6146104ad57806348a80be3146104cd576102ae565b806318160ddd1161026b57806318160ddd1461039757806323b872dd146103b65780632eb4a7ab146103d65780632f745c59146103ec57806331ffd6f11461040c57806332cb6b0c14610422576102ae565b806301ffc9a7146102b357806304cc6c78146102e857806306fdde03146102fd578063081812fc1461031f578063095ea7b31461035757806317e93d1814610377575b600080fd5b3480156102bf57600080fd5b506102d36102ce366004613336565b6108a4565b60405190151581526020015b60405180910390f35b6102fb6102f636600461341d565b6108d1565b005b34801561030957600080fd5b50610312610a40565b6040516102df9190613646565b34801561032b57600080fd5b5061033f61033a36600461341d565b610ad2565b6040516001600160a01b0390911681526020016102df565b34801561036357600080fd5b506102fb6103723660046132f3565b610b67565b34801561038357600080fd5b506102fb61039236600461336e565b610c7d565b3480156103a357600080fd5b506008545b6040519081526020016102df565b3480156103c257600080fd5b506102fb6103d1366004613216565b610da3565b3480156103e257600080fd5b506103a8600a5481565b3480156103f857600080fd5b506103a86104073660046132f3565b610e14565b34801561041857600080fd5b506103a860145481565b34801561042e57600080fd5b506103a8619c4081565b34801561044457600080fd5b506103a86104533660046131ca565b60116020526000908152604090205481565b34801561047157600080fd5b506102fb610ead565b34801561048657600080fd5b506102fb610495366004613216565b610fbb565b6102fb6104a836600461341d565b610fd6565b3480156104b957600080fd5b506102fb6104c83660046133d7565b61119c565b6102fb6104db366004613488565b6111dd565b3480156104ec57600080fd5b506103a86104fb36600461341d565b61140d565b34801561050c57600080fd5b5061033f61051b36600461341d565b6114ae565b34801561052c57600080fd5b506102fb61053b36600461341d565b611525565b34801561054c57600080fd5b506103a861055b3660046131ca565b611651565b34801561056c57600080fd5b506102fb6116d8565b34801561058157600080fd5b506103a86105903660046131ca565b60106020526000908152604090205481565b3480156105ae57600080fd5b50600d5461033f906001600160a01b031681565b3480156105ce57600080fd5b506102fb6105dd36600461331c565b61174c565b3480156105ee57600080fd5b506102fb6105fd3660046131ca565b611789565b34801561060e57600080fd5b506103a86702c68af0bb14000081565b34801561062a57600080fd5b50600c546001600160a01b031661033f565b34801561064857600080fd5b506103126117d5565b34801561065d57600080fd5b506102fb61066c3660046132f3565b6117e4565b34801561067d57600080fd5b506102d361068c36600461341d565b611830565b34801561069d57600080fd5b506102d36106ac3660046131ca565b60126020526000908152604090205460ff1681565b3480156106cd57600080fd5b506102fb6106dc3660046132ca565b611871565b3480156106ed57600080fd5b506103a86106fc36600461341d565b611943565b34801561070d57600080fd5b506102fb61071c366004613251565b61198a565b34801561072d57600080fd5b506102fb61073c3660046133d7565b6119fc565b34801561074d57600080fd5b5061031261075c36600461341d565b611a39565b34801561076d57600080fd5b506016546102d39060ff1681565b6102fb610789366004613435565b611b17565b34801561079a57600080fd5b506102d36107a93660046131e4565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156107e357600080fd5b506103a8600a81565b3480156107f857600080fd5b50610312611cb0565b34801561080d57600080fd5b506103a860155481565b34801561082357600080fd5b506103a861083236600461341d565b600b6020526000908152604090205481565b34801561085057600080fd5b506102fb61085f3660046131ca565b611d3e565b34801561087057600080fd5b50610312611e29565b34801561088557600080fd5b506103a860135481565b34801561089b57600080fd5b506102fb611e36565b60006001600160e01b0319821663780e9d6360e01b14806108c957506108c982611e8f565b90505b919050565b6015544210156108fc5760405162461bcd60e51b81526004016108f3906136ab565b60405180910390fd5b600a81111561091d5760405162461bcd60e51b81526004016108f390613759565b61092f6702c68af0bb1400008261383e565b341461094d5760405162461bcd60e51b81526004016108f39061370f565b3360009081526012602052604090205460ff1661097c5760405162461bcd60e51b81526004016108f390613734565b600061098760085490565b90506013546004610998919061383e565b6109a490619c4061385d565b6109af83600461383e565b6109b99083613812565b11156109ff5760405162461bcd60e51b815260206004820152601560248201527410d85b89dd081b5a5b9d081bdd995c881b1a5b5a5d605a1b60448201526064016108f3565b3360009081526010602052604081208054849290610a1e908490613812565b925050819055508160136000828254610a379190613812565b90915550505050565b606060008054610a4f906138a0565b80601f0160208091040260200160405190810160405280929190818152602001828054610a7b906138a0565b8015610ac85780601f10610a9d57610100808354040283529160200191610ac8565b820191906000526020600020905b815481529060010190602001808311610aab57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610b4b5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108f3565b506000908152600460205260409020546001600160a01b031690565b6000610b72826114ae565b9050806001600160a01b0316836001600160a01b03161415610be05760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108f3565b336001600160a01b0382161480610bfc5750610bfc81336107a9565b610c6e5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108f3565b610c788383611edf565b505050565b336001600160a01b0316610d3d83838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604051610d379250610cd791508990899060200161351d565b60408051601f1981840301815282825280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000084830152603c8085019190915282518085039091018152605c909301909152815191012090565b90611f4d565b6001600160a01b031614610d835760405162461bcd60e51b815260206004820152600d60248201526c14da59c81b9bdd081d985b1a59609a1b60448201526064016108f3565b5050336000908152601260205260409020805460ff191660011790555050565b600d5460405163164746fd60e11b81526001600160a01b0390911690632c8e8dfa90610dd7908690869086906004016135ef565b600060405180830381600087803b158015610df157600080fd5b505af1158015610e05573d6000803e3d6000fd5b50505050610c78838383611fc8565b6000610e1f83611651565b8210610e815760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016108f3565b506001600160a01b03821660009081526006602090815260408083208484529091529020545b92915050565b60165460ff16610ef55760405162461bcd60e51b815260206004820152601360248201527243616e277420636c61696d207265776172647360681b60448201526064016108f3565b600d5460405163164746fd60e11b81526001600160a01b0390911690632c8e8dfa90610f2a90339060009081906004016135ef565b600060405180830381600087803b158015610f4457600080fd5b505af1158015610f58573d6000803e3d6000fd5b5050600d54604051630c00007b60e41b81523360048201526001600160a01b03909116925063c00007b09150602401600060405180830381600087803b158015610fa157600080fd5b505af1158015610fb5573d6000803e3d6000fd5b50505050565b610c788383836040518060200160405280600081525061198a565b601554421015610ff85760405162461bcd60e51b81526004016108f3906136ab565b600a8111156110195760405162461bcd60e51b81526004016108f390613759565b61102b6702c68af0bb1400008261383e565b34146110495760405162461bcd60e51b81526004016108f39061370f565b3360009081526012602052604090205460ff166110785760405162461bcd60e51b81526004016108f390613734565b600061108360085490565b90506013546004611094919061383e565b6110a090619c4061385d565b6110ab83600461383e565b6110b59083613812565b11156110fb5760405162461bcd60e51b815260206004820152601560248201527410d85b89dd081b5a5b9d081bdd995c881b1a5b5a5d605a1b60448201526064016108f3565b600d5460405163164746fd60e11b81526001600160a01b0390911690632c8e8dfa9061113090339060009081906004016135ef565b600060405180830381600087803b15801561114a57600080fd5b505af115801561115e573d6000803e3d6000fd5b5050505060005b82811015610c785761118a61117b82600461383e565b6111859084613812565b611ff9565b80611194816138d5565b915050611165565b600c546001600160a01b031633146111c65760405162461bcd60e51b81526004016108f3906136da565b80516111d990600f906020840190612fe9565b5050565b6014544210156111ff5760405162461bcd60e51b81526004016108f3906136ab565b6112116702c68af0bb1400008661383e565b341461122f5760405162461bcd60e51b81526004016108f39061370f565b336001600160a01b038416146112815760405162461bcd60e51b815260206004820152601760248201527643616c6c6572206e6f742070617274206f66207472656560481b60448201526064016108f3565b61128a84611830565b156112c95760405162461bcd60e51b815260206004820152600f60248201526e436c61696d656420616c726561647960881b60448201526064016108f3565b6112d58484848461212d565b6001600160a01b03831660009081526011602052604090205482906112fb908790613812565b11156113495760405162461bcd60e51b815260206004820152601e60248201527f43616e2774206d696e74206d6f7265207468616e20616c6c6f6361746564000060448201526064016108f3565b6001600160a01b03831660009081526011602052604081208054879290611371908490613812565b9091555050600a8511156113cb576001600160a01b038316600090815260106020526040812080548792906113a7908490613812565b9250508190555084601360008282546113c09190613812565b909155506114069050565b60006113d660085490565b905060005b86811015611403576113f161117b82600461383e565b806113fb816138d5565b9150506113db565b50505b5050505050565b600061141860085490565b821061147b5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016108f3565b6008828154811061149c57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806108c95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108f3565b600a8111156115465760405162461bcd60e51b81526004016108f390613759565b3360009081526012602052604090205460ff166115755760405162461bcd60e51b81526004016108f390613734565b336000908152601060205260408120805483929061159490849061385d565b9250508190555080601360008282546115ad919061385d565b9091555050600d5460405163164746fd60e11b81526001600160a01b0390911690632c8e8dfa906115e790339060009081906004016135ef565b600060405180830381600087803b15801561160157600080fd5b505af1158015611615573d6000803e3d6000fd5b50505050600061162460085490565b905060005b82811015610c785761163f61117b82600461383e565b80611649816138d5565b915050611629565b60006001600160a01b0382166116bc5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108f3565b506001600160a01b031660009081526003602052604090205490565b600c546001600160a01b031633146117025760405162461bcd60e51b81526004016108f3906136da565b600c546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600c80546001600160a01b0319169055565b600c546001600160a01b031633146117765760405162461bcd60e51b81526004016108f3906136da565b6016805460ff1916911515919091179055565b600c546001600160a01b031633146117b35760405162461bcd60e51b81526004016108f3906136da565b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b606060018054610a4f906138a0565b336000908152601060205260408120805483929061180390849061385d565b90915550506001600160a01b03821660009081526010602052604081208054839290610a37908490613812565b60008061183f6101008461382a565b9050600061184f610100856138f0565b6000928352600b602052604090922054600190921b9182169091149392505050565b6001600160a01b0382163314156118ca5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108f3565b3360008181526005602090815260408083206001600160a01b0387168085529252909120805460ff1916841515179055906001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611937911515815260200190565b60405180910390a35050565b60008061195160208461382a565b905060006119606020856138f0565b905061196d81600861383e565b6000928352601760205260409092205490911c60ff169392505050565b600d5460405163164746fd60e11b81526001600160a01b0390911690632c8e8dfa906119be908790879087906004016135ef565b600060405180830381600087803b1580156119d857600080fd5b505af11580156119ec573d6000803e3d6000fd5b50505050610fb5848484846121c6565b600c546001600160a01b03163314611a265760405162461bcd60e51b81526004016108f3906136da565b80516111d990600e906020840190612fe9565b6000818152600260205260409020546060906001600160a01b0316611ab85760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016108f3565b6000611ac26121f8565b90506000815111611ae25760405180602001604052806000815250611b10565b80611aec84612207565b600f604051602001611b009392919061352d565b6040516020818303038152906040525b9392505050565b601454421015611b395760405162461bcd60e51b81526004016108f3906136ab565b611b4b6702c68af0bb1400008361383e565b3414611b695760405162461bcd60e51b81526004016108f39061370f565b336001600160a01b03841614611bbb5760405162461bcd60e51b815260206004820152601760248201527643616c6c6572206e6f742070617274206f66207472656560481b60448201526064016108f3565b6001600160a01b03831660009081526011602052604090205415611c0f5760405162461bcd60e51b815260206004820152600b60248201526a4d696e74656420736f6d6560a81b60448201526064016108f3565b611c1b8484848461232a565b600a821115611c70576001600160a01b03831660009081526010602052604081208054849290611c4c908490613812565b925050819055508160136000828254611c659190613812565b90915550610fb59050565b6000611c7b60085490565b905060005b83811015611ca857611c9661117b82600461383e565b80611ca0816138d5565b915050611c80565b505050505050565b600e8054611cbd906138a0565b80601f0160208091040260200160405190810160405280929190818152602001828054611ce9906138a0565b8015611d365780601f10611d0b57610100808354040283529160200191611d36565b820191906000526020600020905b815481529060010190602001808311611d1957829003601f168201915b505050505081565b600c546001600160a01b03163314611d685760405162461bcd60e51b81526004016108f3906136da565b6001600160a01b038116611dcd5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108f3565b600c546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600c80546001600160a01b0319166001600160a01b0392909216919091179055565b600f8054611cbd906138a0565b600c546001600160a01b03163314611e605760405162461bcd60e51b81526004016108f3906136da565b60405133904780156108fc02916000818181858888f19350505050158015611e8c573d6000803e3d6000fd5b50565b60006001600160e01b031982166380ac58cd60e01b1480611ec057506001600160e01b03198216635b5e139f60e01b145b806108c957506301ffc9a760e01b6001600160e01b03198316146108c9565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611f14826114ae565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008151604114611fa05760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016108f3565b60208201516040830151606084015160001a611fbe86828585612464565b9695505050505050565b611fd2338261260d565b611fee5760405162461bcd60e51b81526004016108f390613790565b610c78838383612700565b60006120066000836128ab565b905060005b6004811015610c78576000600261202184612900565b61202b9083613812565b901b905061203983856128ab565b925060006120468461295c565b905060026120548284613812565b901b915061206284866128ab565b93508061207557600282901b915061209c565b60026120826003866138f0565b61208d846001613812565b6120979190613812565b901b91505b6120a684866128ab565b93506120b28383613812565b91506120c7826120c28588613812565b6129a5565b6120da336120d58588613812565b6129ec565b336120e58487613812565b6040518481527f4d9a3e97ba18387f826a90cdf00545427978afd9c94870f0f5cc811cf2ddb0039060200160405180910390a350508080612125906138d5565b91505061200b565b6040516bffffffffffffffffffffffff19606085901b166020820152603481018390526054810185905260009060740160405160208183030381529060405280519060200120905061218c600a548284612b3a9092919063ffffffff16565b6114065760405162461bcd60e51b815260206004820152600b60248201526a2bb937b73390383937b7b360a91b60448201526064016108f3565b6121d0338361260d565b6121ec5760405162461bcd60e51b81526004016108f390613790565b610fb584848484612bf7565b6060600e8054610a4f906138a0565b60608161222c57506040805180820190915260018152600360fc1b60208201526108cc565b8160005b81156122565780612240816138d5565b915061224f9050600a8361382a565b9150612230565b60008167ffffffffffffffff81111561227f57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156122a9576020820181803683370190505b5090505b8415612322576122be60018361385d565b91506122cb600a866138f0565b6122d6906030613812565b60f81b8183815181106122f957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535061231b600a8661382a565b94506122ad565b949350505050565b61233384611830565b156123725760405162461bcd60e51b815260206004820152600f60248201526e436c61696d656420616c726561647960881b60448201526064016108f3565b6040516bffffffffffffffffffffffff19606085901b16602082015260348101839052605481018590526000906074016040516020818303038152906040528051906020012090506123d1600a548284612b3a9092919063ffffffff16565b61240b5760405162461bcd60e51b815260206004820152600b60248201526a2bb937b73390383937b7b360a91b60448201526064016108f3565b61241485612c2a565b604080518681526001600160a01b03861660208201529081018490527f4ec90e965519d92681267467f775ada5bd214aa92c0dc93d90a5e880ce9ed0269060600160405180910390a15050505050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156124e15760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016108f3565b8360ff16601b14806124f657508360ff16601c145b61254d5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b60648201526084016108f3565b6040805160008082526020820180845288905260ff871692820192909252606081018590526080810184905260019060a0016020604051602081039080840390855afa1580156125a1573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166126045760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016108f3565b95945050505050565b6000818152600260205260408120546001600160a01b03166126865760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108f3565b6000612691836114ae565b9050806001600160a01b0316846001600160a01b031614806126cc5750836001600160a01b03166126c184610ad2565b6001600160a01b0316145b8061232257506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff16612322565b826001600160a01b0316612713826114ae565b6001600160a01b03161461277b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108f3565b6001600160a01b0382166127dd5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108f3565b6127e8838383612c68565b6127f3600082611edf565b6001600160a01b038316600090815260036020526040812080546001929061281c90849061385d565b90915550506001600160a01b038216600090815260036020526040812080546001929061284a908490613812565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000826128ef57604080514460208201524291810191909152606081018390526080015b6040516020818303038152906040528051906020012060001c9050610ea7565b6040805160208101859052016128cf565b60008061290f612710846138f0565b905060198110156129245760009150506108cc565b6104fb8110156129385760019150506108cc565b610ebf81101561294c5760029150506108cc565b60039150506108cc565b50919050565b60008061296a6064846138f0565b9050600a81101561297f5760009150506108cc565b60288110156129925760019150506108cc565b604681101561294c5760029150506108cc565b60006129b260208361382a565b905060006129c16020846138f0565b90506129ce81600861383e565b60009283526017602052604090922080549490921b90931790555050565b6001600160a01b038216612a425760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108f3565b6000818152600260205260409020546001600160a01b031615612aa75760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108f3565b612ab360008383612c68565b6001600160a01b0382166000908152600360205260408120805460019290612adc908490613812565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600081815b8551811015612bec576000868281518110612b6a57634e487b7160e01b600052603260045260246000fd5b60200260200101519050808311612bac576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250612bd9565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080612be4816138d5565b915050612b3f565b509092149392505050565b612c02848484612700565b612c0e84848484612d25565b610fb55760405162461bcd60e51b81526004016108f390613659565b6000612c386101008361382a565b90506000612c48610100846138f0565b6000928352600b60205260409092208054600190931b9092179091555050565b6001600160a01b038316612cc357612cbe81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612ce6565b816001600160a01b0316836001600160a01b031614612ce657612ce68382612e2f565b6001600160a01b038216612d0257612cfd81612ecc565b610c78565b826001600160a01b0316826001600160a01b031614610c7857610c788282612fa5565b60006001600160a01b0384163b15612e2757604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612d69903390899088908890600401613613565b602060405180830381600087803b158015612d8357600080fd5b505af1925050508015612db3575060408051601f3d908101601f19168201909252612db091810190613352565b60015b612e0d573d808015612de1576040519150601f19603f3d011682016040523d82523d6000602084013e612de6565b606091505b508051612e055760405162461bcd60e51b81526004016108f390613659565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612322565b506001612322565b60006001612e3c84611651565b612e46919061385d565b600083815260076020526040902054909150808214612e99576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612ede9060019061385d565b60008381526009602052604081205460088054939450909284908110612f1457634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060088381548110612f4357634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480612f8957634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612fb083611651565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b828054612ff5906138a0565b90600052602060002090601f016020900481019282613017576000855561305d565b82601f1061303057805160ff191683800117855561305d565b8280016001018555821561305d579182015b8281111561305d578251825591602001919060010190613042565b5061306992915061306d565b5090565b5b80821115613069576000815560010161306e565b600067ffffffffffffffff83111561309c5761309c613930565b6130af601f8401601f19166020016137e1565b90508281528383830111156130c357600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b03811681146108cc57600080fd5b600082601f830112613101578081fd5b8135602067ffffffffffffffff82111561311d5761311d613930565b80820261312b8282016137e1565b838152828101908684018388018501891015613145578687fd5b8693505b85841015613167578035835260019390930192918401918401613149565b50979650505050505050565b803580151581146108cc57600080fd5b60008083601f840112613194578182fd5b50813567ffffffffffffffff8111156131ab578182fd5b6020830191508360208285010111156131c357600080fd5b9250929050565b6000602082840312156131db578081fd5b611b10826130da565b600080604083850312156131f6578081fd5b6131ff836130da565b915061320d602084016130da565b90509250929050565b60008060006060848603121561322a578081fd5b613233846130da565b9250613241602085016130da565b9150604084013590509250925092565b60008060008060808587031215613266578081fd5b61326f856130da565b935061327d602086016130da565b925060408501359150606085013567ffffffffffffffff81111561329f578182fd5b8501601f810187136132af578182fd5b6132be87823560208401613082565b91505092959194509250565b600080604083850312156132dc578182fd5b6132e5836130da565b915061320d60208401613173565b60008060408385031215613305578182fd5b61330e836130da565b946020939093013593505050565b60006020828403121561332d578081fd5b611b1082613173565b600060208284031215613347578081fd5b8135611b1081613946565b600060208284031215613363578081fd5b8151611b1081613946565b60008060008060408587031215613383578384fd5b843567ffffffffffffffff8082111561339a578586fd5b6133a688838901613183565b909650945060208701359150808211156133be578384fd5b506133cb87828801613183565b95989497509550505050565b6000602082840312156133e8578081fd5b813567ffffffffffffffff8111156133fe578182fd5b8201601f8101841361340e578182fd5b61232284823560208401613082565b60006020828403121561342e578081fd5b5035919050565b6000806000806080858703121561344a578182fd5b8435935061345a602086016130da565b925060408501359150606085013567ffffffffffffffff81111561347c578182fd5b6132be878288016130f1565b600080600080600060a0868803121561349f578283fd5b85359450602086013593506134b6604087016130da565b925060608601359150608086013567ffffffffffffffff8111156134d8578182fd5b6134e4888289016130f1565b9150509295509295909350565b60008151808452613509816020860160208601613874565b601f01601f19169290920160200192915050565b6000828483379101908152919050565b6000845160206135408285838a01613874565b8551918401916135538184848a01613874565b855492019183906002810460018083168061356f57607f831692505b85831081141561358d57634e487b7160e01b88526022600452602488fd5b8080156135a157600181146135b2576135de565b60ff198516885283880195506135de565b60008b815260209020895b858110156135d65781548a8201529084019088016135bd565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611fbe908301846134f1565b600060208252611b1060208301846134f1565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252601590820152745075626c69632073616c65206e6f7420726561647960581b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600b908201526a57726f6e6720707269636560a81b604082015260600190565b6020808252600b908201526a09cde40d0eadac2dc4074560ab1b604082015260600190565b60208082526018908201527f4d696e74696e6720746f6f206d616e79206174206f6e63650000000000000000604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff8111828210171561380a5761380a613930565b604052919050565b6000821982111561382557613825613904565b500190565b6000826138395761383961391a565b500490565b600081600019048311821515161561385857613858613904565b500290565b60008282101561386f5761386f613904565b500390565b60005b8381101561388f578181015183820152602001613877565b83811115610fb55750506000910152565b6002810460018216806138b457607f821691505b6020821081141561295657634e487b7160e01b600052602260045260246000fd5b60006000198214156138e9576138e9613904565b5060010190565b6000826138ff576138ff61391a565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114611e8c57600080fdfea264697066735822122041c1d0b555341b7828be800056405e973e33d07e572a95141f579be6f9bb34a364736f6c63430008020033
Verified Source Code Partial Match
Compiler: v0.8.2+commit.661d1103
EVM: istanbul
Optimization: Yes (200 runs)
ECDSA.sol 99 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
// Check the signature length
if (signature.length != 65) {
revert("ECDSA: invalid signature length");
}
// Divide the signature in r, s and v variables
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solhint-disable-next-line no-inline-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return recover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value");
require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value");
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
require(signer != address(0), "ECDSA: invalid signature");
return signer;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
ERC20.sol 303 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "IERC20.sol";
import "Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens 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 amount) internal virtual { }
}
ERC165.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
ERC721.sol 377 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "IERC721.sol";
import "IERC721Receiver.sol";
import "IERC721Metadata.sol";
import "IERC721Enumerable.sol";
import "Address.sol";
import "Context.sol";
import "Strings.sol";
import "ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _owners;
// Mapping owner address to token count
mapping (address => uint256) private _balances;
// Mapping from token ID to approved address
mapping (uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping (address => mapping (address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC721).interfaceId
|| interfaceId == type(IERC721Metadata).interfaceId
|| super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: '';
}
/**
* @dev Base URI for computing {tokenURI}. 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 || ERC721.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 || ERC721.isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
_mint(to, tokenId);
require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
private returns (bool)
{
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
// solhint-disable-next-line no-inline-assembly
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` 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 { }
}
IERC20.sol 77 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
Address.sol 189 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
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");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(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");
// solhint-disable-next-line avoid-low-level-calls
(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");
// solhint-disable-next-line avoid-low-level-calls
(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");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
IERC165.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721.sol 129 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}
MKToken.sol 78 lines
pragma solidity ^0.8.2;
import "IERC20.sol";
import "ERC20.sol";
import "IERC721.sol";
/*
* ,_,
* (',')
* {/"\}
* -"-"-
*/
contract MkToken is ERC20("Fragments of the Abyss", "FOA") {
uint256 constant public BASE_RATE = 6_849315068_000000000 ;
uint256 constant public END = 1955491200;
mapping(address => uint256) public rewards;
mapping(address => uint256) public lastUpdate;
IERC721 public mkContracts;
event RewardPaid(address indexed user, uint256 reward);
constructor(address _mk) public{
mkContracts = IERC721(_mk);
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
// called on transfers
function updateReward(address _from, address _to, uint256 _tokenId) external {
require(msg.sender == address(mkContracts));
uint256 time = min(block.timestamp, END);
uint256 timerFrom = lastUpdate[_from];
if (timerFrom > 0)
rewards[_from] += mkContracts.balanceOf(_from) * BASE_RATE * (time - timerFrom) / 86400;
if (timerFrom != END)
lastUpdate[_from] = time;
if (_to != address(0)) {
uint256 timerTo = lastUpdate[_to];
if (timerTo > 0)
rewards[_to] += mkContracts.balanceOf(_to) * BASE_RATE * (time - timerFrom) / 86400;
if (timerTo != END)
lastUpdate[_to] = time;
}
}
function getReward(address _to) external {
require(msg.sender == address(mkContracts));
uint256 reward = rewards[_to];
if (reward > 0) {
rewards[_to] = 0;
_mint(_to, reward);
emit RewardPaid(_to, reward);
}
}
function burn(uint256 _amount) external {
_burn(msg.sender, _amount);
}
function burnFor(address _user, uint256 _amount) external {
uint256 currentAllowance = allowance(_user, msg.sender);
_approve(_user, msg.sender, currentAllowance - _amount);
_burn(_user, _amount);
}
function getTotalClaimable(address _user) external view returns(uint256) {
uint256 time = min(block.timestamp, END);
uint256 pending = mkContracts.balanceOf(_user) * BASE_RATE * (time - lastUpdate[_user]) / 86400;
return rewards[_user] + pending;
}
}
Ownable.sol 68 lines
// SPDX-License-Identifier: MIT
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 () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), 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 {
emit OwnershipTransferred(_owner, address(0));
_owner = 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");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant alphabet = "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] = alphabet[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
SolarBots.sol 258 lines
pragma solidity ^0.8.2;
import "ERC721.sol";
import "ERC721Enumerable.sol";
import "ECDSA.sol";
import "Ownable.sol";
import "MKToken.sol";
import "MerkleWhitelist.sol";
/*
* ,_,
* (',')
* {/"\}
* -"-"-
*/
contract SolarBots is ERC721Enumerable, MerkleWhitelist, Ownable {
using ECDSA for bytes32;
using Strings for uint256;
uint256 public constant MAX_SUPPLY = 40000;
uint256 public constant PRICE = 0.2 ether;
uint256 public constant MAX_PER_CALL = 10;
address public yieldToken;
string public uri;
string public suffix;
mapping(address => uint256) public reservedToMint;
mapping(address => uint256) public mintedBy;
mapping(address => bool) public human;
uint256 public reserved;
uint256 public whitelistSale;
uint256 public publicSaleDate;
bool public rewardsUnlocked;
mapping(uint256 => uint256) genes;
event BotMinted(uint256 indexed tokenId, address indexed receiver, uint256 genes);
constructor(uint256 _whitelistSale, uint256 _publicSaleDate, bytes32 _root) ERC721("Solarbots", "MK1") MerkleWhitelist(_root) {
whitelistSale = _whitelistSale;
publicSaleDate = _publicSaleDate;
_mintTeam(0);
}
function _baseURI() internal override view returns (string memory) {
return uri;
}
function tokenURI(uint256 tokenId) public view 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(), suffix))
: '';
}
function updateURI(string memory _newURI) public onlyOwner {
uri = _newURI;
}
function updateSuffix(string memory _suffix) public onlyOwner {
suffix = _suffix;
}
function updateYieldToken(address _token) external onlyOwner {
yieldToken = _token;
}
function updateRewardLock(bool _val) external onlyOwner {
rewardsUnlocked = _val;
}
function getReward() external {
require(rewardsUnlocked, "Can't claim rewards");
MkToken(yieldToken).updateReward(msg.sender, address(0), 0);
MkToken(yieldToken).getReward(msg.sender);
}
function transferFrom(address from, address to, uint256 tokenId) public override {
MkToken(yieldToken).updateReward(from, to, tokenId);
ERC721.transferFrom(from, to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public override {
MkToken(yieldToken).updateReward(from, to, tokenId);
ERC721.safeTransferFrom(from, to, tokenId, _data);
}
function mintBots(uint256 _amount) external payable {
require(block.timestamp >= publicSaleDate, "Public sale not ready");
require(_amount <= MAX_PER_CALL, "Minting too many at once");
require(msg.value == _amount * PRICE, "Wrong price");
require(human[msg.sender], "No human :(");
uint256 supply = totalSupply();
require(supply + _amount * 4 <= MAX_SUPPLY - reserved * 4, "Can't mint over limit");
MkToken(yieldToken).updateReward(msg.sender, address(0), 0);
for (uint256 i = 0; i < _amount; i++)
_mintTeam(supply + i * 4);
}
function reserveBots(uint256 _amount) external payable {
require(block.timestamp >= publicSaleDate, "Public sale not ready");
require(_amount <= MAX_PER_CALL, "Minting too many at once");
require(msg.value == _amount * PRICE, "Wrong price");
require(human[msg.sender], "No human :(");
uint256 supply = totalSupply();
require(supply + _amount * 4 <= MAX_SUPPLY - reserved * 4, "Can't mint over limit");
reservedToMint[msg.sender] += _amount;
reserved += _amount;
}
function mintAllBotsWithSignature(uint256 _index, address _account, uint256 _amount, bytes32[] memory _proof) public payable {
require(block.timestamp >= whitelistSale, "Public sale not ready");
require(msg.value == _amount * PRICE, "Wrong price");
require(msg.sender == _account, "Caller not part of tree");
require(mintedBy[_account] == 0, "Minted some");
_claim(_index, _account, _amount, _proof);
if (_amount > MAX_PER_CALL) {
reservedToMint[_account] += _amount;
reserved += _amount;
}
else {
uint256 supply = totalSupply();
for (uint256 i = 0; i < _amount; i++)
_mintTeam(supply + i * 4);
}
}
function mintSomeBotsWithSignature(uint256 _toMint, uint256 _index, address _account, uint256 _amount, bytes32[] memory _proof) public payable {
require(block.timestamp >= whitelistSale, "Public sale not ready");
require(msg.value == _toMint * PRICE, "Wrong price");
require(msg.sender == _account, "Caller not part of tree");
require(!isClaimed(_index), "Claimed already");
_verify(_index, _account, _amount, _proof);
require(mintedBy[_account] + _toMint <= _amount, "Can't mint more than allocated");
mintedBy[_account] += _toMint;
if (_toMint > MAX_PER_CALL) {
reservedToMint[_account] += _toMint;
reserved += _toMint;
}
else {
uint256 supply = totalSupply();
for (uint256 i = 0; i < _toMint; i++)
_mintTeam(supply + i * 4);
}
}
function mintRemainder(uint256 _amount) external {
require(_amount <= MAX_PER_CALL, "Minting too many at once");
require(human[msg.sender], "No human :(");
reservedToMint[msg.sender] -= _amount;
reserved -= _amount;
MkToken(yieldToken).updateReward(msg.sender, address(0), 0);
uint256 supply = totalSupply();
for (uint256 i = 0; i < _amount; i++)
_mintTeam(supply + i * 4);
}
function transferMints(address _to, uint256 _amount) external {
reservedToMint[msg.sender] -= _amount;
reservedToMint[_to] += _amount;
}
function meHuman(string calldata _msg, bytes calldata _sig) external {
require(keccak256(abi.encodePacked(_msg)).toEthSignedMessageHash().recover(_sig) == msg.sender, "Sig not valid");
human[msg.sender] = true;
}
// gene composision
// rarity faction bot-type class
// 00=00=00=00
function _mintTeam(uint256 _id) internal {
uint256 seed = generateSeed(0, _id);
for(uint256 i = 0; i < 4; i++) {
uint256 gene = 0;
gene = gene + getRarityOutcome(seed) << 2;
seed = generateSeed(seed, _id);
uint256 faction = getFactionOutcome(seed);
gene = (gene + faction) << 2;
seed = generateSeed(seed, _id);
// bot type
if (faction == 0)
gene <<= 2;
else
gene = (gene + 1 + seed % 3) << 2;
seed = generateSeed(seed, _id);
gene += i;
_storeGenes(gene, _id + i);
_mint(msg.sender, _id + i);
emit BotMinted(_id + i, msg.sender, gene);
}
}
function _storeGenes(uint256 _genes, uint256 _id) internal {
uint256 word = _id / 32;
uint256 index = _id % 32;
genes[word] |= _genes << (index * 8);
}
function getGenes(uint256 _id) external view returns(uint256 gene) {
uint256 word = _id / 32;
uint256 index = _id % 32;
gene = (genes[word] >> (index * 8)) & 0xff;
}
function getFactionOutcome(uint256 _seed) internal returns(uint256) {
uint256 range = _seed % 100;
// 10% - neutral
if (range < 10)
return 0;
// 30% - lacrean
else if (range < 40)
return 1;
// 30% - iilskagaard
else if (range < 70)
return 2;
// 30% - arboria
else
return 3;
}
function getRarityOutcome(uint256 _seed) internal returns(uint256) {
uint256 range = _seed % 10000;
// 0.25% - void
if (range < 25)
return 0;
// 12.5% - epic
else if (range < 1275)
return 1;
// 25% - rare
else if (range < 3775)
return 2;
// 62.25% - common
else
return 3;
}
function generateSeed(uint256 _seed, uint256 _id) internal view returns (uint256) {
if (_seed == 0)
return uint256(keccak256(abi.encodePacked(block.difficulty, block.timestamp, _id)));
else
return uint256(keccak256(abi.encodePacked(_seed)));
}
function fetchEther() external onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
}
MerkleProof.sol 33 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle trees (hash trees),
*/
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) {
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));
}
}
// Check if the computed hash (root) is equal to the provided root
return computedHash == root;
}
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
IERC721Receiver.sol 21 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}
MerkleWhitelist.sol 52 lines
pragma solidity 0.8.2;
import "MerkleProof.sol";
import "IERC20.sol";
/*
* ,_,
* (',')
* {/"\}
* -"-"-
*/
contract MerkleWhitelist {
using MerkleProof for bytes32[];
bytes32 public merkleRoot;
mapping(uint256 => uint256) public claimedBitMap;
event Claimed(uint256 index, address account, uint256 amount);
constructor(bytes32 _root) public {
merkleRoot = _root;
}
function isClaimed(uint256 _index) public view returns(bool) {
uint256 wordIndex = _index / 256;
uint256 bitIndex = _index % 256;
uint256 word = claimedBitMap[wordIndex];
uint256 bitMask = 1 << bitIndex;
return word & bitMask == bitMask;
}
function _setClaimed(uint256 _index) internal {
uint256 wordIndex = _index / 256;
uint256 bitIndex = _index % 256;
claimedBitMap[wordIndex] |= 1 << bitIndex;
}
function _verify(uint256 _index, address _account, uint256 _amount, bytes32[] memory _proof) internal {
bytes32 node = keccak256(abi.encodePacked(_account, _amount, _index));
require(_proof.verify(merkleRoot, node), "Wrong proof");
}
function _claim(uint256 _index, address _account, uint256 _amount, bytes32[] memory _proof) internal {
require(!isClaimed(_index), "Claimed already");
bytes32 node = keccak256(abi.encodePacked(_account, _amount, _index));
require(_proof.verify(merkleRoot, node), "Wrong proof");
_setClaimed(_index);
emit Claimed(_index, _account, _amount);
}
}
ERC721Enumerable.sol 159 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "ERC721.sol";
import "IERC721Enumerable.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId
|| super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
Read Contract
MAX_PER_CALL 0xea156a9b → uint256
MAX_SUPPLY 0x32cb6b0c → uint256
PRICE 0x8d859f3e → uint256
balanceOf 0x70a08231 → uint256
claimedBitMap 0xee25560b → uint256
getApproved 0x081812fc → address
getGenes 0xa2e4b12e → uint256
human 0x9e8e54e1 → bool
isApprovedForAll 0xe985e9c5 → bool
isClaimed 0x9e34070f → bool
merkleRoot 0x2eb4a7ab → bytes32
mintedBy 0x3cef28d2 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
publicSaleDate 0xeced3873 → uint256
reserved 0xfe60d12c → uint256
reservedToMint 0x736f6cff → uint256
rewardsUnlocked 0xde31c972 → bool
suffix 0xf7073c3a → string
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
uri 0xeac989f8 → string
whitelistSale 0x31ffd6f1 → uint256
yieldToken 0x76d5de85 → address
Write Contract 20 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
fetchEther 0xfe6feca2
No parameters
getReward 0x3d18b912
No parameters
meHuman 0x17e93d18
string _msg
bytes _sig
mintAllBotsWithSignature 0xe2eedf92
uint256 _index
address _account
uint256 _amount
bytes32[] _proof
mintBots 0x43fc665f
uint256 _amount
mintRemainder 0x6ec0578a
uint256 _amount
mintSomeBotsWithSignature 0x48a80be3
uint256 _toMint
uint256 _index
address _account
uint256 _amount
bytes32[] _proof
renounceOwnership 0x715018a6
No parameters
reserveBots 0x04cc6c78
uint256 _amount
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferMints 0x9b9a5ef9
address _to
uint256 _amount
transferOwnership 0xf2fde38b
address newOwner
updateRewardLock 0x827c3805
bool _val
updateSuffix 0x44081ca6
string _suffix
updateURI 0xc30f4a5a
string _newURI
updateYieldToken 0x8421b687
address _token
Recent Transactions
No transactions found for this address