Here's a guide to setting up cross-chain transfer in networks built on the Cosmos SDK using IBC.
We need two nodes in different networks. The Relayer can be placed on a separate VPS or on VPS together with one of the nodes.
I use kichain and rizon in my case. The relayer is installed together with the Rizon node. You can use any other networks that supports IBC transfer.
Use the following command to make sure that IBC transfer is supported:
[network command] q ibc-transfer params
In my case, the command is:
rizond q ibc-transfer params
Output will be:
receive_enabled: true send_enabled: true
- Install and initializing the relayer on the Rizon node.
- Create a config files for both networks.
- Get wallets
- Open a channel for relaying
- Make a cross-chain transfer.
- Open channel for transfers from any node.
git clone https://github.com/cosmos/relayer.git
cd relayer
make install
cd
rly version
Output:
version: 1.0.0-rc1–152-g112205b
rly config init
mkdir rly_config
cd rly_config
Here we can use the Global RPC address in the config file.
Create json file using command:
nano kichain-t-4.json
Insert this text in the file you created:
{
"chain-id": "kichain-t-4",
"rpc-addr": "https://rpc-challenge.blockchain.ki:443",
"account-prefix": "tki",
"gas-adjustment": 1.5,
"gas-prices": "0.025utki",
"trusting-period": "48h"
}
Save it: ctrl+X, Y, enter
Instead of the Global RPC address we use the localhost, since the node Rizon is located on the same server as the relayer.
Create json file using command:
nano groot-011.json
Insert this text in the file you created:
{
"chain-id": "kichain-t-4",
"rpc-addr": "http://localhost:26657",
"account-prefix": "tki",
"gas-adjustment": 1.5,
"gas-prices": "0.025utki",
"trusting-period": "48h"
}
Save it: ctrl+X, Y, enter
rly chains add -f groot-011.json
rly chains add -f kichain-t-4.json
cd
In my case, I restored the existing keys on both networks.
For create wallets, using:
rly keys add groot-011 name_of_your_wallet
rly keys add kichain-t-4 name_of_your_wallet
For restore wallets, using:
rly keys restore groot-011 name of your wallet "mnemonic"
rly keys restore kichain-t-4 name of your wallet "mnemonic"
rly chains edit groot-011 key name_of_your_wallet
rly chains edit kichain-t-4 key name_of_your_wallet
Use following command to open the config file:
nano ~/.relayer/config/config.yaml
Set timeout to 30s.
Save it: ctrl+X, Y, enter
Check the availability of coins with the command.
rly q balance groot-011
rly q balance kichain-t-4
The output must not be empty.
rly light init groot-011 -f
rly light init kichain-t-4 -f
rly paths generate groot-011 kichain-t-4 transfer --port=transfer
Im used 'transfer' name for the path. You can use another one.
If successful, the output will be:
Generated path(transfer), run 'rly paths show transfer --yaml' to see details
Use following command:
rly tx link transfer
Output:
★ Channel created: [groot-011]chan{channel-11}port{transfer} -> [kichain-t-4]chan{channel-41}port{transfer}
If it didn't work, try again or change the config.yaml file
Use command to open config.yaml
nano /root/.relayer/config/config.yaml
Remove the following lines in both networks:
client-id: 07-tendermint-18
connection-id: connection-25
channel-id: channel-23
Save it: ctrl+X, Y, enter
Follow step 3.5 and 4.2 again
To make sure everything is OK, use the following command:
rly paths list -d
Output:
0: transfer -> chns(✔) clnts(✔) conn(✔) chan(✔) (groot-011:transfer<>kichain-t-3:transfer)
Template for cross-chain transation:
rly transact transfer [src-chain-id] [dst-chain-id] [amount] [dst-addr] [flags]
In my case, the command looks like this:
rly tx transfer groot-011 kichain-t-4 5000000uatolo tki1cahyp4gs70w55ppnvneulpjjqv2ppc5xx53m2u --path transfer
Output:
✔ [groot-011]@{427471} - msg(0:transfer) hash(405B95613CD768EC971E82F133288F5033F5193B425AF70E1D59A0BBC5C71775)
In my case, the command looks like this:
rly tx transfer kichain-t-4 groot-011 10000000utki rizon1gdrat404pvj4hxc9nvu65apq6nte5hyk862crs --path transfer
Output:
✔ [kichain-t-4]@{246212} - msg(0:transfer) hash(D26C3B00BFBFAA63FFAD7754304133A26AC81848820CC20C15B634154D8B7A02)
You can check your wallet keys using following commands:
rly keys list groot-011
rly keys list kichaint-t-4
sudo tee /etc/systemd/system/rlyd.service > /dev/null <<EOF
[Unit]
Description=relayer client
After=network-online.target
[Service]
User=$USER
ExecStart=$(which rly) start transfer
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable rlyd
sudo systemctl start rlyd
Transfer from Kichain to Rizon.
Template:
kid tx ibc-transfer transfer <path_name> <channel-N> rizon_WALLET_address 1000utki --from <name_OF_wallet> --chain-id kichain-t-4
In my case, the command looks like this:
kid tx ibc-transfer transfer transfer channel-26 rizon1gdrat404pvj4hxc9nvu65apq6nte5hyk862crs 1000utki --from my_rizon_wallet --chain-id kichain-t-4
Transfer from Rizon to kichain.
In my case, the command looks like this:
rizond tx ibc-transfer transfer <path_name> <channel-N> tki_wallet_adress 1000uatolo --from <name_OF_wallet> --chain-id groot-011
Use following command to find channel nummbers:
rly paths show transfer
86022EC9CF803473772C2BCBB65388415566B7FC6309B145374AE8574C18F71D 405B95613CD768EC971E82F133288F5033F5193B425AF70E1D59A0BBC5C71775
Use following URL to check HASH: https://testnet.mintscan.io/rizon/txs/XXXXXXX
C2793A55CAE1F7F603823E317C888048CFB710E971BCC9781D1AEF8DA512ECA4 6772AE3630F8181B084954DD737B951F426DB7F704AE80EBE342A15BF23FEAA3 D26C3B00BFBFAA63FFAD7754304133A26AC81848820CC20C15B634154D8B7A02
Use following URL to check HASH: https://api-challenge.blockchain.ki/txs/XXXXXX