Setting up Cross Chain Connection using BTP Bridge
Follow these steps to establish a cross-chain connection between chains using the BTP Bridge:
Step 1: Ensure Kurtosis Engine is Running
Before proceeding, ensure that the Kurtosis Engine is running in the background. If it's not already running, start it with the following command:
kurtosis engine start
Step 2: Start Two Chains with BTP Bridge
To start both the ICON and Ethereum chains and establish a BTP bridge between them, run the following command:
dive bridge btp --chainA icon --chainB eth
Similarly, To start both the ICON and Hardhat chains and establish a BTP bridge between them, run the following command:
dive bridge btp --chainA icon --chainB hardhat
Executing the above command will generate a 'dive.json' file in the working directory, The file contains service details of the running nodes and deployed contract addresses. Here's what you can find in dive.json
:
Example of dive.json
{
"bridge": "false",
"chains": {
"eth": {
"block_number": "30",
"endpoint": "http://172.16.0.6:8545",
"endpoint_public": "http://172.16.0.3:8544",
"keypassword": "password",
"keystore_path": "keystores/eth_keystore.json",
"network": "0x301824.eth",
"network_name": "eth",
"nid": "0x301824",
"service_name": "el-1-geth-lighthouse"
},
"icon": {
"block_number": "242",
"endpoint": "http://172.16.0.2:9080/api/v3/icon_dex",
"endpoint_public": "http://127.0.0.1:8090/api/v3/icon_dex",
"keypassword": "gochain",
"keystore_path": "keystores/keystore.json",
"network": "0x3.icon",
"networkId": "0x1",
"networkTypeId": "0x1",
"network_name": "icon-0",
"nid": "0x3",
"service_name": "icon-node-0"
}
},
"contracts": {
"eth": {
"bmc": "0xB9D7a3554F221B34f49d7d3C61375E603aFb699e",
"bmcm": "0xAb2A01BC351770D09611Ac80f1DE076D56E0487d",
"bmcs": "0xBFF5cD0aA560e1d1C6B1E2C347860aDAe1bd8235",
"bmv": "0x765E6b67C589A4b40184AEd9D9ae7ba40E32F8d4",
"dapp": "0x9bE03fF3E1888A216f9e48c68B587A89c5b94CD6",
"xcall": "0x5911A6541729C227fAda7D5187ee7518B47fB237"
},
"icon": {
"bmc": "cx14303a14cbfd58b9bcd61b62b786b387f39be25a",
"bmv": "cx71337318cf13aa3fd805c75a38f4d5f800cd627c",
"dapp": "cx90bc909409ff8ba200b5a866e1bb952c39fa1f4a",
"xcall": "cx5dce8a39a49faadee03a02e6b33173aef91d4e67"
}
},
"links": {
"dst": "eth",
"src": "icon"
}
}
Tip: By default, the bridge flag is set to false. If you need an ICON bridge, add the --bmvbridge
or -b
flag to the command.
The above command automates several essential tasks to configure and initialize the local environment:
-
Spinning up Nodes: DIVE automatically starts and configures the required ICON and Ethereum nodes for your local environment.
-
Installing Required npm Dependencies: DIVE takes care of installing all the necessary npm dependencies for seamless operation.
-
Enabling BTP Block on ICON Local Network: DIVE facilitates BTP block functionality on the ICON local network by registering the node as a P-Rep and decentralizing the network.
-
Deploying Contracts for BTP: DIVE automatically builds and deploys essential smart contracts (BMC, BMV, xCall & sample dApp) for BTP functionality on both ICON and Ethereum chains.
-
Starting the Relay: The relay image is built and launched, actively monitoring both ICON and Ethereum chains to enable smooth message transfer between them.
Running BTP Bridge for Already Running Nodes
To set up the BTP Bridge between already running ICON nodes and Ethereum, use the following command:
dive bridge btp --chainA icon --chainB eth --chainAServiceName <service name of icon> --chainBServiceName <service name of eth>
To set up the BTP Bridge between already running ICON nodes and Hardhat, use the following command:
dive bridge btp --chainA icon --chainB hardhat --chainAServiceName <service name of icon> --chainBServiceName <service name of hardhat>
Note: When setting up a BTP relay between already running ICON nodes and Ethereum/Hardhat, you need to decentralize the ICON node first.
Note: Service names for "chainA" and "chainB" can be found in the services.json
file.
Step 3: Setup is Completed
Once the process completes, your local environment with the chains connected via the BTP bridge will be ready for testing and development.
DIVE CLI simplifies the entire setup, allowing you to focus on developing and testing your decentralized applications with ease.
Note: Currently, DIVE supports BTP bridge connections between ICON and Ethereum/Hardhat chains.
Happy developing!