ERC20 Token Interface – How To Create Your Own ERC20 Cryptocurrency Token in 2021

Table of Contents
token interface
Table of Contents

Welcome to lesson 8!

You keep hearing ERC20, but don’t know what it is? Don’t get left out! In this video, we will introduce the ERC20 standard token to you! We will also show you the ERC Token Standard Interface and the functions and events that have to be implemented in order for the ERC20 token to become compliant. Sounds like something that you would like to do? Then you came to the right place! Watch our video to find out more, or read the article, which is a transcription of the video embedded below.

Welcome to lesson 8! In this lesson, we will have a look at the ERC20 token standard. The ERC20 token standard simply describes the functions and events that an Ethereum token contract has to implement. So if you are familiar with Java, for example, and know what an interface is, the ERC20 token standard is essentially just that—an interface that you have to implement so that the token you create becomes an ERC20-compliant token.

In other words, you have to implement all the functions that are described in the ERC token standard interface and make them visible to the public. This is what your token users will interact with, and that is what essentially makes a token.

The reason this standard exists is so that every token that implements this standard follows the same naming convention. By doing so, it makes it easy for developers to interact with different coins. It also makes it easier for wallets to handle different coins, as they know that once a token is ERC20 compliant, it will follow a certain convention and thus behave in predictable ways.

Now let’s have a look at the ERC20 Token Standard Interface and the functions and events that need to be implemented so that a token becomes ERC20 compliant.

Token Supply

The first function that needs to be implemented is the token supply, which simply returns the total token supply in circulation. Then we have the balanceOf() function, which accepts an address of an owner of a certain wallet and returns the balance of that owner.

Transfer Function

Then we have a transfer function, which accepts an address and a value and returns whether the transfer to that address of a certain value was successful or not.

TransferFrom Function

Next, we have a transferFrom function where we transfer funds from a given address to another address of a given value, and then we also return whether the transaction was successful or not.

Approve Function

Then we have another interesting function, approve, which allows a spender (the first parameter here) to withdraw from an account multiple times up to the value amount that was passed as the second parameter. If this function is called again, it overwrites the current allowance with a new value, and then we return whether the transaction should be approved or not by returning the success Boolean.

Allowance

The final function to implement is allowance, which returns the amount that the spender is still allowed to withdraw from the owner. Then we have two events that we need to implement. The first one is triggered when tokens are transferred, and the parameters we have are the ‘address’, which calls to this transfer, and ‘to’ is the address to which the tokens are transferred to, and the ‘value’ is the amount that was sent.

Approval

The final event is approval, which is triggered whenever approve is called and it accepts three parameters: the owner (the address which was approved), the spender (which has been allowed to spend that money), and the value (which has been approved to be spent).

So this is it. As you can see, it’s not a really big, long interface, and not many functions and events that need to be implemented. In the next lesson, we will do just that: implement all these functions and events to create our own ERC20-compliant token.

See you there!