Create ERC 20 Token On Ethereum With Solidity

0
7
ERC 20 Token

With this article, you will learn how you can create your own Cryptocurrency or ERC20 Token on Ethereum with the help of Smart Contracts. ERC 20 token standard is a draft specification created in 2015 for implementing tokens which defines a set of instructions that an Ethereum token can implement. A token comprises of following basic components:

  • Total supply – returns the total amount of tokens in circulation.

  • BalanceOf – It gives the balance that the address holds.

  • Transfer – It transfers the value to another address from your own address.

  • Approve – it gives permission to another address to spend tokens on your behalf.

  • Allowance – it tells how many tokens you have given permission to spend

Events:

Installation of Metamask

Before starting the program just install a Chrome extension called Metamask.

Creating the Token on Solidity:

We will do all our programming in an IDE called Remix IDE. So copy all the methods in the proposal like the program below created in an interface called IERC20:

create solidity token

  • Create a Smart Contract that imports IERC20 files and implements that interface.
  • We will return a total number of Func Tokens in circulation.
  • Send the initial Balance to ourselves.
  • mapping(address) is used to store the balance.
  • We will return the balance of the address and transfer the balance.

The following program illustrates the Creation of ERC 20 Token:

Deploying the Program:

In order to run the program, we have to follow certain procedures which are as follows. So when you are deploying the program in a test network, it will cost you some ethers to deploy it. The window will show like this:

Deploy the program

  • Click on Accept.
  • The contract has been deployed on the network as shown below and copy the address in the address bar.

copy the address

After this open the link in a new window:https://wallet.ethereum.org/contracts

  • When the link will open click on Watch token tab.
  • A window something like this will appear:

Add token

  • In the first box paste the contract address which on you have created the token. it will automatically fill all the details in the other sections of the box. As it knows the name,
  • Function, and the decimal places.
  • Next, we go to the wallet and there we will see that we have 1 million Func tokens in our wallet as we created in the program.
  • We can see this in the image shown below.

function token wallet

We will have to add these tokens to the Metamask wallet also. To do this just paste the address in the Metamask and rest it will be automatically added in the Metamask wallet.

As the program has been written, we can also send these tokens to another address.
For performing this action we need to create another address same as the one listed above.

send function tokens

In the above image, we are sending 10 func tokens to another wallet address.

send funds

We can see that we received 10 func tokens in another address.
So we can see how easy is to create the tokens or currency and send it to another address

How to install Metamask browser extension on Chrome:

In this section, we will see how we can install Metamask and create a wallet. By this, you have to create 2 wallets so that you can learn how to transfer funds from one token to other. If you do not install this, it may result in permanent loss of tokens.

  • Click here and install metamask and Add to Chrome Extension: https://metamask.io

Creating a wallet in Metamask:

When you have installed Metamask Chrome extension click on the logo of Metamask.

  • Click on create a new wallet.
  • Enter the Password
  • It will show you 12 words which you have to write it down somewhere safe. In case you lost the wallet then this key will help you in recovering the wallet.
  • Your account is now created.

You have to create another wallet in order to practice the program of transferring the funds through the same procedure.

metamask account

Conclusion:

In the above article, we studied how we can easily create an ERC20 token and transfer funds through the same. How well did you understand the article please tell us in the comments section below and do tell us how many wallets did you create through this procedure?

LEAVE A REPLY

Please enter your comment!
Please enter your name here