What is an ERC-20 token standard?

To understand what the ERC-20 token standard is, you first need to understand what the state of token creation was like before this standard was introduced. 

So, how do you create a token? Well, first you need to set up a smart contract. This contract is responsible for creating tokens, managing its transactions and keeping track of the balance of each token holder. 

If you want to get your hands on some of these tokens as a user you would then send a certain amount of cryptocurrency e.g. Ether, to the smart contract, which would then issue an equivalent amount to you. So far, so good. 

However, as there were no universal rules or guidelines in place and thousands of users creating multiple smart contracts, each with their own tokens and differences in how they set them up, exchanges and digital wallets had difficulty in ensuring each contract could interact with the other to allow for trading, buying or selling of tokens.

Before the standard was introduced, exchanges would have to create a unique line of code (set of instructions) to ensure each contract would be compatible with the exchange and other contracts and tokens. As you can imagine, this was very time-consuming and not very efficient.

To solve this problem, the Ethereum community came up with a set of rules and guidelines that dictate the fundamental functions each smart contract that creates tokens must have called the ERC-20 token standard. 

These guidelines are broken up into six mandatory functions and three optional ones – name, symbol and how far your token can be broken down similar to Bitcoin and its smallest unit of currency: a Satoshi.

So, if you want to create a token that supports the ERC-20 standard, your contract must be able to:

Define the total supply

Define the total supply of your token. When this number is reached, the smart contract will refuse to create any new tokens.

Keep track of the balance 

Keep track of the number of tokens any given address has.

Transfer 

Move a certain number of tokens from the total supply to the user.

Transfer from

Transfer tokens between any two people who have them.

Approve 

Verify contracts to ensure they can issue a certain number of tokens to a user, taking into account the total supply.

Check the allowance 

Similar to the above, the contract must check to see if one user’s balance is high enough to send tokens to someone else.

You can now see how exchanges and digital wallets can continue to add so many compatible tokens so quickly, as each is now created using this same standard.

Did you find this useful?

68
9