The Innards of an ERC20 Token20th April 2019
What does this mean?
You’ve all heard by now that SunContract’s SNC token is an ERC20 token… But do you know what it means to be of ERC20 standard? If not, stick around for a simple explanation on the ERC20 standard.
ERC20 tokens are designed and used solely on the Ethereum platform. The Ethereum platform consists of a blockchain that is capable of storing transactions, and a virtual machine that is capable of running smart contracts.
Because of these two functions of the Ethereum network, the platform can support the running of decentralised applications (DApps). In return Ethereum charges developers for the computing power in their network — which is paid in Ethers — the main currency on the Ethereum network. Besides Ether, the platform can also support other tokens, including SunContract’s ERC20 SNC token.
So why did we decide to go the ERC20 route? Before we can answer that, there’s something you need to understand:
How exactly do tokens come into existence?
A token can be created by a smart contract. Smart contracts are also responsible for facilitating the transactions of the tokens, as well as recording the balance of each token holder. Smart contracts are written in the programming language “Solidity” on the basis of If-This-Then-That (IFTTT) logic. It is important to note that once a smart contract is deployed, it cannot be changed anymore.
What is the role of ERC 20 Tokens?
Once tokens are created, they can be traded, spent, or gifted to someone else. This typically happens on exchanges.
To get your a token listed on an exchange, the exchange has to write custom code so that they can talk to the given contract and allow people to trade the respective tokens. The same thing goes for wallet providers.
Supporting hundreds of tokens can therefore be a very complex and time-consuming process for exchanges and wallet providers. Luckily for them, and for all of crypto, the blockchain community proposed the standard called ERC20.
ERC20 — A Guideline for Token Creation
ERC20 is a guideline or standard for when developers want to create a token. ERC stands for Ethereum Request for Comments and 20 is the number assigned to the ERC structure. ERC20 Standard defines 6 mandatory functions that a smart contract must implement, and 3 optional ones.
Name — Assign your token a name eg. SunContract
Symbol — e.g SNC
Decimals — e.g 8
The mandatory functions are a bit more complex.
First, you have to create a method that defines the total supply of your token. When this limit is reached, the smart contract will refuse to create new tokens.
Balance Of Method
Which has to return how many tokens a given address has.
Takes a certain number of tokens from the total supply and gives them to a user
Which can be used to transfer tokens between any two users who have them.
Is to allow a specific account to transfer some of my tokens to another account through TransferFrom.
Is to check how much was approved.
If a developer wants the token to be an ERC20 token, they have to implement the ERC20 interface and that forces them to implement these 6 methods listed above.
What are the benefits of ERC20 tokens?
Basically, ERC20 standard makes everything simpler.
ERC-20 is the universal language that all tokens on the Ethereum network use. It allows one token to be traded with another. Before the existence of ERC20 Tokens, everyone who wanted to create a token had to reinvent the wheel. And that meant that exchanges and wallets had to write different custom codes to support the token. With ERC20 however, exchanges and wallet providers only have to implement this code once and that is why exchanges can add new tokens so quickly. ERC-20 also makes the creation of new tokens very easy, and that is why Ethereum rose to become one of the most popular platforms in the world.
The SunContract team is always looking for ways to work efficiently and smartly. Working with ERC20 standard meant that it would be much easier to create the tokens and begin implementing the project on the blockchain. Moreover, it would reduce the workload for exchanges and wallet providers, making it that much easier (and quicker) for us to get listed should an application for listing be approved.
ERC20 is a great standard that has propelled the use of tokens, and while it is not perfect, it has contributed significantly to the disruption of inefficient business models, and in so doing paved the way for newer technologies and more efficient systems.
The Innards of an ERC20 Token was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.