Address Contract Partially Verified
Address
0x0275E1001e293C46CFe158B3702AADe0B99f88a5
Balance
0 ETH
Nonce
1
Code Size
10194 bytes
Creator
0xfe95c45e...3Aa9 at tx 0x65020e85...0e4ddb
Indexed Transactions
0
Contract Bytecode
10194 bytes
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c8063715018a611610104578063a457c2d7116100a2578063dd62ed3e11610071578063dd62ed3e14610699578063f2d5d56b146106d4578063f2fde38b1461070d578063ff9e884d14610740576101da565b8063a457c2d7146105ab578063a9059cbb146105e4578063b753a98c1461061d578063bb35783b14610656576101da565b80638da5cb5b116100de5780638da5cb5b1461052c5780638f32d59b146105345780638fcbaf0c1461053c57806395d89b41146105a3576101da565b8063715018a6146104e95780637a13685a146104f15780637ecebe00146104f9576101da565b80633644e5151161017c57806354fd4d501161014b57806354fd4d501461046957806369ffa08a146104715780636e15d21b146104ae57806370a08231146104b6576101da565b80633644e5151461036557806337fb7e211461036d578063395093511461039e5780634000aea0146103d7576101da565b8063238a3fe1116101b8578063238a3fe1146102c357806323b872dd146102fc57806330adf81f1461033f578063313ce56714610347576101da565b806306fdde03146101df578063095ea7b31461025c57806318160ddd146102a9575b600080fd5b6101e761077b565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610221578181015183820152602001610209565b50505050905090810190601f16801561024e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102956004803603604081101561027257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561082f565b604080519115158252519081900360200190f35b6102b1610845565b60408051918252519081900360200190f35b610295600480360360408110156102d957600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561084b565b6102956004803603606081101561031257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610922565b6102b1610944565b61034f610968565b6040805160ff9092168252519081900360200190f35b6102b1610971565b610375610977565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b610295600480360360408110156103b457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610993565b610295600480360360608110156103ed57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8235169160208101359181019060608101604082013564010000000081111561042a57600080fd5b82018360208201111561043c57600080fd5b8035906020019184600183028401116401000000008311171561045e57600080fd5b5090925090506109e1565b6101e7610c25565b6104ac6004803603604081101561048757600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610c5e565b005b610375610eeb565b6102b1600480360360208110156104cc57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610f07565b6104ac610f2f565b610375611009565b6102b16004803603602081101561050f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611025565b610375611037565b610295611053565b6104ac600480360361010081101561055357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013590911690604081013590606081013590608081013515159060ff60a0820135169060c08101359060e00135611071565b6101e761140e565b610295600480360360408110156105c157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561148d565b610295600480360360408110156105fa57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356114d6565b6104ac6004803603604081101561063357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356114ed565b6104ac6004803603606081101561066c57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013590911690604001356114f8565b6102b1600480360360408110156106af57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611509565b6104ac600480360360408110156106ea57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135611541565b6104ac6004803603602081101561072357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661154c565b6102b16004803603604081101561075657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166115cb565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108255780601f106107fa57610100808354040283529160200191610825565b820191906000526020600020905b81548152906001019060200180831161080857829003601f168201915b5050505050905090565b600061083c3384846115e8565b50600192915050565b60035490565b600a5460009073ffffffffffffffffffffffffffffffffffffffff1633148061088b5750600b5473ffffffffffffffffffffffffffffffffffffffff1633145b806108ad5750600c5473ffffffffffffffffffffffffffffffffffffffff1633145b61091857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f77726f6e672073656e6465720000000000000000000000000000000000000000604482015290519081900360640190fd5b61083c838361172f565b600061092f8484846118d8565b61093a848484611953565b5060019392505050565b7fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb81565b60065460ff1690565b60075481565b600a5473ffffffffffffffffffffffffffffffffffffffff1681565b33600081815260026020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909161083c9185906109dc908663ffffffff611b5616565b6115e8565b60008473ffffffffffffffffffffffffffffffffffffffff811615801590610a1f575073ffffffffffffffffffffffffffffffffffffffff81163014155b610a8a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f6e6f7420612076616c696420726563697069656e740000000000000000000000604482015290519081900360640190fd5b610a94868661172f565b8573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c1687878760405180848152602001806020018281038252848482818152602001925080828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909201829003965090945050505050a3610b678673ffffffffffffffffffffffffffffffffffffffff16611bd1565b15610c1957610bae33878787878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611bd792505050565b610c1957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f636f6e74726163742063616c6c206661696c6564000000000000000000000000604482015290519081900360640190fd5b50600195945050505050565b6040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b610c66611053565b610cd157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8073ffffffffffffffffffffffffffffffffffffffff811615801590610d0d575073ffffffffffffffffffffffffffffffffffffffff81163014155b610d7857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f6e6f7420612076616c696420726563697069656e740000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8316610e1d5760405130319073ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083906000818181858888f19350505050610e17578083604051610dda906125d5565b73ffffffffffffffffffffffffffffffffffffffff9091168152604051908190036020019082f080158015610e13573d6000803e3d6000fd5b5050505b50610ee6565b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051849160009173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610e8e57600080fd5b505afa158015610ea2573d6000803e3d6000fd5b505050506040513d6020811015610eb857600080fd5b50519050610ee373ffffffffffffffffffffffffffffffffffffffff8316858363ffffffff611e7216565b50505b505050565b600c5473ffffffffffffffffffffffffffffffffffffffff1681565b73ffffffffffffffffffffffffffffffffffffffff1660009081526001602052604090205490565b610f37611053565b610fa257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f6e6f7420696d706c656d656e7465640000000000000000000000000000000000604482015290519081900360640190fd5b600b5473ffffffffffffffffffffffffffffffffffffffff1681565b60086020526000908152604090205481565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60005473ffffffffffffffffffffffffffffffffffffffff16331490565b841580611085575084611082611eff565b11155b6110f057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f696e76616c696420657870697279000000000000000000000000000000000000604482015290519081900360640190fd5b600754604080517fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb60208083019190915273ffffffffffffffffffffffffffffffffffffffff808d16838501528b166060830152608082018a905260a0820189905287151560c0808401919091528351808403909101815260e0830184528051908201207f1901000000000000000000000000000000000000000000000000000000000000610100840152610102830194909452610122808301949094528251808303909401845261014282018084528451948201949094206000909452610162820180845284905260ff87166101828301526101a282018690526101c2820185905291516001926101e28084019391927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611240573d6000803e3d6000fd5b5050506020604051035173ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff16146112e357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f696e76616c6964207369676e6174757265206f7220706172616d657465727300604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff89166000908152600860205260409020805460018101909155871461137e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f696e76616c6964206e6f6e636500000000000000000000000000000000000000604482015290519081900360640190fd5b60008561138c5760006113ae565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b90506113bb8a8a836115e8565b856113c75760006113c9565b865b73ffffffffffffffffffffffffffffffffffffffff9a8b1660009081526009602090815260408083209c909d1682529a909a5299909820989098555050505050505050565b60058054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108255780601f106107fa57610100808354040283529160200191610825565b33600081815260026020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909161083c9185906109dc908663ffffffff611f0316565b60006114e2838361172f565b61083c338484611953565b610ee6338383610922565b611503838383610922565b50505050565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260026020908152604080832093909416825291909152205490565b610ee6823383610922565b611554611053565b6115bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6115c881611f7a565b50565b600960209081526000928352604080842090915290825290205481565b73ffffffffffffffffffffffffffffffffffffffff8316611654576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806126f56024913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82166116c0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061265d6022913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600a5460009073ffffffffffffffffffffffffffffffffffffffff1633148061176f5750600b5473ffffffffffffffffffffffffffffffffffffffff1633145b806117915750600c5473ffffffffffffffffffffffffffffffffffffffff1633145b1561185f57336000908152600160205260409020546117b6908363ffffffff611f0316565b336000908152600160205260408082209290925573ffffffffffffffffffffffffffffffffffffffff8516815220546117f5908363ffffffff611b5616565b73ffffffffffffffffffffffffffffffffffffffff84166000818152600160209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600161186c565b6118698383612073565b90505b80610ee657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f7472616e73666572206661696c65640000000000000000000000000000000000604482015290519081900360640190fd5b60006118e5848484612080565b90508061150357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f7472616e73666572206661696c65640000000000000000000000000000000000604482015290519081900360640190fd5b6119728273ffffffffffffffffffffffffffffffffffffffff16611bd1565b8015611999575060408051600081526020810190915261199790849084908490611bd7565b155b15610ee657600a5473ffffffffffffffffffffffffffffffffffffffff83811691161415611a12576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b81526020018061267f602b913960400191505060405180910390fd5b600b5473ffffffffffffffffffffffffffffffffffffffff83811691161415611a86576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180612770602e913960400191505060405180910390fd5b600c5473ffffffffffffffffffffffffffffffffffffffff83811691161415611afa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180612743602d913960400191505060405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff80861682528416602082015280820183905290517f11249f0fc79fc134a15a10d1da8291b79515bf987e036ced05b9ec119614070b9181900360600190a1505050565b600082820183811015611bca57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3b151590565b600060606040518060600160405280602681526020016126aa60269139905060008573ffffffffffffffffffffffffffffffffffffffff1682888787604051602401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611c8b578181015183820152602001611c73565b50505050905090810190601f168015611cb85780820380516001836020036101000a031916815260200191505b50945050505050604051602081830303815290604052906040518082805190602001908083835b60208310611d1c57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611cdf565b5181517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60209485036101000a01908116901991909116179052604080519490920184900390932092860180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090941693909317835251855190945084935090508083835b60208310611dfd57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611dc0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611e5f576040519150601f19603f3d011682016040523d82523d6000602084013e611e64565b606091505b509098975050505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610ee69084906121de565b4290565b600082821115611f7457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b73ffffffffffffffffffffffffffffffffffffffff8116611fe6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806126376026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600061083c33848461241c565b600061208d84848461241c565b73ffffffffffffffffffffffffffffffffffffffff8416331461093a5760006120b68533611509565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146120f9576120f485336109dc848763ffffffff611f0316565b6121d8565b73ffffffffffffffffffffffffffffffffffffffff85166000908152600960209081526040808320338452909152902054158061216d5750612139611eff565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260096020908152604080832033845290915290205410155b6121d857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f65787069727920697320696e2074686520706173740000000000000000000000604482015290519081900360640190fd5b5061093a565b6121fd8273ffffffffffffffffffffffffffffffffffffffff16611bd1565b61226857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b602083106122d157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612294565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612333576040519150601f19603f3d011682016040523d82523d6000602084013e612338565b606091505b5091509150816123a957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115611503578080602001905160208110156123c557600080fd5b5051611503576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612719602a913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316612488576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806126d06025913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82166124f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806126146023913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604090205461252a908263ffffffff611f0316565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020526040808220939093559084168152205461256c908263ffffffff611b5616565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6032806125e28339019056fe60806040526040516032380380603283398181016040526020811015602357600080fd5b50516001600160a01b038116fffe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373796f752063616e2774207472616e7366657220746f20446973747269627574696f6e20636f6e74726163746f6e546f6b656e5472616e7366657228616464726573732c75696e743235362c62797465732945524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564796f752063616e2774207472616e7366657220746f2041647669736f727352657761726420636f6e7472616374796f752063616e2774207472616e7366657220746f20507269766174654f66666572696e6720636f6e7472616374a265627a7a72315820e258745d64b9a9f804a41d6a4de7e626a022dff24689929254ad4396ed1adbf064736f6c634300050c0032
Verified Source Code Partial Match
Compiler: v0.5.12+commit.7709ece9
EVM: istanbul
Optimization: Yes (999999 runs)
SafeMath.sol 107 lines
pragma solidity ^0.5.0;
/**
* @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) {
require(b <= a, "SafeMath: subtraction overflow");
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-solidity/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) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, "SafeMath: division by zero");
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) {
require(b != 0, "SafeMath: modulo by zero");
return a % b;
}
}
Address.sol 27 lines
pragma solidity ^0.5.0;
/**
* @dev Collection of functions related to the address type,
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* This test is non-exhaustive, and there may be false-negatives: during the
* execution of a contract's constructor, its address will be reported as
* not containing a contract.
*
* > It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*/
function isContract(address account) internal view returns (bool) {
// This method relies in 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;
}
}
Ownable.sol 75 lines
pragma solidity ^0.5.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be aplied to your functions to restrict their use to
* the owner.
*/
contract Ownable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
/**
* @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(isOwner(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() public view returns (bool) {
return msg.sender == _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 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 onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
IERC20.sol 76 lines
pragma solidity ^0.5.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see `ERC20Detailed`.
*/
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.
*
* > 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);
}
SafeERC20.sol 75 lines
pragma solidity ^0.5.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves.
// A Solidity high level call has three parts:
// 1. The target address is checked to verify it contains contract code
// 2. The call itself is made, and success asserted
// 3. The return value is decoded, which in turn checks the size of the returned data.
// solhint-disable-next-line max-line-length
require(address(token).isContract(), "SafeERC20: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
ERC20Detailed.sol 54 lines
pragma solidity ^0.5.0;
import "./IERC20.sol";
/**
* @dev Optional functions from the ERC20 standard.
*/
contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
* these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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.
*
* > Note that 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 returns (uint8) {
return _decimals;
}
}
ERC20.sol 236 lines
pragma solidity 0.5.12;
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
/**
* @dev Implementation of the `IERC20` interface.
*
* This implementation was taken from
* https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/token/ERC20/ERC20.sol
* This differs from the original one only in the definition for the `_balances`
* mapping: we made it `internal` instead of `private` since we use the `_balances`
* in the `ERC677BridgeToken` child contract to be able to transfer tokens to address(0)
* (see its `_superTransfer` function). The original OpenZeppelin implementation
* doesn't allow transferring to address(0).
*
* 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 `ERC20Mintable`.
*
* *For a detailed writeup see our guide [How to implement supply
* mechanisms](https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226).*
*
* 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 IERC20 {
using SafeMath for uint256;
mapping (address => uint256) internal _balances; // CHANGED: not private to write a custom transfer method
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev See `IERC20.totalSupply`.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See `IERC20.balanceOf`.
*/
function balanceOf(address account) public view 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 returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See `IERC20.allowance`.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See `IERC20.approve`.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
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 `value`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(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 returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][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 returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(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 {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount);
_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
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destoys `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 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
/**
* @dev Destoys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See `_burn` and `_approve`.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, msg.sender, _allowances[account][msg.sender].sub(amount));
}
}
IDistribution.sol 8 lines
pragma solidity 0.5.12;
interface IDistribution {
function isInitialized() external view returns (bool);
function distributionStartTimestamp() external view returns (uint256);
function supply() external view returns(uint256);
function poolAddress(uint8) external view returns(address);
}
Sacrifice.sol 8 lines
pragma solidity 0.5.12;
contract Sacrifice {
constructor(address payable _recipient) public payable {
selfdestruct(_recipient);
}
}
OilerToken.sol 232 lines
pragma solidity 0.5.12;
import "openzeppelin-solidity/contracts/utils/Address.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";
import "./ERC20Permittable.sol";
import "./Sacrifice.sol";
import "../IDistribution.sol";
// This is Vesting token
//
// We used xDAI vesting implementation:
// https://github.com/xdaichain/stake-token/blob/master/contracts/Token/ERC677BridgeToken.sol
//
// Stripping it of any Bridges and other stuff
contract OilerToken is Ownable, ERC20Permittable {
using SafeERC20 for ERC20;
using Address for address;
/// @dev Distribution contract address.
address public distributionAddress;
/// @dev The PrivateOffering contract address.
address public privateOfferingDistributionAddress;
/// @dev The AdvisorsReward contract address.
address public advisorsRewardDistributionAddress;
/// @dev Mint event.
/// @param to To address.
/// @param amount Minted value.
event Mint(address indexed to, uint256 amount);
/// @dev Modified Transfer event with custom data.
/// @param from From address.
/// @param to To address.
/// @param value Transferred value.
/// @param data Custom data to call after transfer.
event Transfer(address indexed from, address indexed to, uint256 value, bytes data);
/// @dev Emits if custom call after transfer fails.
/// @param from From address.
/// @param to To address.
/// @param value Transferred value.
event ContractFallbackCallFailed(address from, address to, uint256 value);
/// @dev Checks that the recipient address is valid.
/// @param _recipient Recipient address.
modifier validRecipient(address _recipient) {
require(_recipient != address(0) && _recipient != address(this), "not a valid recipient");
_;
}
/// @dev Creates a token and mints the whole supply for the Distribution contract.
/// @param _name Token name.
/// @param _symbol Token symbol.
/// @param _distributionAddress The address of the deployed Distribution contract.
/// @param _privateOfferingDistributionAddress The address of the PrivateOffering contract.
/// @param _advisorsRewardDistributionAddress The address of the AdvisorsReward contract.
constructor(
string memory _name,
string memory _symbol,
address _distributionAddress,
address _privateOfferingDistributionAddress,
address _advisorsRewardDistributionAddress
) ERC20Permittable(_name, _symbol, 18) public {
require(
_distributionAddress.isContract() &&
_privateOfferingDistributionAddress.isContract() &&
_advisorsRewardDistributionAddress.isContract(),
"not a contract address"
);
uint256 supply = IDistribution(_distributionAddress).supply();
require(supply > 0, "the supply must be more than 0");
_mint(_distributionAddress, supply);
distributionAddress = _distributionAddress;
privateOfferingDistributionAddress = _privateOfferingDistributionAddress;
advisorsRewardDistributionAddress = _advisorsRewardDistributionAddress;
emit Mint(_distributionAddress, supply);
}
/// @dev Extends transfer method with callback.
/// @param _to The address of the recipient.
/// @param _value The value to transfer.
/// @param _data Custom data.
/// @return Success status.
function transferAndCall(
address _to,
uint256 _value,
bytes calldata _data
) external validRecipient(_to) returns (bool) {
_superTransfer(_to, _value);
emit Transfer(msg.sender, _to, _value, _data);
if (_to.isContract()) {
require(_contractFallback(msg.sender, _to, _value, _data), "contract call failed");
}
return true;
}
/// @dev Extends transfer method with event when the callback failed.
/// @param _to The address of the recipient.
/// @param _value The value to transfer.
/// @return Success status.
function transfer(address _to, uint256 _value) public returns (bool) {
_superTransfer(_to, _value);
_callAfterTransfer(msg.sender, _to, _value);
return true;
}
/// @dev This is a copy of `transfer` function which can only be called by distribution contracts.
/// Made to get rid of `onTokenTransfer` calling to save gas when distributing tokens.
/// @param _to The address of the recipient.
/// @param _value The value to transfer.
/// @return Success status.
function transferDistribution(address _to, uint256 _value) public returns (bool) {
require(
msg.sender == distributionAddress ||
msg.sender == privateOfferingDistributionAddress ||
msg.sender == advisorsRewardDistributionAddress,
"wrong sender"
);
_superTransfer(_to, _value);
return true;
}
/// @dev Extends transferFrom method with event when the callback failed.
/// @param _from The address of the sender.
/// @param _to The address of the recipient.
/// @param _value The value to transfer.
/// @return Success status.
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
_superTransferFrom(_from, _to, _value);
_callAfterTransfer(_from, _to, _value);
return true;
}
/// @dev If someone sent eth/tokens to the contract mistakenly then the owner can send them back.
/// @param _token The token address to transfer.
/// @param _to The address of the recipient.
function claimTokens(address _token, address payable _to) public onlyOwner validRecipient(_to) {
if (_token == address(0)) {
uint256 value = address(this).balance;
if (!_to.send(value)) { // solium-disable-line security/no-send
// We use the `Sacrifice` trick to be sure the coins can be 100% sent to the receiver.
// Otherwise, if the receiver is a contract which has a revert in its fallback function,
// the sending will fail.
(new Sacrifice).value(value)(_to);
}
} else {
ERC20 token = ERC20(_token);
uint256 balance = token.balanceOf(address(this));
token.safeTransfer(_to, balance);
}
}
/// @dev The removed implementation of the ownership renouncing.
function renounceOwnership() public onlyOwner {
revert("not implemented");
}
/// @dev Calls transfer method and reverts if it fails.
/// @param _to The address of the recipient.
/// @param _value The value to transfer.
function _superTransfer(address _to, uint256 _value) internal {
bool success;
if (
msg.sender == distributionAddress ||
msg.sender == privateOfferingDistributionAddress ||
msg.sender == advisorsRewardDistributionAddress
) {
// Allow sending tokens to `address(0)` by
// Distribution, PrivateOffering, or AdvisorsReward contract
// since `super.transfer` doesn't allow doing that.
// This is needed when the `transferDistribution` function
// is called by Distribution, PrivateOffering, AdvisorsReward contract
// to send tokens to `address(0)`.
// See `Distribution.preInitialize`, `MultipleDistribution.burn` functions.
_balances[msg.sender] = _balances[msg.sender].sub(_value);
_balances[_to] = _balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
success = true;
} else {
success = super.transfer(_to, _value);
}
require(success, "transfer failed");
}
/// @dev Calls transferFrom method and reverts if it fails.
/// @param _from The address of the sender.
/// @param _to The address of the recipient.
/// @param _value The value to transfer.
function _superTransferFrom(address _from, address _to, uint256 _value) internal {
bool success = super.transferFrom(_from, _to, _value);
require(success, "transfer failed");
}
/// @dev Used by the `transfer` and `transferFrom` functions.
/// In case the recipient is a contract, tries to call its `onTokenTransfer` function.
/// Reverts if `onTokenTransfer` fails and the recipient is a bridge/distribution contract.
/// Emits an event if `onTokenTransfer` fails and the recipient is not a bridge/distribution contract.
/// Needed for reverting transfer to a bridge when the bridge doesn't accept tokens due to daily limitations,
/// and to revert transfer to a distribution contract (Distribution or MultipleDistribution)
/// if the contract doesn't accept tokens due to its limitations defined in `onTokenTransfer` function.
/// @param _from The address of the sender.
/// @param _to The address of the recipient.
/// @param _value The transferred value.
function _callAfterTransfer(address _from, address _to, uint256 _value) internal {
if (_to.isContract() && !_contractFallback(_from, _to, _value, new bytes(0))) {
require(_to != distributionAddress, "you can't transfer to Distribution contract");
require(_to != privateOfferingDistributionAddress, "you can't transfer to PrivateOffering contract");
require(_to != advisorsRewardDistributionAddress, "you can't transfer to AdvisorsReward contract");
emit ContractFallbackCallFailed(_from, _to, _value);
}
}
/// @dev Makes a callback after the transfer of tokens.
/// @param _from The address of the sender.
/// @param _to The address of the recipient.
/// @param _value The transferred value.
/// @param _data Custom data.
/// @return Success status.
function _contractFallback(
address _from,
address _to,
uint256 _value,
bytes memory _data
) private returns (bool) {
string memory signature = "onTokenTransfer(address,uint256,bytes)";
// solium-disable-next-line security/no-low-level-calls
(bool success, ) = _to.call(abi.encodeWithSignature(signature, _from, _value, _data));
return success;
}
}
ERC20Permittable.sol 151 lines
pragma solidity 0.5.12;
import "./ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
/**
* @title ERC20Permittable
* @dev This is ERC20 contract extended by the `permit` function (see EIP712).
*/
contract ERC20Permittable is ERC20, ERC20Detailed {
string public constant version = "1";
// EIP712 niceties
bytes32 public DOMAIN_SEPARATOR;
// bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)");
bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb;
mapping(address => uint256) public nonces;
mapping(address => mapping(address => uint256)) public expirations;
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) ERC20Detailed(_name, _symbol, _decimals) public {
uint256 chainId = 0;
assembly {
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(_name)),
keccak256(bytes(version)),
chainId,
address(this)
));
}
/// @dev transferFrom in this contract works in a slightly different form than the generic
/// transferFrom function. This contract allows for "unlimited approval".
/// Should the user approve an address for the maximum uint256 value,
/// then that address will have unlimited approval until told otherwise.
/// @param _sender The address of the sender.
/// @param _recipient The address of the recipient.
/// @param _amount The value to transfer.
/// @return Success status.
function transferFrom(address _sender, address _recipient, uint256 _amount) public returns (bool) {
_transfer(_sender, _recipient, _amount);
if (_sender != msg.sender) {
uint256 allowedAmount = allowance(_sender, msg.sender);
if (allowedAmount != uint256(-1)) {
// If allowance is limited, adjust it.
// In this case `transferFrom` works like the generic
_approve(_sender, msg.sender, allowedAmount.sub(_amount));
} else {
// If allowance is unlimited by `permit`, `approve`, or `increaseAllowance`
// function, don't adjust it. But the expiration date must be empty or in the future.
// Note that the expiration timestamp can have a 900-second error:
// https://github.com/ethereum/wiki/blob/c02254611f218f43cbb07517ca8e5d00fd6d6d75/Block-Protocol-2.0.md
require(
// solium-disable-next-line security/no-block-members
expirations[_sender][msg.sender] == 0 || expirations[_sender][msg.sender] >= _now(),
"expiry is in the past"
);
}
} else {
// If `_sender` is `msg.sender`,
// the function works just like `transfer()`
}
return true;
}
/// @dev An alias for `transfer` function.
/// @param _to The address of the recipient.
/// @param _amount The value to transfer.
function push(address _to, uint256 _amount) public {
transferFrom(msg.sender, _to, _amount);
}
/// @dev Makes a request to transfer the specified amount
/// from the specified address to the caller's address.
/// @param _from The address of the holder.
/// @param _amount The value to transfer.
function pull(address _from, uint256 _amount) public {
transferFrom(_from, msg.sender, _amount);
}
/// @dev An alias for `transferFrom` function.
/// @param _from The address of the sender.
/// @param _to The address of the recipient.
/// @param _amount The value to transfer.
function move(address _from, address _to, uint256 _amount) public {
transferFrom(_from, _to, _amount);
}
/// @dev Allows to spend holder's unlimited amount by the specified spender.
/// The function can be called by anyone, but requires having allowance parameters
/// signed by the holder according to EIP712.
/// @param _holder The holder's address.
/// @param _spender The spender's address.
/// @param _nonce The nonce taken from `nonces(_holder)` public getter.
/// @param _expiry The allowance expiration date (unix timestamp in UTC).
/// Can be zero for no expiration. Forced to zero if `_allowed` is `false`.
/// @param _allowed True to enable unlimited allowance for the spender by the holder. False to disable.
/// @param _v A final byte of signature (ECDSA component).
/// @param _r The first 32 bytes of signature (ECDSA component).
/// @param _s The second 32 bytes of signature (ECDSA component).
function permit(
address _holder,
address _spender,
uint256 _nonce,
uint256 _expiry,
bool _allowed,
uint8 _v,
bytes32 _r,
bytes32 _s
) external {
require(_expiry == 0 || _now() <= _expiry, "invalid expiry");
bytes32 digest = keccak256(abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR,
keccak256(abi.encode(
PERMIT_TYPEHASH,
_holder,
_spender,
_nonce,
_expiry,
_allowed
))
));
require(_holder == ecrecover(digest, _v, _r, _s), "invalid signature or parameters");
require(_nonce == nonces[_holder]++, "invalid nonce");
uint256 amount = _allowed ? uint256(-1) : 0;
_approve(_holder, _spender, amount);
expirations[_holder][_spender] = _allowed ? _expiry : 0;
}
function _now() internal view returns(uint256) {
return now;
}
}
Read Contract
DOMAIN_SEPARATOR 0x3644e515 → bytes32
PERMIT_TYPEHASH 0x30adf81f → bytes32
advisorsRewardDistributionAddress 0x6e15d21b → address
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
decimals 0x313ce567 → uint8
distributionAddress 0x37fb7e21 → address
expirations 0xff9e884d → uint256
isOwner 0x8f32d59b → bool
name 0x06fdde03 → string
nonces 0x7ecebe00 → uint256
owner 0x8da5cb5b → address
privateOfferingDistributionAddress 0x7a13685a → address
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
version 0x54fd4d50 → string
Write Contract 14 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 value
returns: bool
claimTokens 0x69ffa08a
address _token
address _to
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
move 0xbb35783b
address _from
address _to
uint256 _amount
permit 0x8fcbaf0c
address _holder
address _spender
uint256 _nonce
uint256 _expiry
bool _allowed
uint8 _v
bytes32 _r
bytes32 _s
pull 0xf2d5d56b
address _from
uint256 _amount
push 0xb753a98c
address _to
uint256 _amount
renounceOwnership 0x715018a6
No parameters
transfer 0xa9059cbb
address _to
uint256 _value
returns: bool
transferAndCall 0x4000aea0
address _to
uint256 _value
bytes _data
returns: bool
transferDistribution 0x238a3fe1
address _to
uint256 _value
returns: bool
transferFrom 0x23b872dd
address _from
address _to
uint256 _value
returns: bool
transferOwnership 0xf2fde38b
address newOwner
Token Balances (1)
View Transfers →Recent Transactions
No transactions found for this address