Guest User

Erosion.sol

a guest
Jul 5th, 2019
386
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. pragma solidity ^0.5.0;
  4.  
  5. interface IERC20 {
  6. function totalSupply() external view returns (uint256);
  7. function balanceOf(address who) external view returns (uint256);
  8. function allowance(address owner, address spender) external view returns (uint256);
  9. function transfer(address to, uint256 value) external returns (bool);
  10. function approve(address spender, uint256 value) external returns (bool);
  11. function transferFrom(address from, address to, uint256 value) external returns (bool);
  12.  
  13. event Transfer(address indexed from, address indexed to, uint256 value);
  14. event Approval(address indexed owner, address indexed spender, uint256 value);
  15. }
  16.  
  17. library SafeMath {
  18. function mul(uint256 a, uint256 b) internal pure returns (uint256) {
  19. if (a == 0) {
  20. return 0;
  21. }
  22. uint256 c = a * b;
  23. assert(c / a == b);
  24. return c;
  25. }
  26.  
  27. function div(uint256 a, uint256 b) internal pure returns (uint256) {
  28. uint256 c = a / b;
  29. return c;
  30. }
  31.  
  32. function sub(uint256 a, uint256 b) internal pure returns (uint256) {
  33. assert(b <= a);
  34. return a - b;
  35. }
  36.  
  37. function add(uint256 a, uint256 b) internal pure returns (uint256) {
  38. uint256 c = a + b;
  39. assert(c >= a);
  40. return c;
  41. }
  42.  
  43. function ceil(uint256 a, uint256 m) internal pure returns (uint256) {
  44. uint256 c = add(a,m);
  45. uint256 d = sub(c,1);
  46. return mul(div(d,m),m);
  47. }
  48. }
  49.  
  50. contract ERC20Detailed is IERC20 {
  51.  
  52. uint8 private _decimals;
  53. string private _name;
  54. string private _symbol;
  55.  
  56. constructor(string memory name, string memory symbol, uint8 decimals) public {
  57.  
  58. _decimals = decimals;
  59. _name = name;
  60. _symbol = symbol;
  61.  
  62. }
  63.  
  64. function name() public view returns(string memory) {
  65. return _name;
  66. }
  67.  
  68. function symbol() public view returns(string memory) {
  69. return _symbol;
  70. }
  71.  
  72. function decimals() public view returns(uint8) {
  73. return _decimals;
  74. }
  75. }
  76.  
  77. /**end here**/
  78.  
  79. contract Erosion is ERC20Detailed {
  80.  
  81. using SafeMath for uint256;
  82. mapping (address => uint256) private _balances;
  83. mapping (address => mapping (address => uint256)) private _allowed;
  84. string constant tokenName = "Erosion";
  85. string constant tokenSymbol = "EROS";
  86. uint8 constant tokenDecimals = 18;
  87. uint256 _totalSupply = 10000000000000000000000000;
  88. address constant drain = 0x3f17f1962B36e491b30A40b2405849e597Ba5FB5;
  89.  
  90.  
  91.  
  92.  
  93. constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) {
  94. _mint(msg.sender, _totalSupply);
  95. }
  96.  
  97. function totalSupply() public view returns (uint256) {
  98. return _totalSupply;
  99. }
  100.  
  101. function balanceOf(address owner) public view returns (uint256) {
  102. return _balances[owner];
  103. }
  104.  
  105. function allowance(address owner, address spender) public view returns (uint256) {
  106. return _allowed[owner][spender];
  107. }
  108.  
  109. function transfer(address to, uint256 value) public returns (bool) {
  110. require(value <= _balances[msg.sender]);
  111. require(to != address(0));
  112.  
  113. uint256 erosion;
  114.  
  115. if(value <= 10000){
  116. erosion = 0;
  117. } else {
  118. erosion = value.div(10000);
  119. _balances[drain] = _balances[drain].add(erosion);
  120. }
  121.  
  122. uint256 tokensToTransfer = value.sub(erosion);
  123.  
  124. _balances[msg.sender] = _balances[msg.sender].sub(value);
  125. _balances[to] = _balances[to].add(tokensToTransfer);
  126.  
  127. _totalSupply = _totalSupply.sub(erosion);
  128.  
  129. emit Transfer(msg.sender, to, tokensToTransfer);
  130. emit Transfer(msg.sender, drain, erosion);
  131. return true;
  132. }
  133.  
  134. function multiTransfer(address[] memory receivers, uint256[] memory amounts) public {
  135. for (uint256 i = 0; i < receivers.length; i++) {
  136. transfer(receivers[i], amounts[i]);
  137. }
  138. }
  139.  
  140. function approve(address spender, uint256 value) public returns (bool) {
  141. require(spender != address(0));
  142. _allowed[msg.sender][spender] = value;
  143. emit Approval(msg.sender, spender, value);
  144. return true;
  145. }
  146.  
  147. function transferFrom(address from, address to, uint256 value) public returns (bool) {
  148. require(value <= _balances[from]);
  149. require(value <= _allowed[from][msg.sender]);
  150. require(to != address(0));
  151.  
  152. _balances[from] = _balances[from].sub(value);
  153.  
  154. uint256 erosion;
  155.  
  156. if(value <= 10000){
  157. erosion = 0;
  158. } else {
  159. erosion = value.div(10000);
  160. _balances[drain] = _balances[drain].add(erosion);
  161. }
  162.  
  163. uint256 tokensToTransfer = value.sub(erosion);
  164.  
  165. _balances[to] = _balances[to].add(tokensToTransfer);
  166. _totalSupply = _totalSupply.sub(erosion);
  167.  
  168. _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
  169.  
  170. emit Transfer(from, to, tokensToTransfer);
  171. emit Transfer(from, drain, erosion);
  172.  
  173. return true;
  174. }
  175.  
  176. function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
  177. require(spender != address(0));
  178. _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
  179. emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
  180. return true;
  181. }
  182.  
  183. function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
  184. require(spender != address(0));
  185. _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
  186. emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
  187. return true;
  188. }
  189.  
  190. function _mint(address account, uint256 amount) internal {
  191. require(amount != 0);
  192. _balances[account] = _balances[account].add(amount);
  193.  
  194. emit Transfer(address(0), account, amount);
  195. }
  196.  
  197. function burn(uint256 amount) external {
  198. _burn(msg.sender, amount);
  199. }
  200.  
  201. function _burn(address account, uint256 amount) internal {
  202. require(amount != 0);
  203. require(amount <= _balances[account]);
  204. _totalSupply = _totalSupply.sub(amount);
  205. _balances[account] = _balances[account].sub(amount);
  206. emit Transfer(account, address(0), amount);
  207. }
  208.  
  209. function burnFrom(address account, uint256 amount) external {
  210. require(amount <= _allowed[account][msg.sender]);
  211. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount);
  212. _burn(account, amount);
  213. }
  214. }
RAW Paste Data