The Binance Smart Chain (BSC) and the MATIC Network (Polygon) offer test networks so we can bring our own ERC20 token to life for free. Also, the good thing about these blockchains is that the cost of launching our token on the mainnet is much lower than on the Ethereum blockchain and the process is very similar. In a previous article we saw how to develop your own token in Remix. Now, it is time to bring it to life and that this token can be transferred globally to whoever we want.
How to add ERC20 token to BSC and Polygon
Once we have verified in the Remix deployment part that our token works correctly, it is time to launch it on a blockchain. For this process it is recommended that we have a web crypto wallet like MetaMask, since it makes the process much easier and it is also easier to add the test networks. MetaMask is a cryptocurrency wallet that is installed as a browser extension.
Add token to BSC
To launch our token on the BSC testnet, the first thing we need to do is add this testnet to our MetaMask wallet. To do this, what we will do is click on the networks section at the top of the extension and select “Add network”. Once here, we must fill in the fields to add the BSC test network as follows:
- Network name: Smart Chain-Testnet
- New RPC URL: https://data-seed-prebsc-1-s1.binance.org:8545/
- String Identifier: 97
- Currency symbol: BNB
- Block scanner URL: https://testnet.bscscan.com
When selecting save, the BSC test network with zero BNB should automatically appear. Testnets are free. However, they replicate the operation of the main network. Therefore, it is necessary to obtain test BNB to pay for the gas and be able to launch our token. To get free test BNB, we must click on this link, enter our testnet MetaMask address, and in a few minutes 1 BNB will be added to your MetaMask wallet.
We unfold from Remix
Next, we must go to Remix, and in the deployment section where we had done our tests locally, in the “Environment” part we must select “Injected Web 3”. Once selected, Remix will connect to our MetaMask wallet automatically and display the network number (97 in this case), our testnet address, and the amount of BNB we hold (this will display in ETH).
The next step is to decide the amount of tokens that we want to deploy in the “Deploy” section. Here the number of decimals that we write at the time of making the contract is important. In my case, I did it with two decimal places, therefore, the number that we write in Deploy will appear with two decimal places. For example, if we want to deploy 50,000 tokens, in Deploy we have to write 5,000,000 tokens, since two zeros will be removed from the number (two decimal places).
Once we decide the number of tokens, we click on Deploy and if everything is correct, MetaMask will automatically open again to confirm the launch of the tokens. Here it will ask us to pay for the gas in BNB, but since it is operating on the test network, these BNBs that it asks for are the test BNBs that we have previously obtained for free. When clicking on confirm, you have to wait a few seconds and when the transaction is confirmed, a green tick will appear on the lower screen of Remix.
Now, the token should already be deployed on the BSC testnet. To check it, you can go to the BscScan Testnet and in the search engine paste your MetaMask account address where you created the contract. If everything is correct, it should appear that the creation of a contract for a determined Fee in BNB has actually been prepared. Clicking on the contract creation transaction will open a page with all the deployment information.
Now, to add this token to your MetaMask wallet, you must open your account and click on the “Import Tokens” link that appears just below your BNB balance in your testnet account. Here, a tab will open in which you have to enter three sections: address of the token contract, symbol of the token and decimals of the token. In the contract address we must enter the address that appears in the “To” section when we click on the contract creation transaction. In my case: 0x54243f3cd228db419833bae58961340ef5b73e2a (the one that appears in the image next to a tick).
When entering the contract address, the token symbol and token decimal fields will automatically be filled in with the information that we had entered when developing our token. We select “Import Tokens” and the tokens will automatically have been added to our MetaMask.
Except that we are operating on a testnet, these tokens already have all the features of any other ERC20 token. In fact, this can be verified by sending these tokens to our friends or acquaintances. To verify that it works correctly, you can add another MetaMask account in the “My accounts” section in the upper right and send some of these tokens to this account.
To do this, in the new account you must be in the BSC testnet and import the tokens as we have done in the main account. The tokens will then be imported to you but the balance will be zero tokens. To send yourself tokens to this new account, copy the address of the new account and in your main account select to send your new tokens to the address of this new account. After a few seconds, the amount of tokens you have decided to send will be transferred from one account to another. Likewise, in BscScan the verification of this transaction will appear and a page will appear with the information of our new token.
In the main network it would be the same process, but with real money and selecting the main network when adding the network in MetaMask. In other words, these tokens would already have all the characteristics of any ERC20 token and could be purchased by users or companies and used to finance projects.
Add Token to Polygon
The process to add our ERC20 token to the Polygon sidechain is very similar to that of the BSC. Thus, the first thing we must do is add the Polygon test network to our MetaMask, for this, when selecting add network, we must fill in the fields as follows:
- Network Name: Mumbai
- New RPC URL: https://rpc-mumbai.maticvigil.com
- String Identifier: 80001
- Currency symbol: MATIC
- Block explorer URL: https://mumbai.polygonscan.com/
Now, in order to receive free trial MATIC and to be able to pay for the gas to deploy the token, we need to go to the Polygon faucet and claim these tokens. After a few minutes, we will receive our tokens in our MetaMask account.
Unfold from Remix
Now, as we have done with the BSC, we go to Remix to the token deployment part, and if we have MetaMask open in the new test network, our address will automatically appear with the amount of MATIC (in Ethers) and the number of the new network (80.001). Next, we select the number of tokens we want to deploy, click on deploy and sign the transaction in our Metamask wallet.
To verify that the token has indeed been added to the Polygon testnet, we must go to this link and paste our MetaMask address in the browser. If the contract has been deployed correctly, the creation transaction will appear.
Import Tokens to MetaMask
When importing the tokens into MetaMask, the process is identical to the previous one for the BSC. You only have to copy the address of the contract, import tokens in MetaMask and we will have the tokens in our crypto wallet with which we can operate.
Also, the process to add the tokens to an Ethereum testnet like Rinkeby or Ropsten is very similar. Mind you, deploying the tokens on the Ethereum mainnet is much more expensive.
Images taken from: Observatorioblockchain