Build your own ERC-20 token. – Pranshu Rastogi

Now its time to get your hands dirty, I will be guiding you on how to build your own ERC-20 token, and how to deploy on test net.
You can also build multiple testnet addresses and transfer ERC-20 tokens and play among your friends.
I will be using –
- Web Browser
- Online Remix editor
- Metamask
- Etherscan
Just open any web browser and go to Remix online editor, here we can start writing our own code in solidity and easily deploy, we will also install Metamask (Open chrome and add Metamask as an extension).
Let’s try writing some of the functions and build our own token.
Note: I am just implementing some of the functions, you can add or remove functions as per your convenience and I am also using test net for the deployment. So, before implementing please make sure you are not deploying to mainnet or I won’t be responsible for any loss.
I am making token with
Name = "Rastogi coin"
Symbol = "RC"
Decimals = 18
Now let’s try writing some of the functions of ERC-20
pragma solidity ^0.4.24;contract RastogiCoin
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value)
internal
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
*
@param _to The address of the recipient
*
@param _value the amount to send
*/
function transfer(address _to, uint256 _value)
public
returns (bool success)
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
*
@param _value the amount of money to burn
*/
function burn(uint256 _value)
public
returns (bool success)
}
Here pragma defines the version of solidity in which we wish to compile and I have mentioned the comments for the rest of function, please go through them once.
As of now, we have successfully written down the function. Now, we will select the suitable compiler version and then compile and then we will be all set to deploy.
Here I am using Rinkeby Network and Metamask wallet.
Create your account and some rinkeby faucet to your account as deployment and all write operation on Ethereum cost gas (Some ether) as a fee.
After adding some Rinkeby ETH to your account and if you see no error while compiling, we are all set to deploy on Rinkeby Testnet.
After Successful deployment, you can see all functions below.
You can also check the transaction on etherscan.
Here is the contact address of my deployed contract address, you can go to https://rinkeby.etherscan.io/ and verify it.
contract add - 0xdec452c6b9890a578915e70a1ee15b77f7fa17cb
That’s all folks if you got stuck at some point, feel free to ping me anywhere.
I have pushed the code to
Github, try deploying it and play with it.
Do follow me on
Twitter, Linkedin, and Github.
Your suggestions are welcome and do let me the topic you want me to write.
#Learn and grow together.
Published at Thu, 11 Jul 2019 19:43:23 +0000
{flickr|100|campaign}
