Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x524Ebc93BeEf838F70b4Ae54b675d3e971D5884E
Balance 0.000000000 ETH
Nonce 1
Code Size 11159 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

11159 bytes
0x6080604052600436106102975760003560e01c8063715018a61161015a578063b609995e116100c1578063e89bcca21161007a578063e89bcca214610807578063ea2f0b3714610827578063f2fde38b14610847578063f429389014610867578063fe575a871461087c578063fffa1dd9146108ac57600080fd5b8063b609995e14610735578063ba385abb14610755578063bb8d513114610775578063cf0c018b1461078b578063d543dbeb146107a1578063dd62ed3e146107c157600080fd5b8063a0d82dc511610113578063a0d82dc514610692578063a1ab19a3146106a8578063a457c2d7146106bd578063a9059cbb146106dd578063ada46d0a146106fd578063af01f2b21461071f57600080fd5b8063715018a6146105f35780638421b507146106085780638c0b5e22146106285780638da5cb5b1461063e57806395d89b411461065c57806398850b641461067157600080fd5b806339509351116101fe57806351bc3c85116101b757806351bc3c85146105235780635342acb41461053857806354959363146105715780636827e764146105875780636fcba3771461059d57806370a08231146105bd57600080fd5b8063395093511461046357806341cb87fc14610483578063437823ec146104a3578063455a4396146104c357806348a46473146104e357806349bd5a5e1461050357600080fd5b806318160ddd1161025057806318160ddd146103b25780631f53ac02146103d157806323b872dd146103f157806326b6308d146104115780632bb14e1d14610431578063313ce5671461044757600080fd5b806306fdde03146102a3578063095ea7b3146102ce5780630e832273146102fe578063111e037614610337578063113201fa146103595780631694505e1461037a57600080fd5b3661029e57005b600080fd5b3480156102af57600080fd5b506102b86108c1565b6040516102c59190612941565b60405180910390f35b3480156102da57600080fd5b506102ee6102e936600461285d565b610953565b60405190151581526020016102c5565b34801561030a57600080fd5b506102ee610319366004612779565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561034357600080fd5b50610357610352366004612779565b61096a565b005b34801561036557600080fd5b50601c546102ee90600160a81b900460ff1681565b34801561038657600080fd5b50601b5461039a906001600160a01b031681565b6040516001600160a01b0390911681526020016102c5565b3480156103be57600080fd5b506002545b6040519081526020016102c5565b3480156103dd57600080fd5b506103576103ec366004612779565b610ab2565b3480156103fd57600080fd5b506102ee61040c3660046127e9565b610b2a565b34801561041d57600080fd5b5061035761042c366004612888565b610b93565b34801561043d57600080fd5b506103c3600e5481565b34801561045357600080fd5b50604051600981526020016102c5565b34801561046f57600080fd5b506102ee61047e36600461285d565b610c0a565b34801561048f57600080fd5b5061035761049e366004612779565b610c40565b3480156104af57600080fd5b506103576104be366004612779565b610e45565b3480156104cf57600080fd5b506103576104de366004612829565b610ec3565b3480156104ef57600080fd5b506103576104fe3660046128a2565b610f8c565b34801561050f57600080fd5b50601c5461039a906001600160a01b031681565b34801561052f57600080fd5b50610357610ff7565b34801561054457600080fd5b506102ee610553366004612779565b6001600160a01b031660009081526019602052604090205460ff1690565b34801561057d57600080fd5b506103c360115481565b34801561059357600080fd5b506103c3600b5481565b3480156105a957600080fd5b506103576105b83660046128ba565b61103d565b3480156105c957600080fd5b506103c36105d8366004612779565b6001600160a01b031660009081526020819052604090205490565b3480156105ff57600080fd5b5061035761114f565b34801561061457600080fd5b506103576106233660046128a2565b6111c3565b34801561063457600080fd5b506103c360085481565b34801561064a57600080fd5b506005546001600160a01b031661039a565b34801561066857600080fd5b506102b8611274565b34801561067d57600080fd5b506017546102ee90600160a01b900460ff1681565b34801561069e57600080fd5b506103c3600c5481565b3480156106b457600080fd5b50610357611283565b3480156106c957600080fd5b506102ee6106d836600461285d565b61133b565b3480156106e957600080fd5b506102ee6106f836600461285d565b61138a565b34801561070957600080fd5b50610712611397565b6040516102c5919061292e565b34801561072b57600080fd5b506103c360165481565b34801561074157600080fd5b50610357610750366004612779565b6113f8565b34801561076157600080fd5b50610357610770366004612779565b611563565b34801561078157600080fd5b506103c3600f5481565b34801561079757600080fd5b506103c360155481565b3480156107ad57600080fd5b506103576107bc3660046128a2565b6115db565b3480156107cd57600080fd5b506103c36107dc3660046127b1565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b34801561081357600080fd5b50610357610822366004612888565b6116aa565b34801561083357600080fd5b50610357610842366004612779565b611721565b34801561085357600080fd5b50610357610862366004612779565b61179c565b34801561087357600080fd5b50610357611887565b34801561088857600080fd5b506102ee610897366004612779565b60186020526000908152604090205460ff1681565b3480156108b857600080fd5b506103c36118c9565b6060600380546108d090612a73565b80601f01602080910402602001604051908101604052809291908181526020018280546108fc90612a73565b80156109495780601f1061091e57610100808354040283529160200191610949565b820191906000526020600020905b81548152906001019060200180831161092c57829003601f168201915b5050505050905090565b6000610960338484611a0c565b5060015b92915050565b6005546001600160a01b0316331461099d5760405162461bcd60e51b815260040161099490612994565b60405180910390fd5b6001600160a01b03811660009081526007602052604090205460ff1615610a175760405162461bcd60e51b815260206004820152602860248201527f4164647265737320697320616c7265616479206578636c756465642066726f6d604482015267207265776172647360c01b6064820152608401610994565b6006805460018082019092557ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0180546001600160a01b0319166001600160a01b038416908117909155600081815260076020908152604091829020805460ff1916909417909355519081527f9dc0c5d829ba95d4a3aa3e40791b3e0ff125f876788532b9f7f6eb543d8dfbd691015b60405180910390a150565b6005546001600160a01b03163314610adc5760405162461bcd60e51b815260040161099490612994565b601480546001600160a01b0319166001600160a01b0383169081179091556040519081527f31bb1993faff4f8409d7baad771f861e093ef4ce2c92c6e0cb10b82d1c7324cb90602001610aa7565b6000610b37848484611b31565b610b898433610b8485604051806060016040528060288152602001612b15602891396001600160a01b038a1660009081526001602090815260408083203384529091529020549190611f47565b611a0c565b5060019392505050565b6005546001600160a01b03163314610bbd5760405162461bcd60e51b815260040161099490612994565b601c8054821515600160a81b0260ff60a81b199091161790556040517fd9fca2a469120637ae54e43ab68dfdcd9354db52d615dea3d3a66a085e6f41b990610aa790831515815260200190565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610960918590610b8490866119ad565b6005546001600160a01b03163314610c6a5760405162461bcd60e51b815260040161099490612994565b6000819050806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610ca857600080fd5b505afa158015610cbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce09190612795565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d2857600080fd5b505afa158015610d3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d609190612795565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b158015610da857600080fd5b505af1158015610dbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de09190612795565b601c80546001600160a01b03199081166001600160a01b0393841617909155601b805490911683831617905560405190831681527f7aed1d3e8155a07ccf395e44ea3109a0e2d6c9b29bbbe9f142d9790596f4dc809060200160405180910390a15050565b6005546001600160a01b03163314610e6f5760405162461bcd60e51b815260040161099490612994565b6001600160a01b038116600081815260196020908152604091829020805460ff1916600117905590519182527f57a00f76b5f242fb1e04b0b514a6974665a5b07bce45e39f36dabff4a042d9369101610aa7565b6005546001600160a01b03163314610eed5760405162461bcd60e51b815260040161099490612994565b8015610f61576015544210610f615760405162461bcd60e51b815260206004820152603460248201527f546865206162696c69747920746f20626c61636b6c697374206163636f756e7460448201527339903430b9903132b2b7103234b9b0b13632b21760611b6064820152608401610994565b6001600160a01b03919091166000908152601860205260409020805460ff1916911515919091179055565b6005546001600160a01b03163314610fb65760405162461bcd60e51b815260040161099490612994565b610fc481633b9aca00612a3d565b601d556040518181527f5948780118f41f7c4577ae4619d5cbd064057bd8562d9f7b7e60324053375c0090602001610aa7565b6005546001600160a01b031633146110215760405162461bcd60e51b815260040161099490612994565b3060009081526020819052604090205461103a81611f81565b50565b6005546001600160a01b031633146110675760405162461bcd60e51b815260040161099490612994565b6103e8841115801561107b57506103e88311155b801561108957506103e88211155b801561109757506103e88111155b6110ed5760405162461bcd60e51b815260206004820152602160248201527f4665657320657863656564206d6178696d756d20616c6c6f7765642076616c756044820152606560f81b6064820152608401610994565b600b849055600c839055600e829055600f8190556040805185815260208101859052908101839052606081018290527f7027e29faa2460f22e800d92db38d4795b668c7104da6b87afaeaf502a269ca59060800160405180910390a150505050565b6005546001600160a01b031633146111795760405162461bcd60e51b815260040161099490612994565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546001600160a01b031633146111ed5760405162461bcd60e51b815260040161099490612994565b6109c481111561123f5760405162461bcd60e51b815260206004820152601e60248201527f4d6178696d756d206c61756e63682073656c6c206665652069732032352500006044820152606401610994565b60118190556040518181527fc799be5eb19a1a6d6ba7368d21e2bc367c8a335e4a07cd3d954482e6f714d3c590602001610aa7565b6060600480546108d090612a73565b6005546001600160a01b031633146112ad5760405162461bcd60e51b815260040161099490612994565b601754600160a81b900460ff16156113075760405162461bcd60e51b815260206004820152601b60248201527f416c726561647920707265706172656420666f72206c61756e636800000000006044820152606401610994565b6017805460ff60a81b1916600160a81b17905561132642610e10612a05565b6015556113364262093a80612a05565b601655565b60006109603384610b8485604051806060016040528060258152602001612b3d602591393360009081526001602090815260408083206001600160a01b038d1684529091529020549190611f47565b6000610960338484611b31565b6060600680548060200260200160405190810160405280929190818152602001828054801561094957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116113d1575050505050905090565b6005546001600160a01b031633146114225760405162461bcd60e51b815260040161099490612994565b6001600160a01b03811660009081526007602052604090205460ff166114965760405162461bcd60e51b8152602060048201526024808201527f41646472657373206973206e6f74206578636c756465642066726f6d207265776044820152636172647360e01b6064820152608401610994565b60005b60065481101561152957816001600160a01b0316600682815481106114ce57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415611517576001600160a01b0382166000908152600760205260409020805460ff1916905561151281612106565b611529565b8061152181612aa8565b915050611499565b506040516001600160a01b03821681527f87434094d24a90fbd9a8ffcf2be9818d237c06a12d126296bc1ea7d58959433490602001610aa7565b6005546001600160a01b0316331461158d5760405162461bcd60e51b815260040161099490612994565b601780546001600160a01b0319166001600160a01b0383169081179091556040519081527f535be0bbc71c839ded01277ab57f29f2e810c1ff0255bb938d7cb8e96ac8ca1a90602001610aa7565b6005546001600160a01b031633146116055760405162461bcd60e51b815260040161099490612994565b60058110156116565760405162461bcd60e51b815260206004820152601b60248201527f4d61782054582073686f756c642062652061626f766520302e352500000000006044820152606401610994565b6116756103e861166f681b1ae4d6e2ef500000846118e5565b9061196b565b60088190556040519081527f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf90602001610aa7565b6005546001600160a01b031633146116d45760405162461bcd60e51b815260040161099490612994565b60178054821515600160a01b0260ff60a01b199091161790556040517f7d952115fd41bb443db2ae9cde6670e8dd72fefb507b7a4e0156c57e439afaf590610aa790831515815260200190565b6005546001600160a01b0316331461174b5760405162461bcd60e51b815260040161099490612994565b6001600160a01b038116600081815260196020908152604091829020805460ff1916905590519182527f346f6c42af1ce4b7d7951f3fa40a2fb1e78c80ab0f3d76fb4f9fec269d568f0d9101610aa7565b6005546001600160a01b031633146117c65760405162461bcd60e51b815260040161099490612994565b6001600160a01b03811661182b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610994565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146118b15760405162461bcd60e51b815260040161099490612994565b601454479061103a906001600160a01b03168261223c565b60006118d361227c565b6002546118e09190612a5c565b905090565b6000826118f457506000610964565b60006119008385612a3d565b90508261190d8583612a1d565b146119645760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610994565b9392505050565b600061196483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506122f7565b6000806119ba8385612a05565b9050838110156119645760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610994565b6001600160a01b038316611a6e5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610994565b6001600160a01b038216611acf5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610994565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b601754600160a81b900460ff1680611b5357506005546001600160a01b031633145b611bc55760405162461bcd60e51b815260206004820152603f60248201527f436f6e747261637420686173206e6f74206265656e207072657061726564206660448201527f6f72206c61756e636820616e642075736572206973206e6f74206f776e6572006064820152608401610994565b6001600160a01b03831660009081526018602052604090205460ff16158015611c0757506001600160a01b03821660009081526018602052604090205460ff16155b611c495760405162461bcd60e51b8152602060048201526013602482015272426c61636b6c6973746564206164647265737360681b6044820152606401610994565b601754600160a01b900460ff1615611c6b57611c66838383612325565b505050565b6001600160a01b0383166000908152601a602052604090205460ff16158015611cad57506001600160a01b0382166000908152601a602052604090205460ff16155b15611d1457600854811115611d145760405162461bcd60e51b815260206004820152602760248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152661e105b5bdd5b9d60ca1b6064820152608401610994565b600e54600b54601c546001600160a01b0385811691161415611d5857600c54600b55600f54600e556016544211611d5857601154600b54611d54916119ad565b600b555b30600090815260208190526040902054601d5481108015908190611d865750601c54600160a01b900460ff16155b8015611da05750601c546001600160a01b03888116911614155b8015611db55750601c54600160a81b900460ff165b15611dc357611dc3826124a8565b6001600160a01b03871660009081526019602052604090205460ff1680611e0257506001600160a01b03861660009081526019602052604090205460ff165b15611e0f57611e0f612657565b600080611e1b8761269c565b6001600160a01b038b166000908152602081905260409020549193509150611e4390886126c3565b6001600160a01b03808b1660009081526020819052604080822093909355908a1681522054611e7290836119ad565b6001600160a01b038916600090815260208190526040902055611e9481612705565b6001600160a01b03891660009081526019602052604090205460ff1680611ed357506001600160a01b03881660009081526019602052604090205460ff165b15611eef57611eef600a54600955600d54600b55601054600e55565b600b859055600e8690556040518281526001600160a01b03808a1691908b16907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050505050505050565b60008184841115611f6b5760405162461bcd60e51b81526004016109949190612941565b506000611f788486612a5c565b95945050505050565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110611fc457634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152601b54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561201857600080fd5b505afa15801561202c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120509190612795565b8160018151811061207157634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152601b546120979130911684611a0c565b601b5460405163791ac94760e01b81526001600160a01b039091169063791ac947906120d09085906000908690309042906004016129c9565b600060405180830381600087803b1580156120ea57600080fd5b505af11580156120fe573d6000803e3d6000fd5b505050505050565b60065481106121625760405162461bcd60e51b815260206004820152602260248201527f496e6465782069732067726561746572207468616e206172726179206c656e676044820152610e8d60f31b6064820152608401610994565b6006805461217290600190612a5c565b8154811061219057634e487b7160e01b600052603260045260246000fd5b600091825260209091200154600680546001600160a01b0390921691839081106121ca57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600680548061221757634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b031916905501905550565b8015612278576040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015611c66573d6000803e3d6000fd5b5050565b600080805b6006548110156122f1576122d3600682815481106122af57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b03168252819052604090205490565b6122dd9083612a05565b9150806122e981612aa8565b915050612281565b50919050565b600081836123185760405162461bcd60e51b81526004016109949190612941565b506000611f788486612a1d565b6001600160a01b0383166123895760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610994565b6001600160a01b0382166123eb5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610994565b61242881604051806060016040528060268152602001612aef602691396001600160a01b0386166000908152602081905260409020549190611f47565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461245790826119ad565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101611b24565b601c805460ff60a01b1916600160a01b179055600954600e54600b546000926124dc9290916124d6916119ad565b906119ad565b9050806124e95750612647565b476124f383611f81565b60006124ff47836126c3565b905080156126435760006125228461166f600954856118e590919063ffffffff16565b60135490915061253b906001600160a01b03168261223c565b60006125568561166f600e54866118e590919063ffffffff16565b905060008111801561257257506017546001600160a01b031615155b156125d25760175460405163febd221b60e01b8152600960048201526001600160a01b039091169063febd221b9083906024016000604051808303818588803b1580156125be57600080fd5b505af1935050505080156125d0575060015b505b60006125ed8661166f600b54876118e590919063ffffffff16565b601454909150612606906001600160a01b03168261223c565b60408051888152602081018690527f3736f4ec17d19b9b4f0fbeeb377db969da082d70e2e16221f77d5b321570e8c7910160405180910390a15050505b5050505b50601c805460ff60a01b19169055565b600b541580156126675750600e54155b80156126735750600954155b1561267a57565b60098054600a55600b8054600d55600e80546010556000928390559082905555565b60008060006126aa84612732565b905060006126b885836126c3565b959194509092505050565b600061196483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611f47565b3060009081526020819052604090205461271f90826119ad565b3060009081526020819052604090205550565b6000806127526009546124d6600e54600b546119ad90919063ffffffff16565b905061196461271061166f85846118e5565b8035801515811461277457600080fd5b919050565b60006020828403121561278a578081fd5b813561196481612ad9565b6000602082840312156127a6578081fd5b815161196481612ad9565b600080604083850312156127c3578081fd5b82356127ce81612ad9565b915060208301356127de81612ad9565b809150509250929050565b6000806000606084860312156127fd578081fd5b833561280881612ad9565b9250602084013561281881612ad9565b929592945050506040919091013590565b6000806040838503121561283b578182fd5b823561284681612ad9565b915061285460208401612764565b90509250929050565b6000806040838503121561286f578182fd5b823561287a81612ad9565b946020939093013593505050565b600060208284031215612899578081fd5b61196482612764565b6000602082840312156128b3578081fd5b5035919050565b600080600080608085870312156128cf578081fd5b5050823594602084013594506040840135936060013592509050565b6000815180845260208085019450808401835b838110156129235781516001600160a01b0316875295820195908201906001016128fe565b509495945050505050565b60208152600061196460208301846128eb565b6000602080835283518082850152825b8181101561296d57858101830151858201604001528201612951565b8181111561297e5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b85815284602082015260a0604082015260006129e860a08301866128eb565b6001600160a01b0394909416606083015250608001529392505050565b60008219821115612a1857612a18612ac3565b500190565b600082612a3857634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612a5757612a57612ac3565b500290565b600082821015612a6e57612a6e612ac3565b500390565b600181811c90821680612a8757607f821691505b602082108114156122f157634e487b7160e01b600052602260045260246000fd5b6000600019821415612abc57612abc612ac3565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461103a57600080fdfe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220d99a3c6f90007aa8e3c2f196221ac73b7fa025de5da8a7ca4dcd06f45520023664736f6c63430008040033

Verified Source Code Partial Match

Compiler: v0.8.4+commit.c7e474f2 EVM: istanbul Optimization: Yes (200 runs)
ERC20.sol 312 lines
pragma solidity ^0.8.4;

// SPDX-License-Identifier: MIT

import "./IERC20.sol";
import "./IERC20Metadata.sol";
import "./Context.sol";
import "./SafeMath.sol";
import "./Address.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, IERC20Metadata {
    using SafeMath for uint256;
    using Address for address;

    mapping(address => uint256) internal _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 internal _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two 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 override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override 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
     * overridden;
     *
     * 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 override 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);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        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].add(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) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        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);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(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:
     *
     * - `account` 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 = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(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);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(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 {}
}
IERC20.sol 81 lines
pragma solidity ^0.8.4;

// SPDX-License-Identifier: MIT

/**
 * @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 181 lines
pragma solidity ^0.8.4;

// SPDX-License-Identifier: MIT

/**
 * @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) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            codehash := extcodehash(account)
        }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @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"
        );
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(
        address target,
        bytes memory data,
        uint256 weiValue,
        string memory errorMessage
    ) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{value: weiValue}(
            data
        );
        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 14 lines
pragma solidity ^0.8.4;

// SPDX-License-Identifier: MIT

abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}
Ownable.sol 75 lines
pragma solidity 0.8.4;

// SPDX-License-Identifier: MIT

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.
 */
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 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() external 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) external virtual onlyOwner {
        require(
            newOwner != address(0),
            "Ownable: new owner is the zero address"
        );
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}
SafeMath.sol 172 lines
pragma solidity ^0.8.4;

// SPDX-License-Identifier: MIT

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */

library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}
HERO Coin.sol 430 lines
pragma solidity ^0.8.4;

// SPDX-License-Identifier: Apache-2.0

import "./SafeMath.sol";
import "./Address.sol";
import "./RewardsToken.sol";
import "./IUniswapV2Factory.sol";
import "./IUniswapV2Router.sol";
import "./IRewardsTracker.sol";

contract ChallengeCoin is RewardsToken {
    using SafeMath for uint256;
    using Address for address;
    
    // Supply, limits and fees
    uint256 private constant REWARDS_TRACKER_IDENTIFIER = 9;
    uint256 private constant TOTAL_SUPPLY = 500000000000 * (10**9);

    uint256 public maxTxAmount = TOTAL_SUPPLY.mul(2).div(1000); // 2%

    uint256 private platformFee = 600; //  6%
    uint256 private _previousPlatformFee = platformFee;

    uint256 public devFee = 400; // 4%
    uint256 public sellDevFee = 700; // 7%
    uint256 private _previousDevFee = devFee;
    
    uint256 public rewardsFee = 200; // 2%
    uint256 public sellRewardsFee = 200; // 2%
    uint256 private _previousRewardsFee = rewardsFee;

    uint256 public launchSellFee = 925; // 9.25%
    uint256 private _previousLaunchSellFee = launchSellFee;

    address payable private _platformWalletAddress =
        payable(0x3E99a588eE8cD107dbD8F8Ae125c1F50D2b81140);
    address payable private _devWalletAddress =
        payable(0x05d9864854C60E8d2e46eF46D5968D12aCd30D63);

    uint256 public blacklistDeadline = 0;
    uint256 public launchSellFeeDeadline = 0;

    IRewardsTracker private _rewardsTracker;

    // Fallback to generic transfer. On by default
    bool public useGenericTransfer = true;

    // Prepared for launch
    bool private preparedForLaunch = false;

    // Blacklist
    mapping(address => bool) public isBlacklisted;
    
    // Exclusions
    mapping(address => bool) private _isExcludedFromFee;
    mapping(address => bool) private _isExcludedFromMaxTx;
    
    // Token -> ETH swap support
    IUniswapV2Router public uniswapV2Router;
    address public uniswapV2Pair;

    bool currentlySwapping;
    bool public swapAndRedirectEthFeesEnabled = true;

    uint256 private minTokensBeforeSwap = 1250000000 * 10**9;

    // Events and modifiers
    event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
    event SwapAndRedirectEthFeesUpdated(bool enabled);
    event OnSwapAndRedirectEthFees(
        uint256 tokensSwapped,
        uint256 ethToDevWallet
    );
    event MaxTxAmountUpdated(uint256 maxTxAmount);
    event GenericTransferChanged(bool useGenericTransfer);
    event ExcludeFromFees(address wallet);
    event IncludeInFees(address wallet);
    event DevWalletUpdated(address newDevWallet);
    event RewardsTrackerUpdated(address newRewardsTracker);
    event RouterUpdated(address newRouterAddress);
    event FeesChanged(
        uint256 newDevFee,
        uint256 newSellDevFee,
        uint256 newRewardsFee,
        uint256 newSellRewardsFee
    );
    event LaunchFeeUpdated(uint256 newLaunchSellFee);

    modifier lockTheSwap() {
        currentlySwapping = true;
        _;
        currentlySwapping = false;
    }

    constructor() ERC20("Challenge Coin", "HERO") {
        IUniswapV2Router _uniswapV2Router = IUniswapV2Router(
            0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
        );
        // Create a uniswap pair for this new token
        uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
            .createPair(address(this), _uniswapV2Router.WETH());

        // set the rest of the contract variables
        uniswapV2Router = _uniswapV2Router;
        
        // mint supply
        _mint(owner(), TOTAL_SUPPLY);

        // exclude owner and this contract from fee
        _isExcludedFromFee[owner()] = true;
        _isExcludedFromFee[address(this)] = true;
        
        // internal exclude from max tx
        _isExcludedFromMaxTx[owner()] = true;
        _isExcludedFromMaxTx[address(this)] = true;
        
        // exclude from rewards
        excludeFromRewards(address(this));
        excludeFromRewards(address(0xdead));
        excludeFromRewards(uniswapV2Pair);
    }
    
    function decimals() public view virtual override returns (uint8) {
        return 9;
    }

    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual override {
        // launch preparation
        require(preparedForLaunch || _msgSender() == owner(), "Contract has not been prepared for launch and user is not owner");

        // blacklist
        require(
            !isBlacklisted[from] && !isBlacklisted[to],
            "Blacklisted address"
        );

        // fallback implementation
        if (useGenericTransfer) {
            super._transfer(from, to, amount);
            return;
        }

        if (
            !_isExcludedFromMaxTx[from] &&
            !_isExcludedFromMaxTx[to] // by default false
        ) {
            require(
                amount <= maxTxAmount,
                "Transfer amount exceeds the maxTxAmount"
            );
        }

        // sell fees
        uint256 baseRewardsFee = rewardsFee;
        uint256 baseDevFee = devFee;
        if (to == uniswapV2Pair) {
            devFee = sellDevFee;
            rewardsFee = sellRewardsFee;

            if (launchSellFeeDeadline >= block.timestamp) {
                devFee = devFee.add(launchSellFee);
            }
        }

        // start swap to ETH
        uint256 contractTokenBalance = balanceOf(address(this));
        bool overMinTokenBalance = contractTokenBalance >= minTokensBeforeSwap;
        if (
            overMinTokenBalance &&
            !currentlySwapping &&
            from != uniswapV2Pair &&
            swapAndRedirectEthFeesEnabled
        ) {
            // add dev fee
            swapAndRedirectEthFees(contractTokenBalance);
        }

        if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
            removeAllFee();
        }

        (uint256 tTransferAmount, uint256 tFee) = _getValues(amount);
        _balances[from] = _balances[from].sub(amount);
        _balances[to] = _balances[to].add(tTransferAmount);

        _takeFee(tFee);

        if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
            restoreAllFee();
        }

        // restore fees
        devFee = baseDevFee;
        rewardsFee = baseRewardsFee;

        emit Transfer(from, to, tTransferAmount);
    }

    //to recieve ETH from uniswapV2Router when swaping
    receive() external payable {}

    function _getValues(uint256 tAmount)
        private
        view
        returns (uint256, uint256)
    {
        uint256 tFee = calculateFee(tAmount);
        uint256 tTransferAmount = tAmount.sub(tFee);
        return (tTransferAmount, tFee);
    }

    function _takeFee(uint256 fee) private {
        _balances[address(this)] = _balances[address(this)].add(fee);
    }

    function calculateFee(uint256 _amount)
        private
        view
        returns (uint256)
    {
        uint256 totalFee = devFee.add(rewardsFee).add(platformFee);
        return _amount.mul(totalFee).div(10000);
    }

    function removeAllFee() private {
        if (devFee == 0 && rewardsFee == 0 && platformFee == 0) return;

        _previousPlatformFee = platformFee;
        _previousDevFee = devFee;
        _previousRewardsFee = rewardsFee;

        platformFee = 0;
        devFee = 0;
        rewardsFee = 0;
    }

    function restoreAllFee() private {
        platformFee = _previousPlatformFee;
        devFee = _previousDevFee;
        rewardsFee = _previousRewardsFee;
    }

    function swapAndRedirectEthFees(uint256 contractTokenBalance)
        private
        lockTheSwap
    {
        uint256 totalRedirectFee = devFee.add(rewardsFee).add(platformFee);
        if (totalRedirectFee == 0) return;
        
        // capture the contract's current ETH balance.
        // this is so that we can capture exactly the amount of ETH that the
        // swap creates, and not make the fee events include any ETH that
        // has been manually sent to the contract
        uint256 initialBalance = address(this).balance;

        // swap tokens for ETH
        swapTokensForEth(contractTokenBalance);

        uint256 newBalance = address(this).balance.sub(initialBalance);

        if (newBalance > 0) {
            // send to platform wallet
            uint256 platformBalance = newBalance.mul(platformFee).div(totalRedirectFee);
            sendEthToWallet(_platformWalletAddress, platformBalance);

            //
            // send to rewards wallet
            //
            uint256 rewardsBalance = newBalance.mul(rewardsFee).div(totalRedirectFee);
            if (rewardsBalance > 0 && address(_rewardsTracker) != address(0)) {
                try _rewardsTracker.addAllocation{value: rewardsBalance}(REWARDS_TRACKER_IDENTIFIER) {} catch {}
            }
            
            //
            // send to dev wallet
            //
            uint256 devBalance = newBalance.mul(devFee).div(totalRedirectFee);
            sendEthToWallet(_devWalletAddress, devBalance);

            emit OnSwapAndRedirectEthFees(contractTokenBalance, newBalance);
        }
    }

    function sendEthToWallet(address wallet, uint256 amount) private {
        if (amount > 0) {
            payable(wallet).transfer(amount);
        }
    }

    function swapTokensForEth(uint256 tokenAmount) private {
        // generate the uniswap pair path of token -> weth
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = uniswapV2Router.WETH();

        _approve(address(this), address(uniswapV2Router), tokenAmount);

        // make the swap
        uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokenAmount,
            0, // accept any amount of ETH
            path,
            address(this),
            block.timestamp
        );
    }

    function prepareForLaunch() external onlyOwner {
        require(!preparedForLaunch, "Already prepared for launch");

        // ready for launch
        preparedForLaunch = true;

        // a maximum of 1 hour is given to blacklist snipers/flashbots
        blacklistDeadline = block.timestamp + 1 hours;

        // sell penalty for the first 24 hours
        launchSellFeeDeadline = block.timestamp + 7 days;
    }

    function setUseGenericTransfer(bool genericTransfer) external onlyOwner {
        useGenericTransfer = genericTransfer;
        emit GenericTransferChanged(genericTransfer);
    }

    function blacklistAddress(address account, bool value) public onlyOwner {
        if (value) {
            require(block.timestamp < blacklistDeadline, "The ability to blacklist accounts has been disabled.");
        }
        isBlacklisted[account] = value;
    }

    
    // for 0.5% input 5, for 1% input 10
    function setMaxTxPercent(uint256 newMaxTx) external onlyOwner {
        require(newMaxTx >= 5, "Max TX should be above 0.5%");
        maxTxAmount = TOTAL_SUPPLY.mul(newMaxTx).div(1000);
        emit MaxTxAmountUpdated(maxTxAmount);
    }
    
    function isExcludedFromFee(address account) external view returns (bool) {
        return _isExcludedFromFee[account];
    }

    function excludeFromFee(address account) external onlyOwner {
        _isExcludedFromFee[account] = true;
        emit ExcludeFromFees(account);
    }

    function includeInFee(address account) external onlyOwner {
        _isExcludedFromFee[account] = false;
        emit IncludeInFees(account);
    }

    function setFees(
        uint256 newDevFee,
        uint256 newSellDevFee,
        uint256 newRewardsFee,
        uint256 newSellRewardsFee
    ) external onlyOwner {
        require(
            newDevFee <= 1000 &&
            newSellDevFee <= 1000 &&
            newRewardsFee <= 1000 &&
            newSellRewardsFee <= 1000,
            "Fees exceed maximum allowed value"
        );
        devFee = newDevFee;
        sellDevFee = newSellDevFee;
        rewardsFee = newRewardsFee;
        sellRewardsFee = newSellRewardsFee;
        emit FeesChanged(newDevFee, newSellDevFee, newRewardsFee, newSellRewardsFee);
    }

    function setLaunchSellFee(uint256 newLaunchSellFee) external onlyOwner {
        require(newLaunchSellFee <= 2500, "Maximum launch sell fee is 25%");
        launchSellFee = newLaunchSellFee;
        emit LaunchFeeUpdated(newLaunchSellFee);
    }

    function setDevWallet(address payable newDevWallet)
        external
        onlyOwner
    {
        _devWalletAddress = newDevWallet;
        emit DevWalletUpdated(newDevWallet);
    }
    
    function setRewardsTracker(address payable newRewardsTracker)
        external
        onlyOwner
    {
        _rewardsTracker = IRewardsTracker(newRewardsTracker);
        emit RewardsTrackerUpdated(newRewardsTracker);
    }

    function setRouterAddress(address newRouter) external onlyOwner {
        IUniswapV2Router _newUniswapRouter = IUniswapV2Router(newRouter);
        uniswapV2Pair = IUniswapV2Factory(_newUniswapRouter.factory())
            .createPair(address(this), _newUniswapRouter.WETH());
        uniswapV2Router = _newUniswapRouter;
        emit RouterUpdated(newRouter);
    }

    function setSwapAndRedirectEthFeesEnabled(bool enabled) external onlyOwner {
        swapAndRedirectEthFeesEnabled = enabled;
        emit SwapAndRedirectEthFeesUpdated(enabled);
    }

    function setMinTokensBeforeSwap(uint256 minTokens) external onlyOwner {
        minTokensBeforeSwap = minTokens * 10**9;
        emit MinTokensBeforeSwapUpdated(minTokens);
    }
    
    // emergency claim functions
    function manualSwap() external onlyOwner {
        uint256 contractBalance = balanceOf(address(this));
        swapTokensForEth(contractBalance);
    }

    function manualSend() external onlyOwner {
        uint256 contractEthBalance = address(this).balance;
        sendEthToWallet(_devWalletAddress, contractEthBalance);
    }
}
RewardsToken.sol 60 lines
pragma solidity ^0.8.4;

// SPDX-License-Identifier: Apache-2.0

import "./ERC20.sol";
import "./Ownable.sol";

abstract contract RewardsToken is ERC20, Ownable {

    address[] private excludedFromRewards;
    mapping(address => bool) private isAddressExcluded;
    
    event ExcludeFromRewards(address wallet);
    event IncludeInRewards(address wallet);
    
    function deleteExcluded(uint index) internal {
        require(index < excludedFromRewards.length, "Index is greater than array length");
        excludedFromRewards[index] = excludedFromRewards[excludedFromRewards.length - 1];
        excludedFromRewards.pop();
    }
    
    function getExcludedBalances() internal view returns (uint256) {
        uint256 totalExcludedHoldings = 0;
        for (uint i = 0; i < excludedFromRewards.length; i++) {
            totalExcludedHoldings += balanceOf(excludedFromRewards[i]);
        }
        return totalExcludedHoldings;
    }
    
    function excludeFromRewards(address wallet) public onlyOwner {
        require(!isAddressExcluded[wallet], "Address is already excluded from rewards");
        excludedFromRewards.push(wallet);
        isAddressExcluded[wallet] = true;
        emit ExcludeFromRewards(wallet);
    }
    
    function includeInRewards(address wallet) external onlyOwner {
        require(isAddressExcluded[wallet], "Address is not excluded from rewards");
        for (uint i = 0; i < excludedFromRewards.length; i++) {
            if (excludedFromRewards[i] == wallet) {
                isAddressExcluded[wallet] = false;
                deleteExcluded(i);
                break;
            }
        }
        emit IncludeInRewards(wallet);
    }
    
    function isExcludedFromRewards(address wallet) external view returns (bool) {
        return isAddressExcluded[wallet];
    }
    
    function getAllExcludedFromRewards() external view returns (address[] memory) {
        return excludedFromRewards;
    }
    
    function getRewardsSupply() public view returns (uint256) {
        return _totalSupply - getExcludedBalances();
    }
}
IERC20Metadata.sol 27 lines
pragma solidity ^0.8.4;

// SPDX-License-Identifier: MIT

import "./IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}
IRewardsTracker.sol 8 lines
pragma solidity 0.8.4;

// SPDX-License-Identifier: Apache-2.0

interface IRewardsTracker {
    
    function addAllocation(uint identifier) external payable;
}
IUniswapV2Router.sol 18 lines
pragma solidity 0.8.4;

// SPDX-License-Identifier: MIT

interface IUniswapV2Router {
    
    function factory() external pure returns (address);
    
    function WETH() external pure returns (address);

    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;
}
IUniswapV2Factory.sol 10 lines
pragma solidity 0.8.4;

// SPDX-License-Identifier: MIT

interface IUniswapV2Factory {

    function createPair(address tokenA, address tokenB)
        external
        returns (address pair);
}

Read Contract

allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
blacklistDeadline 0xcf0c018b → uint256
decimals 0x313ce567 → uint8
devFee 0x6827e764 → uint256
getAllExcludedFromRewards 0xada46d0a → address[]
getRewardsSupply 0xfffa1dd9 → uint256
isBlacklisted 0xfe575a87 → bool
isExcludedFromFee 0x5342acb4 → bool
isExcludedFromRewards 0x0e832273 → bool
launchSellFee 0x54959363 → uint256
launchSellFeeDeadline 0xaf01f2b2 → uint256
maxTxAmount 0x8c0b5e22 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
rewardsFee 0x2bb14e1d → uint256
sellDevFee 0xa0d82dc5 → uint256
sellRewardsFee 0xbb8d5131 → uint256
swapAndRedirectEthFeesEnabled 0x113201fa → bool
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
uniswapV2Pair 0x49bd5a5e → address
uniswapV2Router 0x1694505e → address
useGenericTransfer 0x98850b64 → bool

Write Contract 24 functions

These functions modify contract state and require a wallet transaction to execute.

approve 0x095ea7b3
address spender
uint256 amount
returns: bool
blacklistAddress 0x455a4396
address account
bool value
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
excludeFromFee 0x437823ec
address account
excludeFromRewards 0x111e0376
address wallet
includeInFee 0xea2f0b37
address account
includeInRewards 0xb609995e
address wallet
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
manualSend 0xf4293890
No parameters
manualSwap 0x51bc3c85
No parameters
prepareForLaunch 0xa1ab19a3
No parameters
renounceOwnership 0x715018a6
No parameters
setDevWallet 0x1f53ac02
address newDevWallet
setFees 0x6fcba377
uint256 newDevFee
uint256 newSellDevFee
uint256 newRewardsFee
uint256 newSellRewardsFee
setLaunchSellFee 0x8421b507
uint256 newLaunchSellFee
setMaxTxPercent 0xd543dbeb
uint256 newMaxTx
setMinTokensBeforeSwap 0x48a46473
uint256 minTokens
setRewardsTracker 0xba385abb
address newRewardsTracker
setRouterAddress 0x41cb87fc
address newRouter
setSwapAndRedirectEthFeesEnabled 0x26b6308d
bool enabled
setUseGenericTransfer 0xe89bcca2
bool genericTransfer
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferFrom 0x23b872dd
address sender
address recipient
uint256 amount
returns: bool
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address