Learning Solidity - How to create your own ERC20 token with no coding

avatar
(Edited)

image.png

There are a few tools out there offering a way to create your own token in several EVM-based blockchains as Ethereum, BSC or Polygon. If you are intending to better understand this technology, I encourage you to follow this quick tutorial and create a token yourself. You do not need any coding experience and we will be using Rinkeby, one of the Ethereum testnets so there will not be any cost associated and you will be able to use it as a point system or get ready to deploy one in any of the real blockchains.

As you know, the code in a blockchain is called a smart contract, and Ethereum coding language is called Solidity. So the first thing we need to do is to write or find a solidity smart contract that does what we want to do. Luckily there are many open-source places where you can get some of the most common contracts, one of them is OpenZeppelin

If you click on the link, you will be directly sent to the ERC20 token contract code and it is something so short as this.

Screenshot 2022-03-20 at 12.26.22.png

All you have to do is replace the token name and symbol for your own ones, in the example above Gold and GLD are used to define both terms. Now you may ask, how do I insert the code in the blockchain. Wel, you need to compile the software and deploy it to the blockchain with an account. That may seem quite complicated for a no coder but luckily we have some free tools to do that.

First, OpenZeppelin offers us a free wizard to customize their ERC20 token contract, just go to their wizard link, replace in MyToken name and MTK symbol for anything you want and add some amount in the Premint field to get some initial tokens created at the time we deploy the contract, then forget about all the other options. Your code will appear updated in the black text box. I have used Tutorial and TUT for my name and symbol and have requested 5000 TUT tokens as you can see.

Screenshot 2022-03-20 at 13.18.35.png

So we have the code, but how do we compile and deploy it to the blockchain?. Here comes the magic again? We can use Remix IDE (Interactive Development Environment).

image.png

Do you see the buttons at the top of the black contract code window? click in the "Open in Remix" one and a new browser tab will open with Remix and the code will be inserted there. If everything works fine you should have a screen similar to this one on your computer.

Screenshot 2022-03-20 at 13.20.06.png

If you forgot you can change the name, symbol, and amount of pre-minted tokens directly in the code, I did change the name for "Tutorial" and the symbol for "TUT" , then go ahead and hit the blue "Compile" button. If everything works fine you should bet a green OK mark in the compile bottom like this one, on the left column.

Screenshot 2022-03-20 at 12.50.33.png

Now we need to deploy our contract to the blockchain. Remix offers you a virtual blockchain by default for you to test things internally but we will directly deploy it in Rinkeby testnet. To do that we need to have an address, some tokens and select the blockchain we want to use. Open your Metamask wallet and create a new address for testing. You do not want to mess around with any of your actual addresses.

image.png

Then select Rinkeby Testnet from the Metamask network selector.

image.png

Now you will need some "fake" Eth do pay the transaction, so go to this Rinkeby Faucet, paste your new created address and you will be transferred 0,1Eth which will be enough to pay your transactions.

Now we are ready to deploy so come back to Remix, but first, we need to select where to deploy so click on the deploy icon.

Screenshot 2022-03-20 at 12.57.39.png

Then, on the top dropdown where it says Javascript VM (London) select Injected Web3 option, and make sure you see Rinkeby underneath and your newly created test account with the 0,1 Eth on it. (you will see mine has around 30 Eth)

Screenshot 2022-03-20 at 13.05.58.png

Below that info, in the CONTRACT dropdown, make sure you select Tutorial contract, if you used a different Token name, select that one.

Screenshot 2022-03-20 at 13.23.23.png

And now you can click the Deploy orange button. When you do, Metamask will open and will require you to validate and pay the transaction. Again, doublecheck you are using Rinkeby and have your newly Test Account selected before confirming.

If everything works fine, at the bottom of the screen, you should see a "view on etherscan" link and a success green tick with some information about the transaction. Go ahead and click in the "view on etherscan" link to get the transaction details.

Screenshot 2022-03-20 at 13.24.25.png

Rinkeby Etherscan will open and you will see the transaction details with the contract address, the name, and the initial amount of tokens minted (5000 in my screenshot). Keep in mind contract addresses are unique, so your token may have the same name and symbol than mine but the address is unique, this is how scammers try to confuse you sometimes creating fake tokens in Ethereum mainnet.

Screenshot 2022-03-20 at 13.26.38.png

Copy the contract address with the copy button a the right of the green tick and go to metamask to add it to your assets. Select Add Token or Import token

image.png

And paste the address there

image.png

Once added, you should be able to see the amount of pre-minted tokens in your test account you can share with anyone.

Screenshot 2022-03-20 at 13.32.03.png

There are some other options you can do with your contract as mint new tokens to any address, pause them etc. But that is for another tutorial.

Posted with STEMGeeks*- *



0
0
0.000
2 comments
avatar

Great guide, thanks for sharing!

!1UP

0
0
0.000