By the end of this lesson, you will be able to:
In this lesson, we provide a detailed guide on how to issue BEP20 fungible tokens on the BNB Smart Chain network. Even though there are several different IDEs that can be used for development purposes on the BNB Smart Chain, the most easiest to use is the Remix IDE. For this demo lesson, we will utilize the Remix IDE to write, compile, and deploy smart contract on the BNB Smart Chain for issuing BEP20 tokens.
Remix IDE is used for the entire journey of smart contract development by users at every knowledge level. It requires no setup, fosters a fast development cycle and has a rich set of plugins with intuitive GUIs. The IDE comes in 2 flavors (web app or desktop app) and as a VSCode extension.
BEP20 is the BNB Chain's equivalent to the popular ERC20 specification for tokens on the Ethereum network. The difference is the BEP20 Token isn't run on the Ethereum Network, but the BNB Smart Chain network. Despite this difference, because BNB Smart Chain implements the Ethereum Virtual Machine (EVM) for all of their smart contracts, they end up being practically identical in both specification and implementation.
In this lesson, we provide guidelines on how to create, compile, and deploy a simple smart contract on BNB Smart Chain for issuing BEP20 tokens using the Remix IDE. For this hands-on guide, readers are encourged to perform the specified tasks along for a better understanding. Before diving into the practical guide, the following requirements are necessary to be fulfilled.
There is no need for any local environment settings for deploying solidity smart contracts on BSC using the Remix IDE. All you require is a browser-based Web3 wallet (e.g. Binance Wallet, MetaMask, etc.) to interact with the BSC Testnet and deployed contracts. You must set up all of the following pre-requisites to be able to deploy your solidity smart contract on the BNB Smart Chain testnet.
Note: If you are already using Metamask, it is recommended to create a new account for testing with Remix IDE. You can do this from the account menu, which appears when you click on the account avatar in the top right corner of MetaMask interface.
BEP20.sol
.0.8.15
for this tutorial.As BNB Smart Chain uses the EVM, the code for deploying an ERC-20 Token and the BEP20 token is the same. This enables us to utilize the ERC-20 specification from OpenZepplin and modify it as per our requirements. You can also alternatively so the BEP20 token template here. Make sure to update the pragma statement to match the solidity compiler version used on Remix, 0.8.15 in our case.
BEP20.sol
file.// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract BEP20 is ERC20 {
constructor(uint256 initialSupply) ERC20("BEP20Token", "BPT") {
_mint(msg.sender, initialSupply);
}
}
a. Step1: Click the compile button to switch to compile page b. Step 3: Select the appropriate Solidity compiler version c. Step3: Enable "Auto compile" and "optimization" d. Step2: Select "BEP20" contract from the contract dropdown e. Step4: Click on the "Compile" button
a. Step1: Click on the Deploy button to switch to Deploy Options. b. Step2: Select "Injected Web3" c. Step3: Select "BEP20" from contract dropdown d. Step4: Specify the initialSupply of your token next to the Deploy icon. In our case we specified 100000000000000000000 for 100 BPT tokens. This is because the token is as 18 decimal places. e. Step 5: Click "Deploy" button and Metamask notification will pop up
e. Click "confirm" button to sign and broadcast transaction to BNB Smart Chain.
a. To view the issued tokens, copy the address of the deployed smart contract
b. Open your Metamask wallet, make sure you are connected to the account you used for deploying the smart contract. c. Click on the Assets tab, and then Import Token
d. Paste the address of your deployed contract in the Token Contract field, the token and decimal values will be fetched automatically. Click on Add Custom Token button.
e. Now you can view the issued BEP20 Tokens in your wallet.
In this lesson, we covered how to issue BEP20 tokens on the BNB Smart Chain Testnet using the Remix IDE. Even though we issued the tokens on testnet, the steps are same for the mainnet.