Building your own Ethereum based ECR20 Token in less than an hour
By: Ahiwe Onyebuchi Valentine
Tags: Solidity, Ethereum, Cryptocurrency, Token, Blockchain

Ethereum

I was applying for a program and a task was given to me to build an ECR20 token in less than 48 hours. This was my first attempt at blockchain development and I didn’t know where to start from. I had knowledge of the cryptocurrency world from a user stand point but not as a developer. I searched around for materials to aid in my task but most were not up to date. This is an up-to-date write up on the steps I took while building this token to help others that are interested in building their own token.

Step 1: Contract code

Download my updated smart contract from the legendary Ethereum unicorn rider, BokkyPooBah, by clicking here.

This code will be edited to build your own token

Step 2: Create Ethereum wallet with MetaMask

Download MetaMask chrome extension to generate a wallet. This is going to be the owner of the smart contract. Once you download the extension, go ahead and create a new account protected by a password. Then choose “Ropsten TestNet” from the top left corner. It looks like this:

MetaMask chrome extension

Step 3: Get Ropsten Ethers

You’ll need some test Ethers in your new MetaMask account to finish the creation of the tokens. These two faucets are working at the time of writing this article:

https://faucet.ropsten.be/

https://faucet.kyber.network/ This faucet will need a verified github account

Input your ethereum wallet address and you’ll be credited with ethereum

Step 4: Edit the contract code

Open the contract you downloaded in your Text Editor e.g VS code, Atom, Sublime etc.

Go to Line 3–15 and look at the comment section. Although this is a comment section, this will help you down the track of important information about your token

Change Line 4 to the title of your Smart Contract

Change Line 6, 120 and 121 to the Ropsten Ethereum address you created in MetaMask

Change Line 7 and 116 Symbol to your respective coin name (Keep it short)

Change Line 8, 102 and 117 to the name of your token

For the decimals and total supply on Line 118 and 119, you can just leave it as it is however I’ll explain it just for visibility. On total supply there are actually a few considerations. First one is that the standard (and max) is 18 decimals, meaning that a coin can be splitted in 18 parts.

The second one is that let’s say for example you want to issue 100 tokens, on the total supply part you have to put 100 followed by the number of decimals that you choose.

Example if I want to emit 100 tokens, what I will put on total supply is: 100000000000000000000; and so it goes.

Line 3–15

Step 5: Deploy Contract Code on Remix

Now head over to Remix IDE (an online solidity compiler and debugger) and paste the code you just modified.

Remix IDE

Compile Contract Code

Next go to the icon with the checkmark on the image and uncheck “Enable Optimizations” if it’s checked. Also set the compiler version to the version that is indicated at the beginning of your contract code. (Note: Do not use the nightly build)

Now go to the next icon below the icon with the checkmark and click on deploy after selecting <your token name> from the drop down list of contracts.

Deploy Contract to Blockchain

Once you hit deploy, MetaMask will prompt you to buy some test ether and submit the transaction. It looks something like this:

Payment Notification for Token

Just make sure you are on Ropsten TestNet and not on the MainNet and then hit Confirm. Now open up MetaMask again and click on the first transaction. It’ll take you to Etherscan where you can observe the ongoing transaction. It may take up to 30s to confirm the transaction. Once it’s confirmed it looks like the following:

Contract Transaction information

Note the to address in the above transaction page. That's your contract address.

Step 6: Publish and Verify Contract

Click on your contract address. On the new page click “Code”.

Now click on “verify and publish” link. Once you are taken to the new page, fill up the details such as compiler version, Enable Optimizations etc and paste the solidity source we deployed earlier.

Verify and Publish

Make sure the compiler version you choose matches the one you deployed your code against in the first step. Now hit “verify and publish”. If successful, it’ll generate bytecode and ABI as following:

Successful verification message

Now anyone can visit your contract address and read the source

Verified Contract address page

Step 7: Add token to your wallet

Now that your token has been verified, you should receive all the initial tokens (100000000 in my case) when you add it to your wallet. So, copy the contract address, go to MetaMask -> Add Token -> Custom token and paste the address. It looks like the following:

Add token page

Hit Next and Confirm. You should now see all the initial supply

GGMToken

Congrats!!!

You’ve just created your token. Now that you have your tokens, don’t forget to send me some, I would love to see what you have built. Send your brand new token to 0xFEB02D9383C49A8373F88e82EbCecB553c1837bf

This is my first article on Medium. Please hit the clap button if you loved it. Thanks.