Advanced

 

How to Sync BEP2 and BEP20 Supply

Binance Smart Chain (BSC) has become one of the most popular blockchain networks in recent years due to its fast transaction times, low gas fees, and compatibility with Ethereum-based applications. BEP2 and BEP20 tokens are the native token standards on BSC and are widely used for various purposes such as fundraising, asset management, and decentralized finance (DeFi) applications.

Keeping the supply of BEP2 and BEP20 tokens in sync is crucial for ensuring the accurate representation of assets on the BSC network. In this tutorial, we will walk you through the steps of syncing the supply of BEP2 and BEP20 tokens on the Binance Smart Chain. We will cover everything from setting up the necessary tools and interfaces to executing the sync process in a smooth and efficient manner. By the end of this tutorial, you will have a clear understanding of how to keep your BEP2 and BEP20 tokens in sync and ensure their accurate representation on the Binance Smart Chain.

Prerequisite

This BEP20 token is mirrored to a BEP2 token.

Motivation

For a BEP20 token which has been mirrored to BC, anyone can call the sync method to balance the total supply on BC and BSC. Thus, the total supply among two Blockchains will remain the same.

What happens under the hood

Verify there is already mirrored

Check the total supply and token symbol is valid

Send a cross-chain package to modify a BEP2 token total supply on Binance Chain

After syncing, the total supply on BC and BSC are the same.

Fee Table

Fee Name

 

Pay in BNB

 

syncFee

it’s 0.002BNB on mainnet now

relayFee

it’s 0.002BNB on mainnet now

 

Both syncFee and relayFee can be changed by on-chain governance

To query syncFee from system contract;

Call Tokenmanager Contract with the latest ABI

Query syncFee 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

Use the latest ABI

Select sync function and fill-in with your BEP20 address

The value here should be no less than syncFee+ 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!

With this, you complete this workshop successfully!!