2019-07-09 02:00:28 -07:00
|
|
|
### Ethereum to Binance Chain bridge demo
|
|
|
|
|
|
|
|
https://forum.poa.network/t/ethereum-to-binance-chain-bridge/2696
|
|
|
|
|
2019-07-10 10:58:30 -07:00
|
|
|
#### Demo info
|
|
|
|
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.
|
|
|
|
|
|
|
|
ERC20 Token is used on the Ethereum side of the bridge.
|
2019-07-15 12:41:02 -07:00
|
|
|
All ERC20 tokens are located on address associated with DEPLOY_PRIVATE_KEY.
|
2019-07-10 10:58:30 -07:00
|
|
|
|
|
|
|
BNB Token is used on the Binance Chain side.
|
|
|
|
|
2019-07-09 02:00:28 -07:00
|
|
|
#### Running demo:
|
|
|
|
1) Build tss from local source.
|
|
|
|
```docker build -t tss -f ./src/tss/Dockerfile-local ./src/tss```
|
|
|
|
2) Run test environment (home and side blockchains, contracts deployment)
|
|
|
|
```./demo/start-environment.sh```
|
|
|
|
3) Run three validators in separate terminal sessions
|
|
|
|
```N=1 ./demo/validator-demo.sh```
|
|
|
|
```N=2 ./demo/validator-demo.sh```
|
|
|
|
```N=3 ./demo/validator-demo.sh```
|
2019-07-10 10:58:30 -07:00
|
|
|
|
|
|
|
|
|
|
|
#### Interacting with validators, sending votes, retrieving bridge information
|
|
|
|
* For each validator, a specific port is mapped outside of the docker
|
|
|
|
container for listening GET requests
|
|
|
|
- 5001 - first validator
|
|
|
|
- 5002 - second validator
|
|
|
|
- 5003 - third validator
|
|
|
|
* Retrieving bridge state
|
|
|
|
- http://localhost:5000/info
|
|
|
|
* Voting for bridge state changes
|
|
|
|
- http://localhost:5000/vote/startEpoch/NEW_EPOCH
|
|
|
|
- ```NEW_EPOCH``` should be equal nextEpoch + 1
|
|
|
|
- After enough votes are collected, keygen process starts, and
|
|
|
|
ends with transfer of all remained funds in the Binance Chain
|
|
|
|
to the new generated account
|
|
|
|
- http://localhost:5000/vote/addValidator/ADDRESS
|
|
|
|
- ```ADDRESS``` is the Ethereum address of a validator
|
|
|
|
- After enough votes are collected, validator is added into
|
|
|
|
the pending validators list for the next epoch
|
|
|
|
- http://localhost:5000/vote/addValidator/ADDRESS
|
|
|
|
- ```ADDRESS``` is the Ethereum address of a validator
|
|
|
|
- After enough votes are collected, validator is removed from
|
|
|
|
the pending validators list for the next epoch
|
|
|
|
|
|
|
|
#### Tools for sending transactions on both sides of the bridge
|
|
|
|
|
|
|
|
Run this scripts from ```src/oracle``` dir
|
|
|
|
|
2019-07-15 12:41:02 -07:00
|
|
|
* ```node testBinanceSend.js TO VALUE_TOKEN [VALUE_BNB]```
|
2019-07-10 10:58:30 -07:00
|
|
|
- ```TO``` - receiver address, current bridge address in the Binance Chain
|
2019-07-15 12:41:02 -07:00
|
|
|
- ```VALUE_TOKEN``` - amount of tokens to send
|
|
|
|
- ```VALUE_BNB``` - amount of BNB tokens to send, if present, the
|
|
|
|
transaction is considered as a funding one
|
|
|
|
* ```node testEthereumSend.js TO VALUE```
|
2019-07-10 10:58:30 -07:00
|
|
|
- Approves specified amount of tokens to the bridge account and calls
|
|
|
|
needed method for starting exchange process
|
|
|
|
- ```TO``` - receiver address in the Binance Chain
|
2019-07-15 12:41:02 -07:00
|
|
|
- ```VALUE``` - amount of tokens to transfer and exchange
|