Creating your own cryptocurrency is not that hard.
As I see dozens of cryptocurrencies’ price up and down 24/7, I always wondered what kind of genius made them because I know the fact that the mathematics behind the blockchain technology is intimidatingly complex.
Coins VS Tokens
Let me make the terms clear first. Sometimes people use the terms “coins” and “tokens” interchangeably. As far as I know, there is no legal definition between them. However, usually coins refer to cryptocurrencies that have its own blockchain such as “Bitcoin” or “Ethereum” whereas tokens refer to cryptocurrencies on other coin’s blockchain such as Tether or BitTorrent. Tether is on the Ethereum-blochcain and BitTorrent is on the Tron-blockchain.
Sometimes, a token becomes a coin after getting popular. EOS is one of them. EOS was on the Ethereum-blockchain until May, 2018 and became an independent coin.
The following link shows major tokens and its based blockchain platform.
Creating a token is not as hard as you think.
If you are making a coin with your own blockchain, you may have to deal with all the scary mathematics.
However, If you are making a token on an established blockchain like Ethereum-blockchain, it is not that hard. It took me just two hours from reading a few related articles on internet and testing to transfer the token from address X to address Y.
In this article, I would like to show you how I have created my own Ethereum-based and ERC20-compliant token. I named the token “KNKT2” by myself. Overall, the point of this article is that making a token is “not that hard”
About the token “KNKT2”
- KNKT2 is not on the Mainnet yet. It is currently deployed at the address of “0xeca5f96b24d71dad1d38752c0dd221a921518404” on the Ropsten Testnet.
- Deploying the token on the Mainnet costs me actual ETH whose price went up drastically these day. So I have chosen to put that on the Ropsten Testnet, which is considered the most similar to the Mainnet.
- Its total supply is 1,000,000.
- As of writing this article, the token is distributed as follows.
- 998,500 tokens owned by “0x72C87B42E09A2671693D163C9990d39bfD980F9d”
1500 tokens owned by “0x0Cdc6d91eBcb11C113f4c6029Ee3Ff0D4bF34926”.
- The both addresses are mine. The distribution is a result of testing if the token is transferable from address X to address Y.
KNKT2 can be sent to any addresses of the Ethereum blockchain(the Ropsten Testnet only because it is deployed there) and anyone can see balance of any address, and where the tokens come and go.
KNKT2 is one of the Ethereum-based tokens.
Unlike the Bitcoin-blockchain that can store only transactional record, the Ethereum-blockchain is revolutionized to not only to store transactional data, but also to deploy programming codes that can play roles of a server/database on the blockchain. Most people call the codes a “smart contract” because they behave like contracts and they can be enforced smartly by itself.
Creating a new token on the blockchain means deploying a set of codes that defines the properties and methods of the token to the blockchain. The codes are alike a Class whose methods and properties would be something like “totalSupply”, “transfer()”, “getBalanceOf().
Once the codes are deployed, users can read and execute the smart contract. Due to the nature of blockchain, unlike traditional server or database, once the changes was made by the execution, they are irreversible and immutable.
It sounds simple, isn’t it?
ERC-20 Token Standard
Because it is easy to create new tokens on the Ethereum-blockchain, there are a countless number of tokens outstanding.
Each token has its own purposes. However, most creators would want the tokens easily accessible so that they are used by as many people as possible.
The best way to achieve the goal is to make them compatible with the most widely used token standard, also called “the ERC-20 token standard”.
If someone says his or her token is ERC-20 compliant, its contract codes(Class) should have the following methods. (https://eips.ethereum.org/EIPS/eip-20#token)
function name() public view returns (string) => OPTIONAL
function symbol() public view returns (string) => OPTIONAL
function decimals() public view returns (uint8) => OPTIONAL
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 methods and events specify the most common functionalities of tokens such as “transferring the certain number of tokens from address A to address B”, “get balance of tokens owned by address X”, “get the number of total outstanding supply of tokens” and etc.
There were three methods for me to take a while to understand what they are. They were “approve()” , allowance()”, and “transferFrom()”.
I found out that ERC-20 tokens must have functionality that delegate other address your right to spend your token in your address. And the three methods are related to the delegation functionality. The functionalities seem somehow advanced and not that much needed for single individual creator like me.
Get your own Ethereum Address
You first have to have an Ethereum address. The easiest way of getting it is to install the Metamask. It is a browser extension running on your front-side.
Going through all the details of getting address and the Metamask would is not the point of this article. So I will skip it.
The Ethereum address looks like
This address can hold not only Ethereum(ETH), but also any ethereum-based tokens like KNKT2.
Determine the name and symbol of token you want to create.
Like Bitcoin’s symbol has its Symbol, BTC, and Ethereum, ETH, you need to give it to your own token name and symbol. I gave my token a name and symbol “KNKT2”, which does not have any meaning.
Deploy Codes in the Blockchains
Let’s get into the coding part. As I mention, creating a new token means deploying codes to an address amid the Ethereum-blockchain.
Deploying codes, which means changing the main blockchain, costs you a small fraction of Ether(ETH). The cost is not huge, but you would not want to spend real ETH on testing or experimenting. To avoid that, I have deployed the codes in the testnet called “Ropsten Test Network”. The testnet is known as having the most similar environment to the Mainnet.
And online IDE for Solidity can be found at https://remix.ethereum.org. It is called Remix.
This is how remix looks like
Remix provides a few sample codes such as Storage or Ballet. I found those codes very useful in getting a sense of how to use the language.
I create my own Solidity file erc20.sol. It is code for making the ERC20-compliant token.
It has all the methods required by the ERC-20 token standard. Anyone with a bit of programming background would understand what this code does. You copy and paste the code in erc20.sol.
Then click the file and click solidity compiler on the left.
Then click compile button
Now the solidity file is compile and ready to be shipped to the blockchain. Click Deploy & run transaction button.
Change Environment to “Injected Web3”. If you have Metamask installed on the browser, it will automatically set your account and environment in accordance with those in the Metamask.
Before hitting the orange Deploy button, you should set the details of your token such as its name, symbol, total supply and decimals etc.
Now it is ready to be deployed. Hit the orange transact button!!
Once you hit the button, Metamask asks your confirmation about deploying the codes. It says the deployment costs you 0.002456 ETH.
If I were doing it on the Mainnet, I should spend the real ETH. But I am doing it on a testnet so the ETH is fake.
Now I press the confirmation button.
While it is processing, a link to etherscan pops up. You click the link to see the progress of how the deployment is progressing.
Successful!! Looks like it went well. The code is deployed at the address of “0xeca5f96b24d71dad1d38752c0dd221a921518404”
Let’s check if the token exists. We can do it on the Metamask.
Click “Add Token”
Once you put the token contract Address and Token symbol, the Next button is activated. Press Next.
Looks good. KNKT2 exists on the Testnet and balance of 1,000,000 which is the total supply.
For test purposes, I transferred 1500 tokens to “0x0Cdc6d91eBcb11C113f4c6029Ee3Ff0D4bF34926”, which is another my address.
Transfer works seamlessly. So not I am one of the token creators. You can be one of them. Good Luck with yours.