当前位置:网站首页>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
边栏推荐
- Command - sudo
- 对普通bean进行Autowired字段注入
- The flyer realizes page Jump through routing routes
- Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
- 山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(五)
- Kibana reports an error server is not ready yet. Possible causes
- 山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(六)
- 一个简单的(基于redisson的)分布式同步工具类封装
- MySQL数据库 - 单表查询(三)
- 优先使用组合而不使用继承
猜你喜欢
Deep learning -- Summary of Feature Engineering
Using oes texture + glsurfaceview + JNI to realize player picture processing based on OpenGL es
Zero base to build profit taking away CPS platform official account
山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(七)
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
精简CUDA教程——CUDA Driver API
Grafana 分享带可变参数的链接
php参考手册String(7.2千字)
Prefer composition to inheritance
指针数组与数组指针的区分
随机推荐
LPC1768 关于延时Delay时间与不同等级的优化对比
Video understanding
Some speculation about the decline of adults' language learning ability
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.
MySQL syntax collation
Go modules daily use
Comment créer un pass BEP - 20 sur la chaîne BNB
An algorithm problem was encountered during the interview_ Find the mirrored word pairs in the dictionary
MFC obtains local IP (used more in network communication)
C学习完结
MySQL数据库 - 单表查询(三)
An example of using JNI to directly access surface data
ESP8266-入门第一篇
HTTP cache - HTTP authoritative guide Chapter VII
Encyclopedia of professional terms and abbreviations in communication engineering
山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(五)
Strange problems in FrameLayout view hierarchy
Kubernetes entry to mastery - bare metal loadbalance 80 443 port exposure precautions
指针数组与数组指针的区分
How about Bohai futures. Is it safe to open futures accounts?