This page may contain legacy content

To get our most up-to-date content please access our documentation

October 2, 2021

BEP20 Testnet – Create a BEP20 Token in 15 Mins

Table of Contents

Tokens are some of the most high-profile expressions of blockchain technology. However, the different types of tokens can vary wildly – from NFTs (non-fungible tokens) to alternatives like ERC20, BEP20, or BEP2 tokens. Furthermore, even though tokens are such dynamic features of Web3 development, they are actually relatively easy to create – at least with proper tools. Nevertheless, this process is still a mystery to many, and for this reason, we are going to take the time to dive deeper into the process of creating tokens. More specifically, we will dedicate this article to taking a closer look at how you can create a BEP20 token on the BEP20 testnet in just 15 minutes with the help of Moralis!

With Moralis and its powerful platform, we can create a BEP20 token for Binance Smart Chain’s BEP20 testnet in record time. Furthermore, one of Moralis’ valuable tools we’ll utilize in this guide is Moralis Speedy Nodes. This service provides all users with some of the quickest and most reliable nodes on the market. Moreover, since we’ll be using Moralis when creating a BEP20 token and launching it on the BSC BEP20 testnet, the first thing you need to do is sign up with Moralis. It only takes a couple of seconds, and joining is completely free! 

In addition, prior experience of working with Solidity, Remix, and MetaMask will be beneficial for this tutorial. However, that experience is not a necessity to follow along as we take you through the complete process of creating a BEP20 token step by step. 

How to Create a BEP20 Token on the BEP20 Testnet

Creating a BEP20 token on the BEP20 testnet is a straightforward process when using Moralis. Furthermore, as a platform user, you don’t even need to be a developer to follow along and create your own BEP20 token, and you’ll be able to do so in just about 15 minutes. So, if you’re interested in learning how to create a BEP20 token, then continue reading, and we’ll take you through the complete process! 

However, before we create the BEP20 token itself, we’re first going to provide you with a better understanding of BSC and also the BEP20 token standard. Following this, we’ll also make a few preparations necessary for deploying the BEP20 token to BSC’s testnet. These preparations are as follows: 

  1. Acquiring an RPC node.
  2. Add the node to MetaMask.
  3. Acquire some BNB.

Moreover, completing these three preparations only takes a couple of minutes, and as soon as they are complete, we’re going to start coding the BEP20 token contract right away. Furthermore, once we complete the contract, we’ll also explain how to deploy the token to the BEP20 testnet on BSC. Moreover, if you’re interested in learning more about BSC development, then Moralis’ blog provides a great guide on how to create BSC tokens. In addition, for those wanting an intro to BSC programming, check out the following article from Moralis covering BSC programming.
 

If you’d rather watch a video of the token creation process, then check out the following video from Moralis’ YouTube channel where we create a BEP20 token from scratch: 

https://www.youtube.com/watch?v=h4gQD7R1r94&t=3s

However, let’s start this tutorial by diving deeper into what BSC is and what the BEP20 standard denotes. 

Binance Smart Chain and BEP20 Tokens

BSC is an abbreviation for “Binance Smart Chain”, and BSC is one of two components of Binance’s ecosystem. BSC is often mixed up with the original “Binance Chain”; however, they are two separate things. Binance Chain was first introduced in 2019, and the primary function of this chain was to facilitate fast and efficient trading. As the chain focused solely on facilitating fast transactions, it lacked flexibility, making it unfit for Web3 development. 

As the original chain was unfit for more complex transactions, Binance solved this issue by introducing a second chain more adapted to enable blockchain programming. This meant that the ecosystem expanded with the introduction of smart contracts. This means that the two chains now run parallel with one another, one facilitating trading as the other allows for smart contract development.

Binance’s ecosystem utilizes something known as ”dual-chain” architecture. This is an essential piece of technology as it allows seamless transfers from one of the chains to the other. This means that users can conveniently allocate their funds to where they are needed, enabling the ecosystem to function more smoothly.

You might have stumbled upon the ERC20 standard previously, which is the fungible token standard for Ethereum. This standard is there to regulate tokens, ensuring that, for example, it is possible to trade them, set an initial amount, etc. 

Furthermore, as ERC20 is the standard for Ethereum, BEP20 and BEP2 are the standards for Binance’s ecosystem. The BEP20 standard regulates BSC tokens as BEP2 is the native standard for Binance Chain. Moreover, the BEP20 standard doesn’t differ significantly from ERC20, meaning they are quite similar with minor differences. 

How to Create a BEP20 Token: Getting Started

Now that we better understand BSC and also what BEP20 tokens are, we can look at the necessary preparations before creating the token itself. So, we’re first going to need a working RPC node as we need to change our MetaMask network to BSC’s testnet. Unfortunately, BSC’s testnet is not one of the default networks of MetaMask; however, this is exactly why we need Moralis Speedy Nodes. 

Furthermore, along with changing the MetaMask network, we must also acquire some BNB for the testnet as we need to pay a fee for deploying tokens to the network. However, as we’ll deploy the contract to the BEP20 testnet, it is possible to acquire BNB for free. 

Nonetheless, let’s look closer at how you can utilize Moralis to get a fully functioning BSC testnet node!

Acquiring a BEP20 Testnet Node

So, first things first, we’re going to need a node to change the MetaMask network to BSC’s testnet. The best and most efficient way of acquiring a node is to use the Speedy Nodes service provided by Moralis. This will give you some of the quickest, most reliable nodes on the market that we can use to deploy the BEP20 token to the testnet. 

If you haven’t already, the first step is to sign up with Moralis. Once you have an account, you can navigate yourself to the Moralis admin panel and then click the ”Speedy Nodes” tab. Clicking this tab will provide a few different alternatives for you to select from, but since we’re building a BEP20 token, you’ll want to choose “BSC Network”.

To get a hold of the node, you need to click the ”Endpoints” button, that’ll supply you with several URLs. Each URL is a node, and since we’re going to be deploying the token to the testnet, you can simply go ahead and copy the testnet URL and keep it for the next step where we will connect to the BSC node.

Change MetaMask Network

With the node information at hand, the next step is to navigate to the MetaMask interface, where we’ll add BSC’s BEP20 testnet to our account. To change networks, all you need to do is click the ”Networks” tab at the top of the interface. This will provide a drop-down menu with various alternatives. As you’ll notice, BSC’s testnet won’t be there by default. As such, we will select the ”Custom RPC” alternative as this will allow us to add the network using the node we acquired earlier.

This will provide a new window where you’ll need to add the following information: 

  • Network Name: BSC Testnet
  • New RPC URL: ”Input Moralis Speedy Node URL
  • Chain ID: 97
  • Currency Symbol: BNB
  • Block Explorer URL: https://testnet.bscscan.com

With all the information filled in, you can simply click ”Save”, and the network will be added to your list. Now, all that remains is to ensure that you click the ”Networks” tab again and select ”BSC Testnet”. 

Acquire BNB

Next up, we’re going to acquire some BNB which is really simple. All you need to do is visit the following website ”https://testnet.binance.org/faucet-smart“. As you can see, there is an input field where you’ll need to input your address. To get your wallet address, you can go back to the MetaMask interface and simply copy the address, which you’ll find below the ”Networks” tab. Once you have copied the address, you need to paste it into the faucet and press the ”Give me BNB” option. 

How to Create a BEP20 Token

Now, with all the preparations complete, we can move on and take a closer look at how we can actually create a BEP20 token and launch it on BSC’s testnet. Creating a BEP20 token is an effortless process, and it is quite similar to creating an ERC20 token. For this reason, we can use several tools used in Ethereum development when we create tokens for BSC’s BEP20 testnet. 

So, for example, we are going to be using Solidity to code our contract. Furthermore, we’ll also be using Remix as the development environment and utilize a template from OpenZeppelin. However, we can go ahead and start the process by creating a new contract. 

Creating a Contract File

So, since we’ll be using Remix when developing the token contract, you first need to visit the Remix website. With the web application opened, you can see a default workspace to the left of your interface. This will have an already developed structure with folders such as ”contracts”, ”scripts”, etc. To create a new contract, you can simply left-click on the contracts folder and select ”New File”. You can name the contract whatever you want, but preferably something that has to do with the token you are about to create. 

OpenZeppelin

One of the advantages of working with blockchain and a decentralized system is the ability to copy-paste code. As most software is open source, we can utilize already written code in the form of templates. Furthermore, this code has already been tested, meaning that everything is working as intended. 

As such, we’ll use a token template provided by OpenZeppelin. As ERC20 and BEP20 tokens are similar, we are, in this example, going to be using an ERC20 template since it’ll work perfectly for our token. Now, we’ve conveniently fetched the template from OpenZeppelin for you, and the code looks like the following: 

// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract GLDToken is ERC20 {
  constructor(uint256 initialSupply) ERC20("Gold", "GLD") {
    _mint(msg.sender, initialSupply);
  }
}

Coding the Contract

We can now continue by copying and pasting the code into our smart contract file. However, we won’t leave the code as-is; we need to make a few minor adjustments to customize the code to our preferences. 

The first essential line in our code is the pragma line. This line specifies which version of Solidity we are using, and it will be important when we compile the contract later on. Following the pragma line, we import the proper OpenZeppelin contract that the token contract, in turn, will inherit from. 

After this, we introduce the contract itself into the code, which is, in the case of the template, named ”GLDToken”. However, we can go ahead and change the name to whatever we would like. Following the name of the contract, we also include ”is ERC20”, which specifies that our contract will inherit from the imported OpenZeppelin package. 

Within the curly braces of the contract, two constructors exist. For the first one, we can remove ”initialSupply”, leaving the parenthesis empty. The second one specifies the name and the currency symbol of the token. As such, you can go ahead and change ”Gold” and ”GLD” to whatever you’d like. 

Within the curly braces following the constructors, we have the ”_mint()” function. ”msg.sender” means that the tokens will be given to the address deploying the contract. Following this line, we also have the initial supply, and unfortunately, we can’t simply write a number here as we need to consider the decimals. You can remove ”initialSupply” and replace it with, for example, ”100 * (10 ** uint256(decimals())))”. This means that once the contract is deployed, 100 tokens will be minted. As such, you can change ”100” to how many tokens you’d like to mint. Furthermore, here is the code from the example: 

The Contract Code:

// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract tokenName is ERC20 {
  constructor() ERC20("tokenName", "currencySymbol") {
    _mint(msg.sender, 100 * (10 ** uint256(decimals())));
  }
}

Compiling and Deploying the Contract

With the finalized code, we can continue the process by compiling the contract. As we are using Remix, this process becomes relatively easy. All we need to do is navigate ourselves to the ”Solidity Compiler” tab at the top left of the Remix interface. 

With the tab opened, all that remains is to select the correct compiler version, which should match the one specified in the pragma line. After this, you’ll also need to ensure that the valid file is selected, and you can then click the ”Compile” button. 

With the contract compiled, we can move on to the next tab just below ”Solidity Compiler” in the navigation bar. This is the tab for deploying the contract, and deploying is pretty straightforward. All you need to do is ensure that the environment is selected to ”Injected Web3” and that your MetaMask is set to the correct network. Then, all that remains is to select the contract and click the ”Deploy” button. 

How to Create a BEP20 Token: Viewing the Token

Now that the token is deployed to BSC’s testnet, we can go ahead and add the token to our MetaMask wallet. Once the transaction is completed, you can click the ”Activity” tab in your wallet, and this will present you with all the latest activities. Here you’ll find the newest transactions, one of which will be the deployment of the contract. 

You can then click on the transaction, which will open a smaller window with various details regarding the event. From here, you can click the little arrow at the top right, which will take you to the “BscScan” website for the testnet, where more information is provided. 

From the table on the website, you’ll want to copy the ”Interacted With (To)” address and go back to MetaMask. 

Once back at the interface, you can click the ”Assets” tab and then ”Add Token”. Now, all that remains is to input the address into the first field, and the other information will automatically fill in. Then you can click ”Next”, which will add the token to your wallet. 

That’s it; you’ve now successfully created a new token and added it to your own MetaMask wallet! 

How to Create a BEP20 Token on the BEP20 Testnet — Summary

With the power of Moralis, we were able to create a BEP20 token for the testnet in less than 15 minutes. With the tools of the platform, we broke down the process into five simple steps: 

  1. Making a few preparations.
  2. Creating a Remix contract file.
  3. Importing an OpenZeppelin template.
  4. Coding the contract.
  5. Compiling and deploying the contract.

By following these five steps, we created the BEP20 token and also added it to our MetaMask wallet easily and quickly. As such, this showcases the strength of Moralis; however, this is far from the limits of the platform. With Moralis, it is possible to do everything from creating a DEX to building ETH dApps, and much more!

Furthermore, the platform offers additional valuable tools for development such as the Moralis Price API, the NFT API, native support for IPFS, etc. So, if you want to develop dApps or additional tokens, sign up with Moralis right away! Signing up is completely free, and it will only take you a couple of seconds to get going with Web3 development. 

Moralis Money
Stay ahead of the markets with real-time, on-chain data insights. Inform your trades with true market alpha!
Moralis Money
Related Articles
October 5, 2023

Identify NFT and ERC-20 Spam and Scam Tokens

November 14, 2022

How to Get All NFTs from a Collection in 3 Steps

November 30, 2023

The Biggest and Most Popular Blockchains for Developers

November 27, 2022

Blockchain Infrastructure Companies – How to Choose the Right Provider

January 22, 2023

Complete Tutorial on How to Create an ERC721 Token

January 22, 2024

Full Guide – The Ethereum Ecosystem in 2024