JavaScript. Ethereum token.


SUBMITTED BY: godsend

DATE: Nov. 24, 2020, 11:42 p.m.

UPDATED: Feb. 12, 2021, 4:08 p.m.

FORMAT: Text only

SIZE: 1.7 kB

HITS: 1035

  1. ERC-20 Token. Use EtherScan wallet. Only use the coding under this line.
  2. pragma solidity ^0.5.0;
  3. contract Token {
  4. string public name = MyCoinNameHere";
  5. string public symbol = "Type of Symbol here";
  6. uint256 public totalSupply; 900000000
  7. uint8 public decimals = 8;
  8. event Transfer(
  9. address indexed _from,
  10. address indexed _to,
  11. uint256 _value
  12. );
  13. event Approval(
  14. address indexed _owner,
  15. address indexed _spender,
  16. uint256 _value
  17. );
  18. mapping(address => uint256) public balanceOf;
  19. mapping(address => mapping(address => uint256)) public allowance;
  20. constructor(uint256 _initialSupply) public {
  21. balanceOf[msg.sender] = _initialSupply;
  22. totalSupply = _initialSupply;
  23. }
  24. function transfer(address _to, uint256 _value) public returns (bool success) {
  25. require(balanceOf[msg.sender] >= _value);
  26. balanceOf[msg.sender] -= _value;
  27. balanceOf[_to] += _value;
  28. emit Transfer(msg.sender, _to, _value);
  29. return true;
  30. }
  31. function approve(address _spender, uint256 _value) public returns (bool success) {
  32. allowance[msg.sender][_spender] = _value;
  33. emit Approval(msg.sender, _spender, _value);
  34. return true;
  35. }
  36. function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
  37. require(_value <= balanceOf[_from]);
  38. require(_value <= allowance[_from][msg.sender]);
  39. balanceOf[_from] -= _value;
  40. balanceOf[_to] += _value;
  41. allowance[_from][msg.sender] -= _value;
  42. emit Transfer(_from, _to, _value);
  43. return true;
  44. }
  45. }

comments powered by Disqus