ERC20 tokens

Ethereum is a generic blockchain. It allows developers to build a DApp and trade digital assets.  Correspondingly, it allows a developer to define a user-specific coin called a token. The majority of these tokens are ERC20 tokens. ERC refers to Ethereum Request for Comment, and 20 is the number that was assigned to this request. In other words, ERC-20 is a technical standard used for smart contracts on the Ethereum blockchain for implementing tokens. According to Etherscan.io, as of October 8, 2018, a total of 125,330 ERC-20 compatible tokens were found on the Ethereum main network.

ERC-20 defines a list of rules for Ethereum tokens to follow. By doing so, it allows for interaction and conversion between Ethereum tokens within the larger Ethereum ecosystem. Currently, Ether does not conform to the ERC-20 standard. However, since Ether is the native coin of Ethereum, it can be converted into other tokens. The ERC-20 specification defines an interface containing methods and events.

The following is list of required methods (github.com):

  • name: It returns the name of the token, for instance, HelloToken: function name() view returns (string name).
  • symbol: It returns the symbol of the token, for instance, HTC: function symbol() view returns (string symbol).
  • decimals: It returns the number of decimals the token uses; for instance, 8 means to divide the token amount by 100,000,000 to get its user representation: function decimals() view returns (uint8 decimals).
  • totalSupply: It returns the total token supply: function totalSupply() view returns (uint256 totalSupply).
  • balanceOf: It returns the account balance of another account with address _owner: function balanceOf (address _owner) view returns (uint256 balance).
  • transfer: It transfers a specified number (_value) of tokens to the _to address, and MUST fire the transfer event. The function should throw an error if the _from account balance does not have enough tokens to spend: function transfer(address _to, uint256 _value) returns (bool success).
  • transferFrom: It transfers a specified amount (_value) of tokens from the _from address to the _to address, and MUST fire the Transfer event. The function should throw an error unless the _from account has deliberately authorized the sender of the message via some mechanism: function transferFrom (address _from, address _to, uint256 _value) returns (bool success).
  • approve: It allows _spender to withdraw from your account multiple times, up to  the _value amount. If this function is called again, it overwrites the current allowance with _value: function approve (address _spender, uint256 _value) returns (bool success).
  • allowance: It returns the amount that _spender is still allowed to withdraw from _owner: function allowance (address _owner, address _spender) view returns (uint256 remaining).

The list of required events is as follows:

  • transfer: Must trigger when tokens are transferred, including zero value transfers. A token contract that creates new tokens SHOULD trigger a Transfer event with the _from address set to 0x0 when tokens are created: event Transfer (address indexed _from, address indexed _to, uint256 _value).
  • approval: Must trigger on any successful call to approve (address _spender, uint256 _value):  event Approval (address indexed _owner, address indexed _spender, uint256 _value).

Although Ethereum allows for a person to create his or her own money, Ethereum's true value is its guaranteed execution of a smart contract. Ether and ERC20 token creation are mainly for initial crowdfunding purposes to support a project and are used for payment during the transaction to circumvent a bank. Without a real business use case, a token is worth nothing.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset