# Into the Project Directory=>cdtestnet-contracts/# Create .env with sample environment variablescp.env.example.env# Add environment variable MNEMONIC from your MetaMask account in .env file.# Add environment variable INFURA_PROJECT_ID from your Infura account in .env file.
Running the bridge on the Ropsten testnet
cd testnet-contracts/
Now run the following commands..
# Deploy contract to ropsten networkyarnmigrate--networkropsten# Get contract's addressyarnpeggy:address--networkropsten
Set up the nodes and validators
node-1
Open a terminal and run the following commands. Let's call it as terminal-1
# Install tools (golangci-lint v1.18)maketools-cleanmaketools# Install the app into your $GOBINmakeinstall# Now you should be able to run the following commands, confirming the build is successful:fbdhelpfbclihelpfbrelayerhelp
Running and testing the application
First, initialise a chain and create accounts.
# Initialize the genesis.json file that will help you to bootstrap the networkfbdinitnode1--chain-id=fbchain# Create a key to hold your validator account and for another test accountfbclikeysaddvalidator1# Enter passwordfbclikeysaddtestuser# Enter password# Edit the genesis.json file for customised stake denom# on terminal go to folder ~/.fbd/config/genesis.json# Edit the staking section having bond_denom key from "stake" to "fbx"# Save and close the file.# Initialize the genesis account and transactionfbdadd-genesis-account$(fbclikeysshowvalidator1-a)1000000000fbx,1000000000fbc# Create genesis transactionfbdgentx--namevalidator1--amount1000000fbx# Enter password# Collect genesis transactionfbdcollect-gentxs#Add Customisation to genesis file# on terminal go to folder ~/.fbd/config/genesis.jsonReplace'"staking"'sectionwiththejsonmentionedincustomised_genesis.json (which isinProjectDirectory)# Now its safe to start `fbd`fbdstart
Start the relayer service
For automated relaying, there is a relayer service that can be run that will automatically watch and relay events (local web socket and deployed address parameters may vary).
Open a new terminal and run the following commands. Let's call it as terminal-2
# Check fbrelayer connection to ebdfbrelayerstatus# Start fbrelayer on the contract's deployed address with [PEGGY_DEPLOYED_ADDRESS]fbrelayer init wss://ropsten.infura.io/ws [PEGGY_DEPLOYED_ADDRESS] LogLock\(bytes32,address,bytes,address,string,uint256,uint256\) validator1 --chain-id=fbchain
# Enter password and press enter# You should see a message like: Started ethereum websocket with provider: wss://ropsten.infura.io/ws \ Subscribed to contract events on address: [PEGGY_DEPLOYED_ADDRESS]
# The relayer will now watch the contract on Ropsten and create a claim whenever it detects a lock event.#Using the application from rest-serverfbclirest-server--trust-node
node-2
Now, on terminal-1, run the following commands
# Install tools (golangci-lint v1.18)maketools-cleanmaketools# Install the app into your $GOBINmakeinstall# Now you should be able to run the following commands, confirming the build is successful:fbdhelpfbclihelpfbrelayerhelp
Running and testing the application
# Initialize the genesis.json file with another moniker and same namechainfbdinitnode2--chain-id=fbchain# Create a key to hold your validator account and for another test accountfbclikeysaddvalidator2# Enter passwordoverwrite~/.fbd/config/genesis.jsonwithfirstnodesgenesis.json#change persistent_peers#run `fbcli status` on first node to get id.goto~/.fbd/config/config.tomlpersistent_peers="<id_of_node1>@<ip>:<26656>"# Now its safe to start `fbd`fbdstart
node-1
# Then, wait 10 seconds and from first node send tokens to valdator2 address for testingfbclitxsendvalidator1<validator2>10000fbx--chain-id=fbchain--yesrun"fbcli keys show validator2"onsecondnodetogetvalidator2address.
terminal-2
# Next, setup the staking module prerequisites# First, create a validator and stakefbclitxstakingcreate-validator \--amount=1000fbx \--pubkey=$(fbdtendermintshow-validator) \--moniker="node2" \--chain-id=fbchain \--commission-rate="0.10" \--commission-max-rate="0.20" \--commission-max-change-rate="0.01" \--min-self-delegation="1" \--gas=200000 \--gas-prices="0.001fbx" \--from=validator2
terminal-3
Start the Relayer service
For automated relaying, there is a relayer service that can be run that will automatically watch and relay events (local web socket and deployed address parameters may vary).
# Check fbrelayer connection to ebdfbrelayerstatus# Start fbrelayer on the contract's deployed address with [PEGGY_DEPLOYED_ADDRESS]fbrelayer init wss://ropsten.infura.io/ws [PEGGY_DEPLOYED_ADDRESS] LogLock\(bytes32,address,bytes,address,string,uint256,uint256\) validator2 --chain-id=fbchain
# Enter password and press enter# You should see a message like: Started ethereum websocket with provider: wss://ropsten.infura.io/ws \ Subscribed to contract events on address: [PEGGY_DEPLOYED_ADDRESS]
# The relayer will now watch the contract on Ropsten and create a claim whenever it detects a lock event.#Using the application from rest-serverfbclirest-server--trust-node
node-3
Terminal-1
# Install tools (golangci-lint v1.18)maketools-cleanmaketools# Install the app into your $GOBINmakeinstall# Now you should be able to run the following commands, confirming the build is successful:fbdhelpfbclihelpfbrelayerhelp
Running and testing the application
First, initialize a chain and create accounts.
# Initialize the genesis.json file with another moniker and same namechainfbdinitnode3--chain-id=fbchain# Create a key to hold your validator account and for another test accountfbclikeysaddvalidator3# Enter passwordoverwrite~/.fbd/config/genesis.jsonwithfirstnodesgenesis.json#change persistent_peersgoto~/.fbd/config/config.tomlpersistent_peers="id@first_node_ip:26656, id@second_node_ip:26659"run"fbcli status"onfirstnodetogetfirst_nodeid.run"fbcli status"onsecondnodetogetsecond_nodeid.# Now its safe to start `fbd`fbdstart
From node-1
# Then, wait 10 seconds and from first node send tokens to valdator3 address for testingfbclitxsendvalidator1<validator3>10000fbx--chain-id=fbchain--yesrun"fbcli keys show validator3"onthirdnodetogetvalidator3address.
Terminal-2
# Next, setup the staking module prerequisites# First, create a validator and stakefbclitxstakingcreate-validator \--amount=900fbx \--pubkey=$(fbdtendermintshow-validator) \--moniker="node3" \--chain-id=fbchain \--commission-rate="0.10" \--commission-max-rate="0.20" \--commission-max-change-rate="0.01" \--min-self-delegation="1" \--gas=200000 \--gas-prices="0.001fbx" \--from=validator3
Start the Relayer service
For automated relaying, there is a relayer service that can be run that will automatically watch and relay events (local web socket and deployed address parameters may vary). On terminal-3, run the following commands
# Check fbrelayer connection to ebdfbrelayerstatus# Start fbrelayer on the contract's deployed address with [PEGGY_DEPLOYED_ADDRESS]fbrelayer init wss://ropsten.infura.io/ws [PEGGY_DEPLOYED_ADDRESS] LogLock\(bytes32,address,bytes,address,string,uint256,uint256\) validator3 --chain-id=fbchain
# Enter password and press enter# You should see a message like: Started ethereum websocket with provider: wss://ropsten.infura.io/ws \ Subscribed to contract events on address: [PEGGY_DEPLOYED_ADDRESS]
# The relayer will now watch the contract on Ropsten and create a claim whenever it detects a lock event.#Using the application from rest-serverfbclirest-server--trust-node