当前位置:网站首页>How to create bep-20 pass on BNB chain
How to create bep-20 pass on BNB chain
2022-04-23 19:41:00 【Chainlink information】

BEP-20 Pass is in BNB Chain On the basis of trading . In this tutorial , You will learn how to create a BEP-20 Pass and deploy to BNB Chain.
What is? BEP-20 Pass card ?
BEP-20 yes BNB Chain A kind of pass standard on , It's based on ERC-20 Standard framework establishment .BEP-20 and ERC-20 Standards are used to create homogeneous certificates of exchange . Homogenization means that you only need to care about its quantity – They are not unique . Fiat money is a good example . You don't need to care which dollar you have , But how many . Non homogeneous items are not interchangeable , What you care about is which one you have .
What is? BNB Chain?
BNB Chain Is based on Go Ethereum agreement (Geth) Hard bifurcations of , Or permanent bifurcation . Although it is similar to Ethereum , But there are some obvious differences .
The most obvious difference is BNB Chain Different consensus mechanisms are used .BNB Chain Used 21 A verifier , They take turns producing blocks . These verifiers are held by BNB(BNB Chain Original pass ) Our client supports . This consensus mechanism is called proof of interest (PoSA). The verifier is selected according to the mortgage amount , front 21 Candidates were selected as verifiers .
BNB Chain The advantages of
because BNB Chain It's through Geth Created by the bifurcation of , It is related to EVM Compatible network . That means you can be in BNB Chain The upper part is related to Ethereum On the same contract . As a proof of interest network ,BNB Chain There are different trade-offs with Ethereum . This forms the advantage of some specific use cases . It is worth noting that ,BNB Chain The speed is relatively fast , Lower cost , This has attracted developers' attention to the network .
Bridge assets to BNB Chain
How to transfer your assets from Ethereum main chain to BNB Chain?
To transfer assets from Ethereum to BNB Chain, have access to Coin on bridge . It's a contract , It will keep your assets on the Ethereum chain , And after a little delay , stay BNB Chain Create a version of the asset .
It's a little like money in arcade games . You put your money (ETH) Give it to the employees of the video game city ( Bridge contract ), In turn, , They create game currency (ETH BEP-20,ETH Of BEP-20 edition ), On the arcade (BNB Chain) Internal use . You can use game currency in the arcade (ETH BEP-20). If you want to quit , You can put your game currency (ETH BEP-20) Return to employees ( Bridge contract ), They will destroy or burn game coins (ETH BEP-20). Then they will put the game currency (ETH BEP-20) The money (ETH) return to you .
What do you need? ?
stay BNB Chain On the development , Need and in any EVM Compatible with the same tools developed on the chain . This is the use of EVM The benefits of the compatibility chain . Usually they all support the same tool .
In this tutorial , We will use :
● Remix– One is based on Web Of Solidity Integrated development environment
● Brave wallet – One One is similar to Metamask Cryptocurrency wallet
● BNB Chain Test net – BNB Chain The test network
● Coin faucet – Get test network BNB
● OpenZeppelin– Security standards for blockchain contracts
Connect to BNB Chain Testnet
stay BNB Chain Test before building an application on the web , Wallet needs to be set . A good tool is Chainlist, It allows you to simply connect your wallet and add chains from there ( You need first. Set Wallet .) You can add the details of the chain yourself in file Find .
Network Name: Binance Testnet
New RPC URL: https://bsc-dataseed.binance.org/
ChainID: 97
Symbol: BNB
Block Explorer URL: https://testnet.bscscan.com
Get the test network BNB
BNB Chain The original pass of the test network is BNB. For deployment and interaction with contracts , We need to get some BNB. Go to Binance water tap Get some test networks BNB. Need to provide your wallet address , And click the “ Give me a BNB”.

Build contracts
First, go to Remix Integrated development environment .
Now you can ignore the sample contract .

Create a new contract in the contract Directory .

And named it BSCCoin.sol.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC-20/ERC-20.sol";
contract BSCCoin is ERC-20 {
constructor(uint256 initialSupply) ERC-20("BSCCoin", "BSCC") {
_mint(msg.sender, initialSupply);
}
}
Let's take a look at this code .
First , We define what we will use Solidity Version of .
pragma solidity ^0.8.2;
This is a OpenZeppelin Basic ERC-20 Pass card . We import it into our contract . Creating BEP-20 Pass time , Remember that they are related to ERC-20 The pass is very similar . therefore , We can use OpenZeppelin Of ERC-20 Contract to create our pass .
import "@openzeppelin/contracts/token/ERC-20/ERC-20.sol";
May refer to OpenZeppelin Of course Getting started page Learn more about .
Use OpenZeppelin Our contract means that our contract can be simpler . We inherited ERC-20 Contract and use it to create our BEP-20 Pass card .
// Define our contract and inherit the ERC-20 contract
contract BSCCoin is ERC-20 {
// When the contract is run create a BEP-20 Token
// The token will be names "BSCCoin"
// The token will have the symbol "BSCC"
constructor(uint256 initialSupply) ERC-20("BSCCoin", "BSCC") {
// Create an initial value for the runner of the contract
_mint(msg.sender, initialSupply * 10 ** decimals());
}
}
Description of decimals
This means that when you want to use decimals , You need to use fixed-point operations . You need to store a fixed number of decimals in the value . In this case ,digimals() Set to 18, That means we have to use 10^18 Multiply by the number of passes we cast .
Deploy
With this contract , You have a fully functional BEP-20 Pass card ! Now it's time to deploy it to BNB Chain Test the network .
First , Change the environment to “Injected Web3”. This will enable Remix Be able to interact with blockchain through your wallet .

Next , Make sure you deploy the right contract . In this case, yes “BSCCoin”.

Specify the number of passes to create , And then click “ Deploy ” Button , You should see a confirmation button . We are deploying the contract to a running blockchain . therefore , It will involve gas cost .


The contract may take some time to complete the deployment . Once that is done , Will you be in “ Deployed contracts ” See it next . You can see all the functions available in the contract . These functions are from OpenZeppelin Imported from the contract .

verification
Once the contract is deployed , We can carefully check whether it is displayed in BNB Chain In the test network .
Copy the address of the contract , Then go to BNB Chain browser .

Enter the contract address and search it .
You can see the contract and pass .

congratulations , You just successfully deployed a BEP-20 Pass to BNB Chain In the test network .
What to do next
So let's start here , You can deploy your pass to BNB Chain Main network , Or you can add more features to it .OpenZeppelin The contract supports additional casting 、 The destruction 、 Voting and other functions . You can see OpenZeppelin file Learn the full details .
Now you know how to create a BEP-20 Pass card , Many new opportunities are open to you . You can use it to communicate with DeFi Application interaction , Create a governance agreement , Or start a Chainlink Price Feed To track its price .
You can also check out the complete Video tutorial , Learn how to BNB Chain Create a BEP-20 Pass card .
Get more about Chainlink Information about , Please visit chain.link Or in the docs.chain.link Read the document . To discuss integration , Please contact an expert .
版权声明
本文为[Chainlink information]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231928494297.html
边栏推荐
- Summary of several relationships of UML class diagram
- Strange passion
- 如何在BNB鏈上創建BEP-20通證
- Speculation on the way to realize the smooth drag preview of video editing software
- 精简CUDA教程——CUDA Driver API
- Devops integration - environment variables and building tools of Jenkins service
- antd dropdown + modal + textarea导致的textarea光标不可被键盘控制问题
- FFT物理意义: 1024点FFT就是1024个实数,实际进入fft的输入是1024个复数(虚部为0),输出也是1024个复数,有效的数据是前512个复数
- Esp8266 - beginner level Chapter 1
- [报告] Microsoft :Application of deep learning methods in speech enhancement
猜你喜欢

Prefer composition to inheritance

Audio signal processing and coding - 2.5.3 the discrete cosine transform

Matlab 2019 installation of deep learning toolbox model for googlenet network

RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`

Lottery applet, mother no longer have to worry about who does the dishes (assign tasks), so easy

First experience of using fluent canvas

【webrtc】Add x264 encoder for CEF/Chromium

优先使用组合而不使用继承

Using oes texture + glsurfaceview + JNI to realize player picture processing based on OpenGL es

Intuitive understanding of the essence of two-dimensional rotation
随机推荐
Use of fluent custom fonts and pictures
MySQL数据库 - 数据库和表的基本操作(二)
高效的串口循环Buffer接收处理思路及代码2
MySQL syntax collation (3)
Efficient serial port cyclic buffer receiving processing idea and code 2
IIS数据转换问题16bit转24bit
如何在BNB链上创建BEP-20通证
MySQL数据库 - 单表查询(二)
Audio editing generation software
Kubernetes introduction to mastery - ktconnect (full name: kubernetes toolkit connect) is a small tool based on kubernetes environment to improve the efficiency of local test joint debugging.
php参考手册String(7.2千字)
The usage of slice and the difference between slice and array
[H264] hevc H264 parsing and frame rate setting of the old version of libvlc
【webrtc】Add x264 encoder for CEF/Chromium
Core concepts of rest
MFCC: Mel频率倒谱系数计算感知频率和实际频率转换
A simple (redisson based) distributed synchronization tool class encapsulation
如何在BNB鏈上創建BEP-20通證
[transfer] summary of new features of js-es6 (one picture)
Machine learning catalog