JavaScript. Ethereum token Etherscan contract, edit to your own specifications.


SUBMITTED BY: godsend

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

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

FORMAT: Text only

SIZE: 6.1 kB

HITS: 1012

  1. Tips or donations can be made at 18e1561MhqrJwmb4tXuCU3V9cGtb3yJCSx For further tips or hacks or tutorials on winning big money
  2. Contact Telegram @Passionateforcoin
  3. No charge, I accept only donations.
  4. ----------------------------------------------------------------------------------------------------------------------
  5. contract Token {
  6. /// @return total amount of tokens
  7. function totalSupply() constant returns (uint256 supply) {}
  8. /// @param _owner The address from which the balance will be retrieved
  9. /// @return The balance
  10. function balanceOf(address _owner) constant returns (uint256 balance) {}
  11. /// @notice send `_value` token to `_to` from `msg.sender`
  12. /// @param _to The address of the recipient
  13. /// @param _value The amount of token to be transferred
  14. /// @return Whether the transfer was successful or not
  15. function transfer(address _to, uint256 _value) returns (bool success) {}
  16. /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
  17. /// @param _from The address of the sender
  18. /// @param _to The address of the recipient
  19. /// @param _value The amount of token to be transferred
  20. /// @return Whether the transfer was successful or not
  21. function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
  22. /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
  23. /// @param _spender The address of the account able to transfer the tokens
  24. /// @param _value The amount of wei to be approved for transfer
  25. /// @return Whether the approval was successful or not
  26. function approve(address _spender, uint256 _value) returns (bool success) {}
  27. /// @param _owner The address of the account owning tokens
  28. /// @param _spender The address of the account able to transfer the tokens
  29. /// @return Amount of remaining tokens allowed to spent
  30. function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
  31. event Transfer(address indexed _from, address indexed _to, uint256 _value);
  32. event Approval(address indexed _owner, address indexed _spender, uint256 _value);
  33. }
  34. contract StandardToken is Token {
  35. function transfer(address _to, uint256 _value) returns (bool success) {
  36. //Default assumes totalSupply can't be over max (2^256 - 1).
  37. //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
  38. //Replace the if with this one instead.
  39. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
  40. if (balances[msg.sender] >= _value && _value > 0) {
  41. balances[msg.sender] -= _value;
  42. balances[_to] += _value;
  43. Transfer(msg.sender, _to, _value);
  44. return true;
  45. } else { return false; }
  46. }
  47. function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
  48. //same as above. Replace this line with the following if you want to protect against wrapping uints.
  49. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
  50. if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
  51. balances[_to] += _value;
  52. balances[_from] -= _value;
  53. allowed[_from][msg.sender] -= _value;
  54. Transfer(_from, _to, _value);
  55. return true;
  56. } else { return false; }
  57. }
  58. function balanceOf(address _owner) constant returns (uint256 balance) {
  59. return balances[_owner];
  60. }
  61. function approve(address _spender, uint256 _value) returns (bool success) {
  62. allowed[msg.sender][_spender] = _value;
  63. Approval(msg.sender, _spender, _value);
  64. return true;
  65. }
  66. function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
  67. return allowed[_owner][_spender];
  68. }
  69. mapping (address => uint256) balances;
  70. mapping (address => mapping (address => uint256)) allowed;
  71. uint256 public totalSupply;
  72. }
  73. //name this contract whatever you'd like
  74. contract ETQuality is StandardToken {
  75. function () {
  76. //if ether is sent to this address, send it back.
  77. throw;
  78. }
  79. /* Public variables of the token */
  80. /*
  81. NOTE:
  82. The following variables are OPTIONAL vanities. One does not have to include them.
  83. They allow one to customise the token contract & in no way influences the core functionality.
  84. Some wallets/interfaces might not even bother to look at this information.
  85. */
  86. string public name; //fancy name: EG James Bond
  87. uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
  88. string public symbol; //An identifier: eg SBX
  89. string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme.
  90. //
  91. // CHANGE THESE VALUES FOR YOUR TOKEN
  92. //
  93. //make sure this function name matches the contract name above. So if your token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token
  94. function ETQuality(
  95. ) {
  96. balances[msg.sender] = 1000000000000000000000000000; // Give the creator all initial tokens (100000 for example)
  97. totalSupply = 1000000000000000000000000000; // Update total supply (100000 for example)
  98. name = "Ether Quality"; // Set the name for display purposes
  99. decimals = 18; // Amount of decimals for display purposes
  100. symbol = "ETQ"; // Set the symbol for display purposes
  101. }
  102. /* Approves and then calls the receiving contract */
  103. function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
  104. allowed[msg.sender][_spender] = _value;
  105. Approval(msg.sender, _spender, _value);
  106. //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
  107. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
  108. //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
  109. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
  110. return true;
  111. }
  112. }

comments powered by Disqus