Technical Journey about Migrating Xeonbit Token (XNS) between Binance Smart Chain (BEP20) and Binance Chain (BEP2)

Xeonbit
4 min readMar 24, 2021

--

Hi guys, Xeonbit Token (XNS) were released on Ethereum (ERC20), Binance Chain (BEP2) and Binance Smart Chain (BEP20). We are trying to bind Xeonbit Token (XNS) between Binance Smart Chain (BEP20) <-> Binance Chain (BEP2). This article will show how to do it.

  • Requirements: BC Account, BSC Account, Metamask, Remix, bnbcli
  • Time: 1 hour

Process Overview — 3 Simple Steps

Part 1 — Generating the Bind

  1. Token Owner deploys a BEP20 contract with totalSupply that *exactly* matches its BEP2 counter-part. The symbol should be identical to the prefix of the BEP2 symbol (ie. if BEP2 is “XNS-760” then symbol should be “XNS”) The decimals also must be 18.
  2. BEP2 Token Owner then binds the BEP20 contract with the BEP2 asset.

This now creates the asset on BSC and tells BC about it. The full supply of the BSC asset will be on the BEP20 Owner’s address.

Part 2 — Approving the Bind

  1. The BEP20 owner then approves the BSC TokenHub to spend an infinite supply.
  2. The BEP20 owner then approves the Bind on the TokenHub contract.

The full supply will now be moved into the TokenHub, ready to fulfil transfer requests by BEP2 owners.

Part 3 — Social Profile (skip)

  1. BEP20 Owner is to then update the social profile on BscScan to allow users to discover and be informed about their new BEP20 token.

Part 1 — Generating the Bind

1.1 Creating a BEP20 Token (Skip)

1.2 Binding the BEP2

The next part is to bind the two assets together.

Firstly, download the CLI binary (get the latest version, then download off github):

Binance have a community-maintained installer script (install.sh) that takes care of chain directory setup. This uses the following defaults:

  • Home folder in ~/.bnbchaind
  • Client executables stored in /usr/local/bin (i.e. lightd or bnbchaind)

# One-line install
sh <(wget -qO- https://raw.githubusercontent.com/binance-chain/node-binary/master/install.sh)

The script will install the bnbchain, bnbcli and tbnbcli binaries. Verify that everything is OK:

$ bnbchaind version
$ bnbcli version

Import owner key with mnemonic to your keys:

$ bnbcli keys add owner — recover

Then prepare the command to bind the BEP2 with smart contract BEP20

$ bnbcli bridge bind — symbol XNS-760 — amount 0 — expire-time 1616579955 — contract-decimals 18 — from owner — chain-id Binance-Chain-Tigris — contract-address 0x805d53d9b85c56aaa059005c553b65c084bcea85 — node http://dataseed4.binance.org:80

Note on parameters:

  • Symbol is the BEP2 symbol
  • Amount should be 0 which will specify 100% of the supply to be migrated
  • Expire-time place 15 minutes into the future: https://www.epochconverter.com/
  • Contract Address should be the BEP20 address

Committed at block 152241896 (tx hash: A4795DF9931B41E56350A8D657CBAEE816D1AEBBC5BD9824E5BC8DB001F1E8D5, response: {Code:0 Data:[] Log:Msg 0: Info: GasWanted:0 GasUsed:0 Events:[{Type: Attributes:[{Key:[112 101 103 95 105 110 95 66 78 66] Value:[50 48 48 48 48 48 48] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0} {Key:[83 101 110 100 83 101 113 117 101 110 99 101] Value:[54 56] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0} {Key:[67 104 97 110 110 101 108] Value:[1] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0} {Key:[114 101 108 97 121 101 114 70 101 101] Value:[50 48 48 48 48 48 48] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0} {Key:[97 99 116 105 111 110] Value:[99 114 111 115 115 66 105 110 100] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0}] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0}] Codespace: XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0})

Result will show with transaction on BC

Part 2 — Approving the Bind

2.1 Approving the Tokenhub to spend.

Head to BSCScan find the Xeonbit Token(BEP20) contract and click “write contract” in order to approve TokenHub contract to spend an infinite supply (just use “-1”):

0x0000000000000000000000000000000000001008

You can see the contract transaction detail

2.3 Approving the Bind

The BEP20 Owner can now approve the bind. This will transfer the full supply from their address into the TokenHub Contract.

https://bscscan.com/address/0x0000000000000000000000000000000000001008#writeContract

After connect through Metamask you can click Approve the Contract transaction

Note: you will need to pay the relay fee of 0.01 BNB.

You can see the contract transaction detail event log we saw the failedReson: 1. We also don't know what's happening with the result

We will find out what's the failReason: 1 and update about it soon.

After this step you can use Bridge between BEP20 and BEP2. Please let us know more about your idea to solve this issue. Thanks

Reference:
https://medium.com/spartanprotocol/migrating-from-binance-chain-to-binance-smart-chain-bdda3a36385d
https://bnbsmartchain.com/bind-bep2-and-bep20-token/

--

--

Xeonbit

Xeonbit (XNB) & Xeonbit Token (XNS) - the private digital currency for secure payment network fully decentralized without any central authorities.