ERC20

ERC20 is the Ethereum token standard which is used for Ethereum smart contracts. Developed in 2015, ERC-20 defines a common list of rules that an Ethereum token has to implement. Giving developers the ability to program how new tokens will function within the Ethereum ecosystem. This token protocol became popular with crowdfunding companies via Initial Coin Offering (ICO).

Mercury Protocol’s Global Messaging Token is an example of an application based on ERC20 tokens.

The ERC20 token standard describes the functions and events that an Ethereum token contract has to implement.

The ERC20 Token Standard Interface

Following is an interface contract declaring the required functions and events to meet the ERC20 standard:

Most of the major tokens on the Ethereum blockchain are ERC-20-compliant. The GNT Golem Network Token is only partially-ERC20 blockchain-compliant as it does not implement the , and functions, and the event.

Some of the tokens include further information describing the token contract:


How Does ERC-20 Token Contract Work?

Following is a fragment of a token contract to demonstrate how a token contract maintains the token balance of Ethereum accounts:

Blockchain Token Balance

For an example, assume that this token contract has two token holders:

  • with a balance of 100 units
  • with a balance of 200 units

The token contract’s data structure will contain the following information:

The function will return the following values:

Transfer Token Balance

If wants to transfer 10 tokens to , will execute the function:

The token contract’s function will alter the data structure to contain the following information:

The function will now return the following values:

Approve And TransferFrom Token Balance

ERC20 Source code If wants to authorise to transfer some tokens to , will execute the function:

The data structure will now contain the following information:

If wants to later transfer some tokens from to itself, executes the function:

The data structure will be altered to contain the following information:

And the data structure will now contain the following information:

can still spend 10 tokens from .

The function will now return the following values:


Sample Fixed Supply Token Contract

Following is a sample Fixed Supply Token contract with a fixed supply of 1,000,000 units that are initially assigned to the owner of the contract. This token has 18 decimal places: ERC20 Code:

See How to issue your own token on Ethereum in less than 20 minutes for steps to deploy a token contract.

Further Information On ERC20 network and platform for tokens

See also

Source

http://wikipedia.org/