# How to Set-up IBC connection between two chains.
##Note I am using server for the setup of two chains.
* First We have to do SSH in to our server.
For example: ssh root@ip_of_server
* After login in to our server first thing we need to setup the two different chains on the same server for this I am taking first chain sif chain and another one is regen.
* First I am doing the setup of Sifchain.
* Clone the binary of sif chain from here https://github.com/Sifchain/sifnode.git
git clone https://github.com/Sifchain/sifnode.git
* After clonning the binary go inside the clone directory and run the command for checkout.
git checkout v1.1.0-beta
* After run the command on the same directory.
make install
* Now we have to setup our sifchain for this we have to do init run the command:
sifnoded init witval --chain-id zone
* Add the keys and make sure save the mnemonic run the command:
sifnoded keys add key
* After running two commands we have to do some changes in our genesis.json file open the file with nano editor
nano .sifnoded/config/genesis.json
* Now after opening the file we have to change the denom from stake to rowan just replace the stake with rowan change the unbonding period to 172800s which is 2 days and voting period to 3600s this is 1 hour in seconds and there is another field called "admin" just put these accounts in to it.
"admin": {
"admin_accounts": [
{
"admin_type": 4,
"admin_address": "put_your_key_address"
},
{
"admin_type": 1,
"admin_address": "put_your_key_address"
},
{
"admin_type": 2,
"admin_address": "put_your_key_address"
},
{
"admin_type": 3,
"admin_address": "put_your_key_address"
}
]
},
* So we have successfully edit our genesis.json file now save the changes by ctrl+x and press y our changes is saved.
* Now Add genesis account for this run command:
sifnoded add-genesis-account key 10000000000000000000000000000000000rowan
* Provide self delegation to the validator run this command:
sifnoded gentxs key 900000000000000000000000rowan --chain-id zone
* Now run the command for collect-gentxs:
sifnoded collect-gentxs
* Now same we have to do for regen simply run the below command to clone the binary:
git clone https://github.com/regen-network/regen-ledger.git
* Go inside the regen directory and run the command for checkout to latest branch:
git checkout v5.1.0
* After git checkout on the same directory run the following command:
make install
* Now Setup the regen chain first we have to do init.
regen init name_Of_the_validator --chain-id zone1
* Add the keys and make sure save the mnemonic:
regen keys add key1
* Now we have to change the denom from stake to uregen for that open the genesis file.
nano .regen/config/genesis.json
* After open the file replace the stake with uregen denom and save the file with ctrl+x and press yes.
* Now Add genesis account for this run command:
regen add-genesis-account key1 1000000000000000000000000uregen
* Provide self delegation to the validator run this command:
regen gentxs key1 9000000000000000000uregen --chain-id zone1
* Now run the command for collect-gentxs:
regen collect-gentxs
* Most important thing as we running both the chains on the same server so we have configure the port no for one chain i am chainging the port no of regen open the config.toml and app.toml files from the .regen directory.
* Now after opening the file we have to change the denom from stake to uregn just replace the stake with uregn change the unbonding period to 172800s which is 2 days and voting period to 3600s this is 1 hour in seconds.
* To open the config.toml and changes the ports.
nano .regen/config/config.toml
we have change the rpc ports laddr = "tcp://127.0.0.1:26657" ==> "tcp://127.0.0.1:16657"
p2p laddr = "tcp://0.0.0.0:26656" ==> laddr = "tcp://0.0.0.0:16656"
pprof_laddr = "localhost:6060" ==> pprof_laddr = "localhost:6061".
* Now open app.toml file and changes the ports.
nano .regen/config/app.toml
we have to change the grpc port address = "0.0.0.0:9090" to ==> address = "0.0.0.0:9092".
[grpc-web]
address = "0.0.0.0:9091" ==> address = "0.0.0.0:9093"
* We have to some changes on genesis.json also open the genesis file change the denom from stake to uregn just replace the stake with uregn change the unbonding period to 172800s which is 2 days and voting period to 3600s this is 1 hour in seconds.
* Save the chages on the files and now start the two new screens if screen is not install on the system install it by the following command:
sudo apt install screen
* Command for start a new screen:
screen -S name_of_the_screen
* Now I am starting two new screens for both the chain and go inside the first screen start the sifnode chain:
sifnoded start
* Go inside to the another screen start the regen chain command to start the chain:
regen start
* After successfully running both the chains we have to install the hermes.
* But first install rust from here: https://www.rust-lang.org/learn/get-started
* Install golang from here: https://go.dev/doc/install
* To install the cargo and hermes run the command:
cargo install ibc-relayer-cli --bin hermes --locked
* After installation create a .hermes/bin directory on the home and copy the following data:
~/.cargo/bin# cp hermes ~/.hermes/bin
* Go inside the .hermes directory and create a file with name config.toml and paste the following data:
[global]
log_level = 'info'
[mode]
[mode.clients]
enabled = true
refresh = true
misbehaviour = true
[mode.connections]
enabled = true
[mode.channels]
enabled = true
[mode.packets]
enabled = true
clear_interval = 100
clear_on_start = true
tx_confirmation = true
[telemetry]
enabled = true
host = '127.0.0.1'
port = 3001
[rest]
enabled = true
host = '127.0.0.1'
port = 3000
[[chains]]
id = 'zone'
rpc_addr = 'http://localhost:26657'
grpc_addr = 'http://localhost:9090'
websocket_addr = 'ws:/localhost:26657/websocket'
rpc_timeout = '15s'
account_prefix = 'sif'
key_name = 'key'
store_prefix = 'ibc'
gas_price = { price = 0.01, denom = 'rowan' }
max_gas = 10000000
clock_drift = '5s'
trusting_period = '1days'
trust_threshold = { numerator = '1', denominator = '3' }
[[chains]]
id = 'zone1'
rpc_addr = 'http://localhost:16657'
grpc_addr = 'http://localhost:9092'
websocket_addr = 'ws:/localhost:16657/websocket'
rpc_timeout = '15s'
account_prefix = 'regen'
key_name = 'key1'
store_prefix = 'ibc'
gas_price = { price = 0.01, denom = 'uregen' }
max_gas = 10000000
clock_drift = '5s'
trusting_period = '1days'
trust_threshold = { numerator = '1', denominator = '3' }
* Now after paste the above content in to file and save it.
* Create a file sif.json and paste the sif key mnemonic in to the file and save it. Now we have to add the sif keys to the hermes for this run the command:
hermes keys add --mnemonic-file sif.json --chain zone
* Create another file with regen.json and paste the mnemonic of the regen account.
* Add the regen keys to the hermes:
hermes keys add --mnemonic-file regen.json --chain zone1
* Now check the keys is successfully added or not run this command:
hermes keys list --chain <CHAIN_ID>
* Now we have to create channel between both the chain for this run the below command:
hermes create channel --a-chain (chain_id_of_first_chain) --b-chain (chain_id_0f_second_chain) --a-port transfer --b-port transfer --new-client-connection
for example ==> hermes create channel --a-chain zone --b-chain zone1 --a-port transfer --b-port transfer --new-client-connection
* After successfully created the channels copy the channel id of boths chains and run the following command:
sifnoded query tokenregistry generate --token_base_denom <denom> --token_display_name <name> --token_ibc_channel_id <src-chanel-id> --token_ibc_counterparty_chain_id <chain-id-of other-chain> --token_ibc_counterparty_channel_id <dst-channel-id> --token_permission_ibc_import --token_permission_ibc_export --token_decimals 6 --output=json
for example ==> sifnoded query tokenregistry generate --token_base_denom uregen --token_display_name regen --token_ibc_channel_id channel-0 --token_ibc_counterparty_chain_id zone1 --token_ibc_counterparty_channel_id channel-0 --token_permission_ibc_import --token_permission_ibc_export --token_decimals 6 --output=json
* So this command is generate a json output copy it and create a file and paste in to it and save the file with any name but extension must be json and now we need to register in to tokenregistry so run the command:
sifnoded tx tokenregistry register <file_name.json> --from <key_name> --chain-id chain_id
for example ==> sifnoded tx tokenregistry register test.json --from key --chain-id zone
* We need have to register rowan token to tokenregistry too so do the same steps for rowan also for that run the command for rowan:
sifnoded query tokenregistry generate --token_base_denom rowan --token_display_name rowan --token_decimals 6 --token_permission_ibc_import --token_permission_ibc_export --output json
* Now we need to register in to tokenregistry so run the command:
sifnoded tx tokenregistry register test1.json --from key --chain-id zone
* Now create one more screen and start hermes on it. To start the hermes run the command:
hermes start
* Now I am doing the IBC transactions Sifnode to Regen:
sifnoded tx ibc-transfer transfer transfer channel-0 regen1z8whvd8ag3mrhyqr2kznxf4mv0nqamgz0qpmvp 100000rowan --chain-id zone --from key --keyring-backend test --node tcp://localhost:26657 --broadcast-mode block --fees 10000000000000000rowan
* Trasaction Regen to Sifnode using the below command:
regen tx ibc-transfer transfer transfer channel-1 sif1s35tqtchh97gl00kadfwezk3luvwxdl2tyc9g0 100000uregen --chain-id zone1 --from key1 --keyring-backend test --node tcp://localhost:16657
* Now if both the trasactions is successful submit a software upgrade proposal on sifchain. Upgrade name 1.2.0-beta and make sure that height will be reached after 1 hour because our voting period is 1 hour command for software-proposal:
sifnoded tx gov submit-proposal software-upgrade 1.2.0-beta --from key --upgrade-height 50700 --title abcd --description "Software-upgrade" --chain-id zone --fees 20000000000000000000000rowan
* Make and deposit and vote on the proposal.
* After the chain halt at the given upgrade height clone the given repository and replace the binary with existing one:
git clone https://github.com/atheeshp/sifnode.git
* Do git checkout and make install:
git checkout ap/ibc-v2-to-v4 && make install
* Now the start chain and do the ibc transactions between both the chains if the trasactions is successful congratulations we setup a relayer between two chains.