Blockchain Developer | BSc Computer Science

Month: July 2021

ERC20: The Ethereum Token Standard

What is a token in the Ethereum Ecosystem?

In Ethereum, tokens are simply digital assets that are being built on top of the network. They benefit from Ethereum’s existing infrastructure instead of developers having to build an entirely new blockchain. They are usually digital abstractions of fungible coins, that can be used for exchanging and payments. There are a lot of types of tokens, from stable coins like USDT and USDC, covering NFTs and coins with volatility.

The ERC20 standard

Check this post if you don’t understand what are ERCs and EIPs in the Ethereum Ecosystem.

ERC-20 is one of the most widely-used standards for smart contracts on the Ethereum platform. The fact that nearly all Ethereum tokens are issued to the same standard brings vast benefits for users of the Ethereum ecosystem. It means that ERC-20 tokens are interoperable with one another and with any ERC-20 supported contract, exchange, marketplace, or wallet.

If you have previous experience with Object-Oriented Programming, you can think of ERC20 as an interface. The standard is just a collection of methods that a token contract in Solidity should implement.

What are the Methods of the ERC-20 Token Standard Interface?

The ERC-20 token standard is relatively straightforward, comprising nine rules for issuing tokens. Six of them are mandatory and must be applied in all instances. Three are optional, although at least two of these are generally used.

Optional Rules

The three optional rules are:

  • name: Despite being optional, this is almost always used as token owners want users to be able to identify their tokens.
  • symbol: Again, almost always used as exchanges list token pairs using tickers.
  • decimal: Each ERC-20 token can be denominated in fractional units of up to one-eighteenth.

Mandatory Rules

Mandatory rules are categorized as either functions or events. The first two functions don’t modify the state of the contract. They define some core features of the token, and if queried, will return already-defined information.

  • totalSupply: the total number of the tokens issued.
  • balanceOf: answers a query regarding how many tokens any given address is holding.

The rest of the functionalities modifies the contract state except the allowance method.

  • transfer: allow a holder account to transfer its balance to another account.
  • approve: approves the movement of tokens in a transferFrom by a third party.
  • allowance: the amount of tokens approved to be transfered by a third party.
  • transferFrom: once approved, this function instructs the contract to move a defined value of tokens from a sender address to a recipient address (checking the allowance).

Summarizing

ERC-20 is one of the most widely-used standards for smart contracts on the Ethereum platform. All ERC-20 tokens are issued to the same standard. This ability to integrate has acted as a positive reinforcement cycle for Ethereum, with the existing ecosystem pulling in more developers and users who want to join in.

Ethereum Ecosystem: EIPs and ERCs concepts explained

What is an EIP?

EIP stands for Ethereum Improvement Proposal. These are design documents informing the Ethereum community, particularly its core developers, about new features proposals on Ethereum or changes to the ecosystem’s structure, processes, or environment.

EIPs are designed to provide both precise technical specifications of a new feature and rationale for adopting it. They’re a little like technical white papers. The person who brings up an EIP is responsible for persuading and convincing others in the community and building consensus around the new proposal.

EIP structure

Most successful EIPs are laid out like this:

  • Preamble
  • Simple Summary
  • Abstract
  • Motivation
  • Specification
  • Rationale
  • Backwards Compatibility
  • Test Cases
  • Implementations
  • Copyright Waiver

What is an ERC?

ERC stands for Ethereum Request for Comment, and “Request for Comment” is a similar concept to that devised by the Internet Engineering Task Force as a means of conveying essential technical notes and requirements to a group of developers and users.

In practice, it is just a subtype of Standards Track EIP, which stands for application-level standards and conventions, including contract standards such as token standards (ERC-20), name registries (ERC-137), URI schemes, library/package formats, and wallet formats.

To dive deeper into the types of EIPs and how to commit one, go to the official definition page in EIP-1.

Powered by WordPress & Theme by Anders Norén