Building Your First ERC20 Token

Lina Nada Maach
The Innostation Publication
8 min readJan 14, 2022

A step-by-step guide.

“I wish I had my own currency”

I bet that thought crossed your mind, at least once — when you were trying to figure out how you can become rich, or more commonly, when you see tokens’ values skyrocket and you’re just watching from the sidelines.

But look no further, because while I’m not a wish-granting fairy, I can grant your wish this time.

Instead of using my magic though, I will be taking you through the steps I followed to build and deploy my very own token, DeBias.

But efore I do that, let’s discuss the basics and the prerequisites to ensure you can follow along smoothly.

Before we get started:

No, we’re not going over what is Blockchain or Smart Contracts, that’s a prerequisite to follow along. Instead, I will directly jump into ERC20.

ERC20 Tokens

First of all, ERC stands for “Ethereum Request for Comment”, and was implemented in 2015 as a standard for writing and deploying smart contracts on the Ethereum blockchain to create investable and exchangeable tokenized assets.

Metamask

We will be deploying our token on the Ropsten Test Network, so I would highly recommend downloading the extension and creating an account to be able to do that as well.

Solidity

The language I will be using to code the smart contract is Solidity, a language that is very similar to JS in syntax — but not in the “behind-the-scenes”, where they significantly differ.

Remix

We will be developing this project on Remix, an online IDE that can be used to write, compile, debug and deploy Solidity code.

Why deploy on a test network?

Once a contract is deployed to the blockchain, it can’t be modified, meaning that we should only take that step once we’re sure everything is functional.

We can do that by deploying our contract locally in Remix, and then by deploying it on a test Ethereum network, with fake ether.

And finally, I will not be deploying this on the Ethereum mainnet because the gas fees can be crazy and it’s not a project idea I want to pursue, so I will be sticking to a test network for now.

Building The Token

Step #1: Setting up your Remix workspace

If this is your first time using Remix, then you’ll have one more step to do, but if you’ve used it before you should be ready to go.

At the top left, you’ll see a workplace sidebar, if it’s your first time using Remix, it will say “Default Workspace”

If that’s the case, I would recommend that you set up a new workspace using the plus button:

A window will pop-up:

Name your workspace and create it.

Step #2: Setting up your file

Create a new file called “nameofthefile.sol” (Naming the file with the token’s name is good practice).

Step #3: Declaring the license for the source code

It’s not that important in such a beginner project, but it’s a good habit to declare the SPDX license at the very beginning, which also prevents the constant headache of Remix messages bugging you to do that every time you compile. I will be using the MIT license.

Step #4: Declaring the solidity version you’ll be using

You need to do this for EVERY Solidity file to tell the compiler which version you’ll be using — I recommend the latest version as it has most recent bug fixes, so you’ll probably find less issues.

Also make sure that the solidity version corresponds to the one the compiler is set to:

Make sure your Auto Compile is enabled so the compiler can debug in real time.

Step #5: Importing the ERC20 library

We will be inheriting all the required functions for an ERC20 token from a GitHub library:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol

Step #6: Creating the smart contract

Create the smart contract using the “contract statement”. The name of my token is DeBias, so I named my contract accordingly, but the contract’s name doesn’t have to be similar to the token name.

Step #7: Creating the Token

Next up, we will define some very fundamental elements for our token: The name, the symbol, the total supply and the admin of the contract.

In this case, the token’s name is DeBias, the symbol is $DBS, the total supply is 100 Trillion, and the admin is whoever deploys the contract.

Step #8: Adding extra functions

At this point, your token is ready to deploy, but you can make it more sophisticated by adding on more functions.

For this project, we will keep it simple by adding the mint and burn functions.

Minting is decreasing the value per token by creating new tokens — so it’s the same market cap but higher total supply. I set the mint function so only the admin can mint new tokens.

Burning is the opposite of minting, it’s increasing the value per token by “deleting” tokens — so it’s the same market cap but lower total supply. I set the burn function so that anyone can choose to burn their tokens.

Step #9: Deploying the contract on JS VM

The contract is now ready to be deployed, but before we deploy it to a test network, we can test it right there on Remix to make sure everything is good to go. Just go to the deploy tab, set the environment to JavaScript VM (it comes with 10 fake accounts), don’t touch the gas limit, and make sure that the Contract box is the right contract and file.

Deploy the contract — it might take a few seconds to happen — then find the “Deployed Contracts” section at the bottom left and expand the corresponding contract…

**Moment of anxiety** Is it going to work? You’re about to see…

It should return this:

Those are all the functions available to you. Orange means you have to pay gas fees and are anything that requires a change of balance of any accounts (they need a new block saved into the Blockchain), the blue ones are anything that just looks through the Blockchain to find information (soo you don’t need to pay gas fees).

Step #10: Deploying on the Ropsten test network

Now that we know the contract works, we will deploy is on a test network.

First, change the environment to “Injected Web3”.

Next, a metamask window should pop up asking you to connect metamask with Remix:

Connect your Metamask to Remix, then go to your networks tab. If you’re a new Metamask user, it will only show you the Ethereum blockchain by default:

To access test networks, go to “show/hide test networks” and enable it:

Next, go back to your networks and select the Ropsten test network:

If it’s your first time using it, you will have 0 ether, but you need some for the gas fees to deploy and test transactions. Don’t worry, since it’s a test network, it’s just fake ether, to get some, just select “Buy”…

Then select “Get Ether from a faucet for the Ropsten”

It will take you to a new tab, select “request 1 ether from the faucet”, the ether should be in your account within a few seconds…

Now back to Remix…

Make sure that the tag right below the environment says “Ropsten Network”

Now go ahead and press deploy…

After a few seconds, you should get this…

Congratulations, your token can be found on etherscan (with a twist, it’s only on the Ropsten etherscan)!!

Step #11: Find your token on Etherscan

Want to see the result of your hard work?

Copy the admin address and search it on Etherscan, you should see that you own your token, and from that page, you can go to your token page…

https://ropsten.etherscan.io/

Conclusion

It’s time to wrap up 😥

If you’re already thinking about becoming the richest person in the world, I am sorry to break it to you, but that’s not happening with our very basic token. The only way to currently own your ERC20 token is if someone who owns it transfers it over, and it also doesn’t have any value or concept to make it useful for people to use. But building an ERC20 token is a good starting project to familiarize yourself around solidity, smart contracts, …

If you’ve come this far, thank you for reading! If you enjoyed it, feel free to follow my journey on Twitter @linamaach, on LinkedIn, and subscribe to my personal newsletter to get monthly updates about what an ambitious teenager is up to!

We’re providing opportunities for the next generation of student thinkers, inventors, and learners, to publish their thoughts, ideas, and innovation through writing.
Our writers span from all areas of topics — from Growth to Tech, all the way to Future and World.
So if you feel like you’re about to jump into a rabbit hole of reading these incredible articles, don’t worry, we feel the same way. ;)
That’s why students x students is the place for getting your voice heard!
Sounds interesting? Why not join us on this epic journey?

--

--

Lina Nada Maach
The Innostation Publication

AI and Blockchain enthusiast. I write about Stem, emerging tech, growth, philosophy, culture, global causes, book recs, lifestyle, AI & Blockchain.