A Token is a digital representation. Tokens can represent anything like people, organizations, financial assets, fiat currency, etc. In fact, that cash in your pocket, it’s just a token to represent value.

Today, we will create a simple Token for Kinda Lame on the Ethereum network. And, we will do it in under 10 minutes!

We will be creating a Token compliant to ERC-20 Token Standard. The ERC-20 (Ethereum Request for Comments 20) is a robust Token Standard that implements an API for tokens within Smart Contracts. ERC-20 Tokens are Fungible i.e. each Token is the same in type and value.

ERC-20  allows you to transfer tokens from one account to another, as well as get an account’s current token balance and the total supply of the token available on the network.

A Smart Contract implementing the following functions and events is called an ERC-20 Contract:

Functions

function name() public view returns (string)
function symbol() public view returns (string)
function decimals() public view returns (uint8)
function totalSupply() public view returns (uint256)
function balanceOf(address _owner) public view returns (uint256 balance)
function transfer(address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function approve(address _spender, uint256 _value) public returns (bool success)
function allowance(address _owner, address _spender) public view returns (uint256 remaining)

Events

event Transfer(address indexed _from, address indexed _to, uint256 _value)
event Approval(address indexed _owner, address indexed _spender, uint256 _value)
These functions and Events ensure that Ethereum tokens of various types behave consistently within the Ethereum system. Consequently, almost all digital wallets that accept ether now support ERC-20-compliant tokens.

Prerequisites

  1. MetaMask Chrome Extension (https://metamask.io/)
  2. Any ERC20 Implementation – We will be using a simple implementation by CodeWithJoe
  3. Remix IDE – Online (http://remix.ethereum.org/)
  4. Ropsten Ethereum Faucet (https://faucet.ropsten.be/)

My environment looks like this:

Ropsten Testnet Environment Setups

You can then use a split window to read this tutorial on the side while you work with these 3 tabs.

Creating ERC20 Token

The ERC20 Token we will be creating is a basic one and the process won’t take very long. Just make sure you have the prerequisites set up.

Install MetaMask. Please refer to our blog about MetaMask and how to set it up, if you need help.

Open the MetaMask extension and switch to Ropsten Test Network.

How to Select Ropsten Test Network With Metamask

Then we need some Ropsten test ether. First copy your MetaMask account number by clicking the area marked as blue below on your extension page. Clicking there automatically copies it to your clipboard.

Getting your Ethereum Address in Metamask
Getting Test Ethereum from the Ropsten Testnet Faucet

Move back to your extension. Your account will now have been funded with 1 test Ether.

MetaMask Wallet Showing One Test Ethereum Balance

Programming With Solidity in Remix

Navigate to http://remix.ethereum.org/Note that the URL is HTTP and not HTTPS. This is because with HTTPS remix sometimes does not work correctly.

 Create a new file and end its name with .sol extension.

Ethereum Token Creation with Remix IDE - File Creation

Copy and paste the code from https://github.com/CodeWithJoe2020/ERC20Token/blob/main/ERC20.sol

Considering starring it because the author has published this code for free.

Copy code from Github into Remix for ERC-20 Creation

Make some simple changes to the code like name, symbol and supply (highlighted in blue). Finally, switch to Compile tab by clicking second icon on the sidebar and click Compile.

ERC-20 Token Creation with Remix IDE - Setting Token Values

Upon successful compilation, the sidebar should look like this.

Compiled ERC-20 Token in Remix IDE

Next switch to the deploy tab from the sidebar and make the changes marked in blue. MetaMask extension should open. Click Next. Then click Connect.

Connect Metamask to Remix IDE

Changes shown zoomed in.

Deploy and Run Transaction on Ethereum - Deploy Smart Contract for ERC-20

Finally, click Deploy. MetaMask extension will show up.

Metamask - Deploying ERC-20 Token on the blockchain

Click Confirm.

MetaMask transaction will complete and a notification indicating the same should appear.

Note the changes in debug console. Click the link which appears in your debug console.

Remix IDE Console - ERC-20 Deployment Details

Upon clicking the link a new tab like this should open.

Ropsten Testnet - Etherscan View of ERC-20 Token Creation Transaction

Click the contract address.  As you can see, the token has been created:

Etherscan Contract Details Page for ERC-20 Token

Now, let’s finish by verifying and publishing our contract on Ethereum blockchain. Click Contract tab on the Etherscan tab. Next click Verify and Publish.

How to Verify and Publish Your ERC-20 Token on Etherscan

Fill in the details including your source (solidity code). Click Continue.

Source Code Verfication Steps on Etherscan

Get compiler version from Remix:

Where to get the compiler version in Remix IDE

On the next page, copy paste the code from Remix to the area provided:

How to Upload and Verify Solidity Code on Etherscan

Scroll to the bottom. Click Verify and Publish after completing the captcha.

 It will take a few seconds and then the following screen will appear. Click the Contract address to return to contract page.

ERC-20 Contract Source Code Verfication on Etherscan

Our basic ERC-20 smart contract is now verified.

Verified Solidity Source Code on Etherscan

We will now add our token to MetaMask.

Adding your Token to MetaMask

 Copy the contract address on top.

Where and how to find the contract address for ERC-20 Tokens on Etherscan
Where to add tokens to metamask

Click add custom token and paste the contract address.

Adding a custom ERC-20 token to Metamask

Click Next. Finally, confirm by clicking Add Token. Your token will appear in your MetaMask account.

MetaMask showing custom ERC-20 token balances

That’s all. We are done.  

Final Words

We made a very basic ERC-20 token in just a few minutes. Isn’t that exciting?

We performed the whole process on Ropsten Test Network, so we did not have to spend any real gas. But, you can follow the same process to create your own token on the Ethereum Main Network. Just change it in MetaMask from the network list.

ERC-20 makes it very easy to make custom Tokens on Ethereum Network. However, it is still a new technology and sometimes bugs need to be ironed out. Fortunately, it has a large community supporting it and as of 2019, over 200,000 ERC-20 compliant Tokens exist on Ethereum Network signalling its bright future.

References

Ethereum Docs ERC-20: https://ethereum.org/en/developers/docs/standards/tokens/erc-20/

CodeWithJoe: https://www.youtube.com/watch?v=GDq7r1n9zIU (Check out his channel and show some love!)

Disclaimer

The information contained herein is for informational purposes only. Nothing herein shall be construed to be financial legal or tax advice. Trading cryptocurrencies poses considerable risk of loss.