Create your own token on the Ethereum platform

Tram Ho

After writing articles about decentralized applications and preparing to guide you to do practical examples. I want to write some important topics in detail so that people can understand them better. And today will be a way to create a token on the Ethereum platform. Why is a token and not a coin? Everyone with me find out

1. Token and Coin

When it comes to something to circulate in the Blockchain system, people often think of Bitcoin or Altcoin immediately (Alternative Cryptocurrency Coins). So what is token and what does it do on Blockchain?

Altcoin is referred to as variable electronic currencies from Bitcoin. There are forked branches from Bitcoin such as Namecoin, Peercoin, Litecoin, Dogecoin, … These coins were developed from the original Bitcoin protocols to meet the needs that developers want different from Bitcoin. . Many people believe it is a reform of Bitcoin. But people see that, never on Coin Market Cap has any other name in the number one position besides Bitcoin. Some other Altcoin ways are rewritten to separate protocols and used in separate Blockchain systems such as Ethereum, Ripple, Omni, Bitshares, NEO, …

=> So conclusions, Coin and Altcoin have their own independent Blockchain system and are used in their original Blockchain system protocols.

A token is a representation of a specific asset or utility, usually located on an existing blockchain. The token code seems more versatile when it can represent the value of goods, expressing the uniqueness of an Object, the points of members, can be used as electronic currency for circulation.

Creating tokens is a much easier process because you don't have to modify the code from a specific protocol or create a blockchain from scratch. All you have to do is follow a standard pattern on blockchain – such as the Ethereum platform or Waves – allowing you to create your own token. The function of creating your own token is done through the use of smart contracts; Computer code can be programmed to execute itself and does not need any third party to function.

=> So creating a decentralized application with tokens using the Blockchain system is sure to be more easily accessible than creating a separate Blokchain system and coin for it.

2. Standards to create a token on Ethereum

As mentioned above, you can create your own token but follow the standards available. Why does it need to be standard? Let's take a look at some concepts:

Ethereum Request for Comment (ERC) is a form of research release and requires comment in the Ethereum source code community. ERC is a form of EIP, or Ethereum Improvement Proposal – Proposal to improve Ethereum. Just like Bitcoin Improvement Proposals (BIPs), only a handful of proposals are actually implemented. The following figures can be interpreted as version registration numbers to distinguish them from other ERC standards. Common ERC standards such as ERC20, ERC777, ERC223, ERC721, ERC827, ERC948, ERC884.

In particular, ERC20 is the most commonly used token Ethereum standard. It can be said that almost any ICO project uses this standard ERC20 token. A token using ERC20 standard will be available

The following 6 functions:

and 2 events:

Before using this standard, if you send a token to the wrong address, the token will be permanently lost. These standards can be considered as patches or improvements to the token. And more importantly, using an ERC standard helps the system understand and interact better with your token.

An e-wallet will know the interactions with your token if you know you're using an ERC20 standard. If you don't use any standard, your token is a new thing without any electronic wallet, so it's hard for developers to do something to store it for you or to exchange between Your token with other tokens.

Maybe you are interested

Learn Blockchain technology located under Bitcoin Protocol [Part 1]

The roadmap to become a programmer after 9 months of self-study (Part 1)

3. Practice only

Using the Token standard has your code ante jailed, no longer being created? No, as is known, solidity is an object-oriented language. So you only need to implement this ERC20 class token to develop your token. Keep using Remix IDE.

The code of ERC20 you can get here

I will use solidity version 0.4.25 familiar to me

There are some problems when you compile with solidity versions, some versions will require you to use pure or view instead of constant so I fix a bit.

You create the file ERC20.sol and then add the other code. Function description of the function can be viewed here

Next is the file SafeMath.sol . As its name implies, this file helps to check the condition of parameters before doing calculations with them.

And finally, import the above files and implement the contracts into the Token.sol file

After everything is ok (that is, there will be no errors in the code line) then proceed to compile.

There are some warning on the other side. But okay, there is no error when compiling. Go to the Run tab and try deploying the code.

Since the last Smart Contract I use is Token, I will choose it to deploy. You should note that the constructor part I am making my token initialization parameters can be entered. And those parameters are:

  • Name of the token
  • Code of token
  • The number of decimal places after the comma of the token
  • Total number of tokens to issue

For example, we will create the token as follows:

  • Name:
  • Code: VBL
  • Number of decimal digits after comma: 0
  • Total issued tokens: 1000

Remember to log into the metamask to use the remix as your guide in the previous post. You can review it here

Enter everything like your image and click on transact, confirm the transaction that the metamask notified and wait a bit.

Delicious! Successfully deploying and I tested the functions ok.

You can view your token at https://ropsten.etherscan.io/ has it matched the five world powers. Type a name or a Token symbol to search. It will take some time to find it because the tokens deployed on the testnet network are quite numerous and continuous.

Or you can go to the Token section on Metamask to add the token. Click on the latest transaction in Metamask's transaction history and you will see a Smart Contract address that token deploy on. Use that address to add to Add Token in the metamask we can check if the Token number has been deployed yet.

Share the news now

Source : Viblo