当前位置:网站首页>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
边栏推荐
- Go modules daily use
- C学习完结
- Deep learning -- Summary of Feature Engineering
- Kubernetes entry to mastery - bare metal loadbalance 80 443 port exposure precautions
- 深度分析数据恢复原理——那些数据可以恢复那些不可以数据恢复软件
- goroutine
- UML类图几种关系的总结
- Kubernetes getting started to proficient - install openelb on kubernetes
- 2021-2022-2 ACM training team weekly Programming Competition (8) problem solution
- 2021-2022-2 ACM集训队每周程序设计竞赛(8)题解
猜你喜欢

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.

2021-2022-2 ACM training team weekly Programming Competition (8) problem solution

The platinum library cannot search the debug process records of some projection devices

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

JVM的类加载过程

Class loading process of JVM

Physical meaning of FFT: 1024 point FFT is 1024 real numbers. The actual input to FFT is 1024 complex numbers (imaginary part is 0), and the output is also 1024 complex numbers. The effective data is

Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies

指针数组与数组指针的区分

RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
随机推荐
Zero cost, zero foundation, build profitable film and television applet
Codeworks round 783 (Div. 2) d problem solution
How to uninstall easyton
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
Using oes texture + glsurfaceview + JNI to realize player picture processing based on OpenGL es
MySQL数据库 - 数据库和表的基本操作(二)
Redis core technology and practice 1 - start with building a simple key value database simplekv
Application of DCT transform
高效的串口循环Buffer接收处理思路及代码2
Inject Autowired fields into ordinary beans
SQL of contention for system time plus time in ocrale database
Go modules daily use
MySQL数据库 - 单表查询(一)
Shanda Wangan shooting range experimental platform project - personal record (IV)
5 minutes to achieve wechat cloud applet payment function (including source code)
优先使用组合而不使用继承
Encyclopedia of professional terms and abbreviations in communication engineering
MFCC: Mel频率倒谱系数计算感知频率和实际频率转换
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
Translation of audio signal processing and coding: Preface