Advanced
How to Mirror BEP2 and BEP20 Tokens
In the world of blockchain and cryptocurrency, it is common for multiple networks and platforms to exist for the same token. For example, a token may have a BEP2 version on Binance Chain and a BEP20 version on Binance Smart Chain. Mirroring tokens, or having the same token represented on multiple chains, allows for greater flexibility and reach for the token’s users.
This tutorial will guide you through the process of mirroring BEP2 and BEP20 tokens. You will learn how to create a smart contract that can represent the token on both chains, and how to manage the token on each chain. Whether you are a token issuer, a developer, or a token holder, this tutorial will provide valuable information on how to effectively manage your tokens across different networks.
Pre-requisites
This BEP20 token is not bound to any BEP2 token
Motivation
Anyone can call the mirror
method to issue a BEP2 token automatically and bind them.
What Happens Under the Hood
Verify there is no pending mirror request
Check the total supply and token symbol is valid
Send a cross-chain package to issue a BEP2 token on Beacon Chain
The newly created BEP2 token is locked until the token holder sends cross-chain transfer
After binding, all liquid circulation is on BSC.
Fee Table
Fee Name |
Pay in BNB |
---|---|
mirrorFee |
it’s 10 BNB on mainnet now |
relayFee |
it’s 0.002BNB on mainnet now |
Both mirrorFee
and relayFee
can be changed by on-chain governance
To query mirrorFee
from the system contract;
Call Tokenmanager
Contract with the latest ABI
Query mirrorFee
function
Fee= result/1e18
To query relayFee
from system contract;
Call TokenHub
Contract with the latest ABI
Query getMiniRelayFee
function
Fee= result/1e18
Mirror With MyEtherWallet
Call Tokenmanager
Contract with the latest ABI
Select mirror
function and fill-in with your BEP20 address
The value here should be no less than mirrorFee
+ relayFee
.
Time stamp should be greater than unix_timestamp(now())
. The difference should be between 120 and 86400. It’s recommended to use unix_timestamp(now())+1000
All set!
Query BEP2 Token Symbol
You can query the BEP2 Token symbol from tokenhub
contract with the latest ABI
Select getBoundBep2Symbol
function to input BEP20 token contract address, then you can see the token symbol in the result.