Chain
BNB Beacon Chain
Staking & lapisan tata kelola ekosistem BNB Chain
Pengembang
Komunitas
Binance Smart Chain and Binance Chain work together to ensure that one token can circulate in both formats with confirmed total supply and be used in different use cases. Token Binding can happen at any time after BEP2 and BEP20 are ready. The token owners of either BEP2 or BEP20 only need to complete the Binding process when a cross-chain feature is necessary.
Download the code: https://github.com/binance-chain/token-bind-tool
Compile token bind tool:
make build
Generate temp account (Deploy contract on Binance Smart Chain):
./build/token-bind-tool initKey --network-type {testnet/mainnet}
Example response:
Temp account: 0xde9Aa1d632b48d881B50528FC524C88474Ec8809, Explorer url: https://bscscan.com/address/0xde9Aa1d632b48d881B50528FC524C88474Ec8809
Transfer 1 BNB to the temp account.
2.1 Cross chain transfer
bnbcli bridge transfer-out --expire-time `expr $(date +%s) + 3600` \
--chain-id Binance-Chain-Tigris --from {keyName} --node http://dataseed4.binance.org:80 \
--to {temp account address} --amount 100000000:BNB
Example command:
bnbcli bridge transfer-out --expire-time `expr $(date +%s) + 3600` \
--chain-id Binance-Chain-Tigris --from bep2TokenIssuer --node http://dataseed4.binance.org:80 \
--to 0xde9Aa1d632b48d881B50528FC524C88474Ec8809 --amount 100000000:BNB
2.2 You can also transfer BNB from other Binance Smart Chain account with Metamask.
Suppose you have already issued a BEP2 token, and you want to deploy a BEP20 token and bind it with existing BEP2 token:
Import bep2 token owner key(Send bind transaction on Binance Chain):
1.1 From ledger: connect ledger to your computer and open Binance Chain App
bnbcli keys add bep2TokenIssuer --ledger --index {your ledger key index}
1.2 From mnemonic:
bnbcli keys add bep2TokenIssuer --recover
Prepare BEP20 contract code
2.1 You can refer to BEP20 Template and modify it according to your own requirements.
NOTE 1: Ensure the BEP20 symbol is identical to the prefix of a BEP2 token symbol. Suppose a BEP2 token symbol is ABC-123
, then the BEP20 symbol must be ABC
.
NOTE 2: Ensure the total supply equals to the BEP2 token total supply. As we know, the decimals of BEP2 tokens are 8, if the BEP20 decimal is 18, then the BEP20 total supply must be BEP2_total_supply*10^10
.
NOTE 3: If your BEP2 token is mintable, then you'd better implement mint
in BEP20 contract. Otherwise, you'd better remove mint
in BEP20 contract.
2.2 Compile your contract with Remix and get contract byte code:
Edit script/contract.json
to add contract byte code:
{
"contract_data": ""
}
Fill contract byte code to contract_data
Deploy contract, bind and transfer ownership:
./script/bind.sh {mainnet/testnet} {bep2TokenIssuerKeyName} {password, for ledger key, use empty string: ""} {peggyAmount} {bep2 token symbol} {token owner} {path to bnbcli or tbnbcli}
Example command:
./script/bind.sh testnet bep2TokenIssuer "12345678" 0 ABC-D9B 0xaa25Aa7a19f9c426E07dee59b12f944f4d9f1DD3 $HOME/go/bin/tbnbcli
Suppose you have already issued BEP2 token, deployed BEP20 contract and sent bind transaction, now you just want to approve bind from your Ledger device:
./build/token-bind-tool approveBindFromLedger --bep2-symbol {bep2 symbol} --bep20-contract-addr {bep20 contract address} \
--ledger-account-index {ledger key index} --peggy-amount {peggy amount} --network-type {mainnet/testnet}
Suppose you just want to deploy a BEP20 contract and transfer all token and ownership to your owner account, then you can try this command:
./build/token-bind-tool deployBEP20ContractTransferTotalSupplyAndOwnership --bep20-owner {bep20 owner} \
--config-path {contract byte code path, refer to `script/contract.json`} --network-type {mainnet/testnet}
./build/token-bind-tool refundRestBNB --network-type {mainnet/testnet} --recipient {bsc account}