Binance became one of the earliest and most well-known DeFi ecosystems in cryptocurrency in 2022 when it rebranded both Binance Chain (BEP2) and Binance Smart Chain (BEP20) as BNB Chain. One of the most widely used blockchains recently was Binance’s layer-1 blockchain, which competed with Ethereum.
What Exactly Are BEP-20 Tokens?
A BNB Chain token standard called BEP-20 builds on the groundwork already out by the ERC-20 standard. Tokens created in accordance with the BEP-20 and ERC-20 standards are fungible and exchangeable. Products that are fungible are ones that you are concerned about the quantity of since they are not unique. Fiat currency is a prime example: the important factor is how many dollars you have rather than which ones. Products that are non-fungible cannot be traded. You are worried about which one you have.
What is BNB Chain?
BNB Chain (Geth) was created as a result of a hard fork, or permanent divergence, of the Go Ethereum protocol. Although it and Ethereum are relatively similar, there are several significant differences.
The main difference is the alternative consensus algorithm used by BNB Chain. BNB Chain uses 21 validators, each of whom generates a block. Delegators who stake BNB, the native token of BNB Chain, support these validators. This consensus procedure is known as Proof of Staked Authority (PoSA). Depending on the amount wagered, the top 21 candidates are chosen to serve as validators.
Benefits of a BNB Chain
Because the BNB Chain chain is a fork of Geth, it is EVM-compatible. This implies that you can use the same contracts on BNB Chain that you can on Ethereum. BNB Chain, being a PoSA network, offers distinct trade-offs than Ethereum. This has various advantages for certain usage situations. Notably, BNB Chain is quick and cheap, which draws developers to the network.
Bridge Assets to the BNB Chain
How can you transfer assets from Ethereum’s main chain to the BNB Chain?
To move assets from Ethereum to BNB Chain, you must use the Binance Bridge. This is a contract that will take custody of your Ethereum assets and, after a short wait, produce a Binance counterpart of that asset.
Consider this to be similar to using tokens in an arcade. You hand over your money (ETH) to the arcade employee (bridge contract), and they produce tokens (ETH BEP-20, a BEP-20 variant of ETH) for usage within the arcade (BNB Chain). You may then utilize the tokens (ETH BEP-20) while in the arcade. If you want to quit, you can return your tokens (ETH BEP-20) to the employee (bridge contract), who will destroy or burn the tokens (ETH BEP-20). Then they’ll refund your money (ETH) for the tokens (ETH BEP-20).
What You’ll Require
To begin developing on BNB Chain, you’ll need the same tools as you would for any EVM-compatible chain. That is one of the benefits of utilizing EVM-compatible chains: they frequently support the same tools. We will be utilizing the following tools for this tutorial:
- A web-based solidity IDE called Remix
- Brave Wallet, a cryptocurrency wallet comparable to Metamask
- BNB Chain Testnet—The BNB Chain testing network.
- Gain test net BNB using the Binance Faucet.
- A safe blockchain contract standard called OpenZeppelin
Connect to BNB Chain Testnet
Before you can start building an application on BNB Chain testnet, you’ll need to set up your wallet. A great tool for this is Chainlist, which allows you to simply connect your wallet and add chains from there (you will need to setup your wallet first.) The details for adding the chain yourself can be found in the Binance Docs.
- Network Name:Â Binance Testnet
- New RPC URL:Â https://bsc-dataseed.binance.org/
- ChainID:Â 97
- Symbol:Â BNB
- Block Explorer URL:Â https://testnet.bscscan.com
Obtain Testnet BNB
The BNB Chain testnet’s native token is BNB. We’ll need some contracts to deploy and interact with. To obtain some testnet BNB, go to the Binance Faucet. You must enter your wallet address and then click “Give me BNB.”
Creating the Contract
Head over to the Remix IDE to get started, then in the contracts directory, create a new contract.
Name it BSCCoin.sol
Take a look at this code.
First, we identify the Solidity version we will be utilizing.
From OpenZeppelin, this is the fundamental ERC-20 coin. We include that in our contract. Remember that BEP-20 tokens are quite similar to ERC-20 tokens when establishing one. As a result, we may use the OpenZeppelin ERC-20 contract to create the coin.
For additional information, see their getting started page.
Because we are using OpenZeppelin contracts, our contract may be lot easier. We use the ERC-20 contract that we inherited to produce our BEP-20 coin.
A Word About Decimals
Solidity does not employ decimals. This means that if you want to utilize less than whole integers, you must use fixed-point arithmetic. A set number of decimals must be stored in the value. Decimals() is set to 18 in this example, which implies we are increasing the amount of tokens we mint by 1018.
Utilizing
You now have a fully working BEP-20 token as a result of this contract! It is now time to deploy it to the BNB Chain testnet.
First, set the Environment to “Injected Web3,” which will allow Remix to interface with the blockchain through your wallet.
Next, confirm that you are using the right contract. In this case, it’s “BSCCoin.”
Select the quantity of tokens to produce, then click the “Deploy” button. A confirmation button should appear. We are now deploying to a live blockchain. As a result, there will be a gas cost.
The contract may take some time to completely deploy. Once it is, you will see it under “deployed contracts,” where you will be able to examine all of the contract’s functions. The OpenZeppelin contract was used to import these functions.
We may double-check if the contract is visible on the BNB Chain testnet once it has been deployed.
Make a note of the contract address and go to BNB ChainScan.
Search for it by entering the contract address. The token and contract should be visible.
you’ve just deployed a BEP-20 token to the BNB Chain testnet.
What information is contained in a BNB Chain Wallet address?
You should be aware of three highly significant facts about a BNB Chain Wallet:
When sending assets to the BNB Chain wallet, a string of numbers and characters is known as a wallet address. Through the wallet address you specify, others can send money to you. The following is the format of a BNB Chain (BNB BEP20) wallet address: 0x859AA4525c19829034CbbFD916F46c068F116310
An encryption key that may be used as a password and contains any 12 English words. The Passphrase login step must be completed in order to execute the wallet recovery process. Password formats include: task, estate tube, ear decade, stone trick, army gray, wonderful net bottle.
Quite similar to a bank account password, a private key is a combination of letters and numbers that is used to connect to an account. The structure of a private key is 0x3b0c8dd07372e32a5eb89b2c74996d6daad56cc8a40bc7eaa418b5d5630623b1.
In order to understand, think of the BNB Chain Wallet as a bank account, with the account number being the wallet address and the password representing the passphrase/private key.
The distinction here is that with a bank account, others will have access to your personal information. In the case of the BNB Chain Wallet, the user becomes anonymous; no one knows who owns the wallet, and transactions are only possible via the address, which is encoded into a series of numbers and letters.
You could either proceed to the BNB Chain mainnet from here with your token or you could give it further features. The OpenZeppelin contracts allow for extra minting, burning, voting, and other features. For further information, see the OpenZeppelin documentation.
Many new options await you now that you understand how to manufacture a BEP-20 coin. It might be used to interface with DeFi apps, to develop a governance protocol, or to start a Chainlink Pricing Feed to monitor its price.