How to Write & Deploy Bep-20 Token in Binance Smart Chain?

Guide to create and deploy Bep-20 token in binance smart chain:

In this article, you will find a step-by-step complete guide on how to create and deploy your first bep-20 token in Binance smart chain.

Are you excited to deploy your own bep-20 token in BSC? Yes? then, let’s get started!

Pre-requisites required:

  1. Metamask wallet extension.
  2. $2-3 worth of BNB token.

1. Connect your Metamask to Binance Smart Chain:

You need to configure your metamask wallet to add Binance smart chain network. Follow the below guide if you’re setting up everything from scratch.

  1. Select your Metamask wallet extension and Click on icon on the top-right.
  2. Now select Settings >> Network >> Add Network
metamask home
Metamask settings
metamask network

3. Now visit this official binance post to get the parameters to manually add your BSC to metamask. Click here

bsc mainnet paramters

4. Once done, switch your network to BSC in Metamask wallet.

We are done setting up. Now, let’s move on to the actual part.

2. Writing BEP-20 Token Smart Contract:

1. Now, let’s write our smart contract in remix IDE.Go to remix.ethereum.org and create a file (name_anything.sol) under contracts folder.

remix IDE

It should look something like the above image.

2. Then, we will set our compiler version.

pragma solidity ^0.8.3;

3. Now, Let’s import the ERC-20 smart contract code from the OpenZeppelin Github page.

import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol';

4. Now, Let’s write our contract.

contract BalaToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("BalaToken","Bala") {
        _mint(msg.sender, initialSupply);
    }
}

we have named our contract as “BalaToken” and it inherits from ERC20.

balatoken code

This is how your code should look like now.

3. Deploying Bep-20 Token in Binance Smart Chain:

We have wrote our code in remix IDE. Now, Let’s compile our code and deploy it.

1. Now select your compiler version and click on compile. The solidity compiler will compile the code and the success tick mark will appear in the left-sidebar icon.

remix ide compiler

2. Now, Let’s deploy it.

Select Environment as Injected Web3 and Select your contract_name.sol from the contract drop-down and Set your Initial Supply value like “10000”. Now, Click on Deploy button.

remix deploy contract

3. The Metamask wallet will open, Click on Confirm to confirm the transaction and you’ve successfully deployed bep-20 token in Binance Smart Chain.

transaction hash

Search your transaction hash in bscscan.com and you will find your contract address.

To Import your token in Metamask, Click on Import tokens, add your contract address to add your custom bep-20 token to the Metamask wallet.

I hope this article helped you to write and deploy bep-20 token in Binance Smart chain. Please do share it with your friends.

Share on:
Admin

Admin is a tech avid and digital marketer. He likes to write and share about apps, games, gadgets, smartphones and Tech Reviews. He is a Blogger, Half-Geek, Half-Nerd.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.