15

I'm looking for a clear way to describe "the ERC20 token standard" to regular folks like me who are not developers, and can't seem to find a plain language articulation of the core components of that standard. Being a non-developer, the github thread where the ERC20 standard was developed is totally Chinese to me. Here is what I do understand and say about ERC20 at the moment (please edit if that is off):

The ERC20 token standard is a set of criteria developed by the Ethereum community for how to set up smart contracts on the blockchain in order to ensure optimal interoperability. ERC stands for Ethereum Request for Comments and this particular request was to help improve the standards to which developers should strive to adhere in developing smart tokens.

Below were my best sources for understanding ERC20 but none of them answer the question I asked above: What are the actual criteria?

  1. themerkle.com/what-is-the-erc20-ethereum-token-standard/
  2. www.ethnews.com/erc20-the-ethereum-token-standard
  3. steemit.com/cryptocurrency/@cryptoadvocator/all-about-ethereum-erc20-token-standard
13

At a high level, the main parts of ERC20 specify:

1. how tokens can be transferred by its owner

2. how tokens can be transferred on behalf of an owner

3. how to get data about the token

4. events about the token

The first specifies the obvious requirement that tokens must be transferrable, and what ERC20 defines is that you would tell the token contract to transfer some number of your tokens to someone else. You would not tell a token contract to "send" or "give" tokens to someone else: the term ERC20 chose is transfer.

The second part allows you to approve someone to take some number of your tokens and transferFrom you to someone else. It's less obvious why that's needed but it helps in some workflows. For example, one goal of Ethereum and smart contracts is "veridical computing" and a way for this to happen is for someone to publish their contract which says: "if you approve me to use some of your tokens, I will give you X". X could be another token or "smart property". Now you can read that contract, approve the contract and execute the contract. As part of the contract execution, it will transferFrom your tokens and deliver you X. If the contract did not have those terms, you had full control to not approve and execute it in the first place.

This is different from giving the contract your tokens first, and then asking it to deliver X. You don't give someone something and then ask them to sign a promise to deliver you X, because they might take your tokens and ignore your request for X. (There's ways that the contract can be made to keep its promise, but the workflow could be more complicated.) You can see that the type of contract by me "If you give me T, I will give you X" is simpler than you writing a contract for "I will give you T, but you must then give me X": the former is a promise by me and your choice to accept or not; the latter is written by you and I need to accept first before you do anything.

If you approve someone, you or they can find out for how many tokens, by checking their allowance.

The other parts of ERC20 allows anyone to get data like the name, symbol, totalSupply of tokens, as well as the balanceOf an account.

Finally, ERC20 specifies the format and meaning of certain events, for example a Transfer must indicate firstly the sender, secondly the recipient, and thirdly the number of tokens. User interfaces can then take comfort that what they display to users will make sense for tokens that comply with ERC20.

The finalized ERC20 is at https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md

  • I'm just curious why you did not link to the actual standard? Is there an "official" document standard at this point? This is an excellent answer. Very informative. But it seems to me it should have a link. – Thomas Jay Rush May 28 '17 at 12:01
  • That was really helpful, eth. I was able to go back to the github thread and finally understand that the list of functions listed under "specification" are what make up the ERC20 standard. Like Thomas, I wonder if there is a final official document. I also wonder whether the list on that github thread (which is now closed) is final or whether the standard is still evolving. Github thread link (for those who want to go see it): github.com/ethereum/EIPs/issues/20 – Tesa May 28 '17 at 17:58
  • @ThomasJayRush - the only two links I have found are the github one I included in my comment above + an Ethereum Wiki link I just found today theethereum.wiki/w/index.php/ERC20_Token_Standard I don't know if any of these links count as "official" for the Ethereum community. I would personally love to know if the ERC20 token standard is still being refined, and if so... where is that conversation happening? – Tesa May 29 '17 at 9:47
  • Updated the answer to include the link to ERC20. Thanks – eth Jan 11 '18 at 21:35
3

Here is my attempt at a definition of the ERC20 Token Standard and overview of its 8 components, based on Eth's response to my original question above + the ERC20 Github thread: https://github.com/ethereum/EIPs/issues/20

What is the ERC20 Token Standard?

The ERC20 Token Standard is a set of 6 functions and 2 events that need to be included (in a specific agreed upon language and format) in a smart token contract in order to enable interoperability across multiple interfaces and distributed applications (dapps). The 6 functions relate to (1) how tokens can be transferred (either by its owner or on behalf of its owner) and (2) how to access data about the token (name, symbol, total supply, and account balance). The 2 events are transfers and approvals, and how they need to be formatted.

Specific functions and events making up the ERC20's Token Standard:

I got these from the Github thread which is now closed. Please edit if they have changed / are still evolving. Note that the ERC20 standard is based on very specific words for each function. So, for instance “TotalSupply” is the command to be used to get the total token supply, rather than “get the total coin supply” or some other wording. Subscribing to the ERC20 token standard means following the agreed upon language for each function.*

Method-related functions:

The specific wording of the function is followed by a clarification of what it does, in [brackets]

  1. TotalSupply [Get the total token supply]

  2. BalanceOf (address _owner) constant returns (uint256 balance) [Get the account balance of another account with address _owner]

  3. transfer(address _to, uint256 _value) returns (bool success) [Send _value amount of tokens to address _to]

  4. transferFrom(address _from, address _to, uint256 _value) returns (bool success) [Send _value amount of tokens from address _from to address _to]

  5. approve(address _spender, uint256 _value) returns (bool success) [Allow _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]

  6. allowance (address *_owner*, address *_spender*) constant returns (uint256 remaining) [Returns the amount which _spender is still allowed to withdraw from _owner]

Events format:

  1. Transfer(address indexed _from, address indexed _to, uint256 _value). [Triggered when tokens are transferred.]

  2. Approval(address indexed _owner, address indexed _spender, uint256 _value) [Triggered whenever approve(address _spender, uint256 _value) is called.]

Note:

Please refer back to Eth’s response above for very helpful clarifications of these functions and events.

Later edit: Just found a list of core components of the ERC20 on the Ethereum Wiki: https://theethereum.wiki/w/index.php/ERC20_Token_Standard

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.