## Ethereum to Binance Chain bridge https://forum.poa.network/t/ethereum-to-binance-chain-bridge/2696 The bridge is able to transfer an ERC20 tokens on an EVM based chain to BEP2 to the Binance Chain. It includes the following components: 1. The bridge contract on an EVM-based chain that is responsible to receive and release ERC20 tokens 2. The orchestration contract on an EVM-based chain that participate in MPC (multy-party computations) to generate a threshold signature. 3. The oracle that monitors the chains and the send transactions. One oracle represents one bridge validator (one private key). The idea of the bridge is similar to [the token bridge](https://github.com/poanetwork/tokenbridge) produced by [POA.Network](https://poa.network/): - every oracle sends its confirmation as soon as a user sends the token relay request in one chain. - when enough confirmations collected the requested amount of tokens is unlocked in another chain. Collecting confirmations for the Binance Chain is made in form of mutlisig wallet - the validator's confirmation is participation in the transaction signature gneration with usage of Threshold Signature Scheme implemented for ECDSA by [KZen Research team](https://github.com/KZen-networks/multi-party-ecdsa). #### Demo This demo, at the beginning, consists of three validator parties, while only two are enough to sign any transaction in the Binance Chain, confirm token transfer on the Ethereum Side, or vote for state changes. BEP2 Token is used on the Binance Chain side. All parts of this demo are docker containers. #### Running demo: 1. Preparation * (1.1) Download `tbnbcli` from https://github.com/binance-chain/node-binary/tree/master/cli. * (1.2) Create a new account through the [web-interface](https://testnet.binance.org/en/create). Copy the private key and mnemonic phrase. The private key will be used to import it in an Ethereum Wallet. The mnemonic phrase is to recover the BNB with `tbnbcli`. * (1.3) Recover the account in the console with the mnemonic. ``` ./tbnbcli keys add test_account1 --recover ``` * (1.4) Create few BNB accounts from the console. They will be donors to provide enough funds to issue a BEP2 tokens (500 BNB required). ``` ./tbnbcli keys add test_account2 ./tbnbcli keys add test_account3 ``` * (1.5) Register on the Binance site and fund the accounts from the [testnet faucet](https://www.binance.com/en/dex/testnet/address). * (1.6) Re-arrange funds on the accounts as so the first account will have 550 BNB and others 10-20 BNBs to make transactions. ``` ./tbnbcli send --from test_account2 --to
\ --amount 18500000000:BNB --chain-id=Binance-Chain-Nile \ --node=data-seed-pre-2-s1.binance.org:80 --memo "donate" ./tbnbcli send --from test_account3 --to \ --amount 18500000000:BNB --chain-id=Binance-Chain-Nile --node=data-seed-pre-2-s1.binance.org:80 --memo "donate" ``` * (1.7) Issue the BEP2 token from the first account. `3141500000000000` corresponds to `31415000.0` tokens. ``` ./tbnbcli token issue --token-name "ERC20toBEP2Bridge" --total-supply 3141500000000000 \ --symbol ETB0819 --mintable --from test_account1 --chain-id=Binance-Chain-Nile \ --node=data-seed-pre-2-s1.binance.org:80 --trust-node ``` In the real deployment most probably the token must not be mintable. * (1.8) Get the BEP2 token ID in `denom` field (in this example it is `ETB0819-863`). ``` ./tbnbcli account \ --chain-id=Binance-Chain-Nile --node=data-seed-pre-2-s1.binance.org:80 --trust-node ``` * (1.9) Clone the repo and initialize git submodules: ``` git clone --recurse-submodules https://github.com/k1rill-fedoseev/eth-to-bnc-bridge.git ``` * (1.10) Build TSS to be used in the bridge oracles: ``` docker build -t tss -f ./src/tss/Dockerfile-local ./src/tss ``` 2. Run test environment * (2.1) Modify `src/deploy/deploy-test/.env` and specify the amount of tokens to mint in the parameter `TOKEN_INITIAL_MINT`. * (2.2) Run testnets and deploy contracts ``` ./demo/start-environment.sh ``` This command will also mint tokens, the owner of tokens is the address that corresponds to the private key specified in `PRIVATE_KEY_DEV` of `src/deploy/deploy-test/.env`. * (2.3) Get the Ethereum account address for the first test account from its private key (step 1.2). NiftyWallet could be used for this. * (2.4) Modify the parameter `RECEIVER_ADDRESS` in `src/test-services/ethereumSend/.env` as so it contains the Ethereum address of the first account. * (2.5) Send few tokens from the current token owner to the first account: ``` ./src/test-services/ethereumSend/run.sh 5000000000000000000 ``` * (2.6) Check that the tokens were transferred properly: ``` ./src/test-services/ethereumBalance/run.sh