How to build a BEP-20 Token – Detailed guide

How to build a BEP-20 Token – Detailed guide

If you have ever been curious about launching your very own token on the Binance Smart Chain, in that case, that specific token will need to follow what is known as the BEP-20 token standard.

Creating a token on the Binance Smart Chain might not be as difficult as you initially thought it would be, and today, we are going to go over just about everything that you need to know when it comes to building your very own BEP-20 token. Pay close attention to each step of the way, so you do not make any mistakes and can successfully build your own tokens.

How to Build a BEP-20 Token - Detailed Guide

Key Points:

  • BEP20 is the main token standard found within the Binance Smart Chain
  • It serves the role of a blueprint that each and every token needs to follow prior to getting deployed.
  • Any developer can build their own BEP20 tokens.
  • You can easily connect to a BSC node through the usage of NOWNodes.

What is BEP-20 Token?

Before we can discover how to create BEP20 token, we will need to go over what the token is first. BEP-20 is essentially a token standard that is specifically developed for the Binance Smart Chain, which is an extension of the ERC-20 token standard, a standard typically utilized within the Ethereum blockchain network. 

To truly understand what this means, you can essentially imagine this token standard as a blueprint for the token development process, which defines how a token can actually be spent, who gets to spend it, and specific rules that are tailored towards its usage.

What is BEP-20 Token?

If you are curious what does BEP20 mean, the BEP-20 token standard was developed as a technical specification for the Binance Smart Chain, with the main goal of ensuring that there is a flexible format through which developers can launch a range of different tokens, which can essentially represent anything, from shares within a specific business, to dollars which get stored within a bank such as stablecoins for example, and this list goes on.

Developers can create a native asset as a BEP-20 token as well, or peg tokens from other blockchains as a means of making them compatible as well as usable with the Binance Smart Chain.

Any transfer that occurs across different BEP-20 tokens is fueled through the usage of the BNB token, which incentivizes validators to include the transaction in the blockchain due to the fact that they can essentially collect the BNB tokens as a fee for their hard work.

BEP-20 Token

With all of this in mind, creating a BSC token is easy, and the tokens have to conform to a standard known as BEP-20, which is responsible for ensuring that there is a basic level of functionality for the token, which includes transfers, balances, viewing token ownership and so on. Hopefully, now you know a bit more about what is a BEP20 token.

That said, now that you know what is BEP20, we will now head over to developing a BEP-20 token as a means of teaching you everything that you need to know.

Coding the Token

A BEP-20 token requires specific functions within it as a means of enabling other accounts to interact with it properly. Specifically, you will find that many tokens have the ability to be minted and burned, transfer ownership of the token to a different address, or pause and play the token contract as an emergency stop mechanism. Let’s go over how to make a BEP20 token.

In order for you to be able to code a token, you will need specific things first, including:

Remix IDE

You will need to open Remix and create a new Token.sol file under /contracts. Ensure that it is open within the file editor. Now all you have to do is begin coding the BEP-20 token. This is how you begin the process to create a BEP20 token.

To do this, you will first need to declare a license, and the version of Solidity in the token is written. For the purposes of this guide, we will be using the latest version. As such, here is the code that you will need to answer:

How to create BEP-20

You can then create a new contract declaration which is called a token.

How to create BEP-20

Within this next step, you will need to initialize the variables and events which are required to implement the BEP-20 token standard.

How to create BEP-20

The variables essentially share the same name as some functions; as in Solidity v0.8 or over, public variables will automatically generate getter functions.

Here is a list of the functions that are available to you automatically:

  • name()
  • symbol()
  • decimals()
  • totalSupply()
  • owner()
  • balanceOf()
  • allowance()

You can then define the constructor of the token contract, which includes details such as the name, symbol, and a specified number of tokens, after which you can transfer them to the owner of the token.

How to create BEP-20

Here, functions can be defined which are not automatically generated. 

First, getOwner() returns the address of the owner of the BEP-20 token.

How to build BEP-20 token

Now, transfer(address _to, uint256 _value) transfers a specified amount of tokens to an address.

How to build BEP-20 token

And then, transferFrom(address _from, address _to, uint256 _value) transfers a specified amount of tokens from one address to another.

How to build BEP-20 token

There is also approve(address _spender, uint256 _value) which essentially allows an account (_spender) to withdraw from another account multiple times, up to the specified amount (_value).

How to build BEP-20 token

You can increase the total supply of the token with the following code:

How to build BEP-20 token

When it comes to burning tokens, burn(uint256 _amount) allows a token holder to burn (i.e., destroy) a specified amount of existing tokens.

How to build BEP-20 token

Now we can move on toward deploying the token.

How to deploy the token?

You can easily deploy the token through the usage of Remix. You will now learn how to get BEP20 on MetaMask.  Before you get started, you will, however, need a browser with MetaMask installed so you can sign the transaction of deploying the token contract through Remix and as a means of interacting with the token.

Additionally, you will also need BNB as a means of paying for the costs associated with deploying the new contract.

  1. Open Remix and create a new contract file.
  2. On the left sidebar, click on the Solidity compiler and click on “Compile Token.sol”.
  3. Click on Deploy and Run Transactions.
  4. Set the ENVIRONMENT to Inject Web3. 
  5. Confirm the MetaMask prompt for the transaction. 
  6. Click on the Deploy button, and confirm once more where you will be able to see the contracts under the Deployed Contracts Section now.

That’s everything you need to know. Remember to copy the address of the deployed contract, as you will need it in order to publish it.

How to deploy the token?

Verifying and publishing the BEP-20 token

Once the token has been deployed from your end on a public network, you will need to publish it. You can do so on BscScan

This is essentially the tool that will allow you to view transactions that are occurring within the BSC network. When you verify the source code, you make your token a lot more legitimate due to the fact that everyone can see what’s happening with it.

  1. Navigate to the homepage and visit the BscScan mainnet if you deployed there or the BscScan testnet if you deployed there.
  2. You will now need to paste the address of the deployed contract that you copied previously.
  3. You will need to review the details of the token, after which you can click on the Contract tab below the token details.
  4. Here, you will need to Verify and Publish, after which you will need to fill in the form.
  5. Ensure that the compiler version is the same as the one used in Remix, and the license field is also set to the same as in the source code. After his, click on Continue.
  6. You will now be able to see an input box to paste in the contract smart code; here, you can copy the source code from the Remix editor, paste it into the box, and Verify and Publish.

That is everything you need to know about deploying and verifying the token on BsScan. You can now import the token in MetaMask and make transactions with it easily, so let’s dive into that next.

Importing BEP-20 into MetaMask

Importing BEP-20 into MetaMask

By this point, we assume that you have already deployed the token contract on a public network. Now all you have to do is interact with MetaMask.

  1. Open MetaMask and ensure that you are connected to the Binance Smart Chain network first.
  2. Make sure that you are using the same account as the one that you used to deploy the token contract, and ensure that you are on the Assets tab, after which you can click on Import Tokens.
  3. You will now need to paste the deployed token contract address, and MetaMask will be able to read the token symbol alongside the decimals automatically.
  4. You can now click on Add Custom Token, after which you can confirm the operation by clicking on Import Token.

How to run BSC node? 

If you want to stay connected to the Binance Smart Chain and get data about each transaction, such as the block height, for example, you can utilize a Binance Smart Chain node, otherwise known for short as a BSC node.

NOWNodes is essentially a blockchain-as-a-service provider that will enable you to easily connect with over 40 nodes, one of which is the BSC node.

All you have to do is navigate to the official website, and enter your email address, after which you can get an API key.

Then, once you are in possession of the free API key, you can navigate over to the official documentation in order to get the code through which you can connect.

For example, on the BSC, if you want to see the current status of the blockbook and connected backend, you can utilize this code:

How to run BSC node?

The response will look something like this:

How to run BSC node?

Hopefully, now you know a bit more about connecting to a BSC node through the utilization of NOWNodes.

Frequently Asked Questions (FAQs)

Do you need a MetaMask wallet in order to launch a BEP-20 token?

Yes, you will be required to have a MetaMask wallet as a means of signing the transactions.

Are you required to have BNB tokens in order to deploy a new contract?

You will need some BNB tokens in order to deploy to the testnet as well as the mainnet. While on the mainnet, you will need to buy BNB tokens; on the testnet, you can head over to the BSC testnet faucet and request some funds using the account which was set up throughout the setup procedure.

Binance smart chain faucet


Hopefully, now you have a heightened perspective as well as a heightened level of understanding when it comes to building your own BEP-20 token on top of the Binance Smart Chain.

Remember that by following each of these steps, you can get your token up and live in no time. By using NOWNodes, you can also easily deploy to a BSC node.