Header Ads

Header ADS

What is ERC20 tokens in blockchain?

What are ERC-20 tokens? 

We all hear about ERC 20 tokens, but what are those tokens? And most importantly, what are they not? To start with, let's quickly go over some of the basics. ERC 20 tokens exist on the Ethereum platform, which consists of a blockchain capable of storing transactions and a virtual machine capable of running smart contracts.

It's important to understand that tokens live on the Ethereum blockchain. They benefit from its technology, they aren't independent, and they rely on Ethereum's blockchain and platform. The native currency on the Ethereum network is ether, but besides ether, it can also support other tokens. And these can work like currencies, but they can also represent shares of a company, loyalty points, gold certificates, and so on. But we're running ahead of it. Let's first take a look at how tokens come into existence.

History of the Tokenism

The token can be created by a smart contract. This contract is not only responsible for creating tickets, but also for managing transactions of the token and for keeping track of the balance of each token holder. To get some tokens, you have to send some ether to the smart contract, which will then give you a certain amount of tickets in return. So when you want to create your own token, you write a smart contract that can create tokens, transfer them and keep track of people's balances. That sounds pretty easy, but it's also quite risky. For starters, once the smart contract is deployed, it cannot be changed anymore. So if you made an error, you cannot fix it, and that could be quite catastrophic. Imagine a bug inside your contracts code that causes people to lose their tokens or a bug that would allow others to steal tokens and then there is a problem of interoperability. Each token contract can be completely different from the other. So if you want your token to be available on an exchange, the exchange has to write custom code so they can talk to your contract and allow people to trade. The same thing goes for wallet providers. Supporting hundreds of tokens would be very complex and very time-consuming. So instead the community proposed the standard called ERC 20. ERC stands for Ethereum requests for comments and twenty is just the number they assigned to a proposal that would create some structure in the Wild West of tokens.

 ERC 620 is a guideline or a standard for when you want to create your own token. It defines 6 mandatory functions that your smart contract should implement and three optional. Once to start with, you can optionally give your token a name, and a symbol, and you can control how dividable your token is by specifying how many decimals it should support.

 The mandatory functions are a bit more complex. For starters, 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. Next up is the balance-off method which has to return how many tokens a given address has. And then there are two transfer methods, a transfer which digs a certain amount of tokens from the total supply and gives them to a user, and a transfer which can be used to transfer tokens between any 2 users who have them. Finally, there is the approval and allowance method. Approve verifies that your contract can give a certain amount of tokens to a user taken into account. The total supply and the allowance method are almost the exact same except that it checks if one user has enough balance to send a certain amount of tokens to someone else.


How to create an ERC-20 token?

If you know something about object-oriented programming, you can compare ERC 20 to an interface. If you want your token to be an ERC 20 token, you have to implement the ERC 20 interface, and that forces you to implement these six methods. Now, before there was the ERC 20 standard, everyone who wanted to create a token had to reinvent the wheel, and that meant that each token contract was slightly different and that exchanges and wallets had to write custom code to support your token. With ERC 20, however, exchanges and wallet providers only have to implement this code once, and that's why exchanges can add new tokens so quickly and why wallets like my Ether Wallet have support for all ERC 20 tokens without having to be updated. So how easy is it to create your own token? Well, there's a website called Token Factory that does it all for you. You just enter what the total supply of your token should be, what you want to call it, how many decimals it should support and what symbol it should have. After entering all this, the website creates a token contract for you and adds it to the Ethereum blockchain. It is super easy and almost effortless. So effortless in fact, that the website etherscan has a list of 36,000 known ERC 20 tokens and it's estimated that in 2017 over $4 billion was raised by selling tokens in an ICO. 


Ultimate words

However, these tokens were not always clean, some were really overhyped and many people got scammed into purchasing tokens that were essentially worthless, but now we're getting a bit distracted. ERC 20 is a great standard that has propelled the use of tokens, but ERC 20 itself is not perfect. It's only a guideline and people are free to implement the required functions however they like, and that has led to some interesting problems. For instance, to buy some tokens, you have to send some ether to the token contract, but some people tried sending other ERC 20 tokens instead. If the contract was not designed with this in mind, it will result in more tokens being lost. In fact, it was estimated that by December 2017 well over $3 million have been lost because of this flaw. So to solve this, the community is already working on extending the ERC 20 standard with the ERC 223 standards. This warrants token creators about these risks and offers some workarounds. That was it for this content. I hope you find it interesting. Let me know what you think about ERC 20 tokens in the comments below. Thank you very much for reading and don't forget to share the article in your social profiles.


 

No comments

Powered by Blogger.