Fern uses the parity-bridge
project to connect private PoA networks to a public network like ethereum. The bridge will enable token transfers between the networks.
This repository contains scripts and configuration files for testing parity bridge between a private PoA network and the Kovan network.
The bin
directory contains parity bridge binaries built from bdc00d1
of parity-bridge.
To run and test the bridge locally, you will have to create an account and request some ethers from faucet.
- Copy the
parity-bridge
&parity-bridge-deploy
binaries frombin
to a folder in yourPATH
- Start a parity node connecting to the home (Kovan) network:
$ sh parity_home_start.sh
- Start a parity node connecting to the foreign (fern) netowork:
$ sh parity_foreign_start.sh
- Deploy the bridge contracts:
$ sh bridge_deploy.sh
- Once contracts are deployed, start the bridge:
$ sh bridge_start.sh
Bridge Monitor is a simple nodejs app that monitors the bridge contracts from both networks, and output events to the console.
- nodejs >= v8.11.1
- Copy the
.env.example
file to.env
- Replace the
HOME_CONTRACT_ADDRESS
andFOREIGN_CONTRACT_ADDRESS
with the addresses from the deployment. You can find them underbridge_db.toml
after parity-bridge contracts are deployed. - Run the Bridge Monitor:
$ npm start
- Parity bridge running
- MetaMask installed
- If you want to see the events and results in action, make sure to start the
Bridge Monitor
. - Open MetaMask and switch to Kovan network.
- Make sure the correct account is selected, transfer a small amount of ether to the
HOME_CONTRACT_ADDRESS
(you can find the address frombridge_db.toml
after you complete parity bridge deployment) - Once the transaction is submitted, you should see the following events from
Bridge Monitor
:
[HOME] Event: Deposit
Data: {
"0": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"1": "1000000000000000",
"recipient": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"value": "1000000000000000"
}
[BALANCE] 0x06ecd9d5f588a57d6e696253f95265bd61bee378 now has 1000000000000000 tokens in foreign network.
[FOREIGN] Event: Transfer
Data: {
"0": "0x0000000000000000000000000000000000000000",
"1": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"2": "1000000000000000",
"from": "0x0000000000000000000000000000000000000000",
"to": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"tokens": "1000000000000000"
}
[FOREIGN] Event: Deposit
Data: {
"0": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"1": "1000000000000000",
"2": "0x71694415e46e0fc3666ca1c156c8ed6e43ebc31e60240b74795e4855b5b91ba9",
"recipient": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"value": "1000000000000000",
"transactionHash": "0x71694415e46e0fc3666ca1c156c8ed6e43ebc31e60240b74795e4855b5b91ba9"
}
[BALANCE] 0x06ecd9d5f588a57d6e696253f95265bd61bee378 now has 2000000000000000 tokens in foreign network.
- If you want to see the events and results in action, make sure to start the
Bridge Monitor
. - Follow the steps in the above section to transfer 0.001 eth into the foreign network. Verify that you have at least 0.001 eth worth of tokens (1000000000000000) in the foreign network using
Bridge Monitor
. - Run the
npm run withdraw
task to trigger the withdraw. By default, it attempts to withdraw 1000000000000000 tokens. - Check the
Bridge Monitor
for results. If you see something like below, the tokens is successfully withdrawn and transferred back to the address in the home network.
[BALANCE] 0x06ecd9d5f588a57d6e696253f95265bd61bee378 now has 2000000000000000 tokens in foreign network.
[FOREIGN] Event: Transfer
Data: {
"0": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"1": "0x0000000000000000000000000000000000000000",
"2": "1000000000000000",
"from": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"to": "0x0000000000000000000000000000000000000000",
"tokens": "1000000000000000"
}
[FOREIGN] Event: Withdraw
Data: {
"0": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"1": "1000000000000000",
"2": "200000",
"recipient": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"value": "1000000000000000",
"homeGasPrice": "200000"
}
[FOREIGN] Event: CollectedSignatures
Data: {
"0": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"1": "0x877fecd5316961b99010568cc6a09b5be8a06db7133846d04e35c729963914a4",
"authorityResponsibleForRelay": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"messageHash": "0x877fecd5316961b99010568cc6a09b5be8a06db7133846d04e35c729963914a4"
}
[BALANCE] 0x06ecd9d5f588a57d6e696253f95265bd61bee378 now has 1000000000000000 tokens in foreign network.
[HOME] Event: Withdraw
Data: {
"0": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"1": "999960000000000",
"2": "0x0208b23c0a6eda8fece6a503ecd6cca04bc500d2e87e03fbea709ec5e222ba77",
"recipient": "0x06EcD9D5F588a57d6E696253f95265Bd61bEe378",
"value": "999960000000000",
"transactionHash": "0x0208b23c0a6eda8fece6a503ecd6cca04bc500d2e87e03fbea709ec5e222ba77"
}
- Verify your eth balance on Etherscan.