Connect Two Cosmos SDK Blockchains using IBC / Hermes Cosmos Journey

Connect Two Cosmos SDK Blockchains using IBC / Hermes Cosmos Journey

For this tutorial we will be using two seperate chains (Alpha & Omega) scaffolded with Ignite CLI.

Steps:

  • Install Ignite CLI
  • Install Hermes App for Ignite CLI
  • Scaffold Alpha Blockchain
  • Add alpha.yml config file
  • Scaffold Omega Blockchain
  • Add omega.yml config file
  • Start Alpha & Omega chains
  • Configure the Hermes Relayer
  • Start the Hermes Relayer
  • Send a Test Transaction

Install Ignite CLI

(Note: The only version of Ignite that worked for me was the nightly version, you can install with this command.)

curl https://get.ignite.com/cli@nightly! | bash

As always, be sure to have Ignite on your $PATH be sure to have it placed in your /usr/local/bin

Install Hermes App for Ignite CLI

Hermes is an implementaion of IBC you can learn more here: Link

ignite app install -g github.com/ignite/apps/hermes

Scaffold Alpha Blockchain

We will use Ignite CLI to scaffold our blockchains.

ignite scaffold chain alpha

Note: in this version we are not adding a custom address prefix. Though you can add custom prefixes.with --flag when configuring the relayer.

Add alpha.yml config file

Note you will already have a config.yml, we will ignore this file when launching our chain and use our own custom one.

Move into our project directory:

cd alpha

Create a new file:

nano alpha.yml

Copy and past this into the file:

version: 1
accounts:
  - name: alice
    coins:
      - 1000token
      - 100000000stake
  - name: bob
    coins:
      - 500token
      - 100000000stake
faucet:
  name: bob
  coins:
    - 5token
    - 100000stake
  host: 0.0.0.0:4501
genesis:
  chain_id: alpha-1
validators:
  - name: alice
    bonded: 100000000stake
    app:
      api:
        address: :1317
      grpc:
        address: :9090
      grpc-web:
        address: :9091
    config:
      p2p:
        laddr: :26658
      rpc:
        laddr: :26657
        pprof_laddr: :6060

Scaffold Omega Blockchain

ignite scaffold chain omega

Add omega.yml config file

Move into our project directory:

cd omega

Create a new file:

nano omega.yml

Copy and past this into the file:

version: 1
accounts:
  - name: john
    coins:
      - 1000token
      - 100000000stake
  - name: kevin
    coins:
      - 500token
      - 100000000stake
faucet:
  name: kevin
  coins:
    - 5token
    - 100000stake
  host: 0.0.0.0:4500
genesis:
  chain_id: omega-1
validators:
  - name: john
    bonded: 100000000stake
    app:
      api:
        address: :1316
      grpc:
        address: :9082
      grpc-web:
        address: :9092
    config:
      p2p:
        laddr: :26648
      rpc:
        laddr: :26649
        pprof_laddr: :6065

Start Alpha Chain

In a new window:

cd $HOME
cd alpha

start chain the Alpha Blockchain using the --config flag to point to our custom config yaml file.

ignite chain serve --config alpha.yml

Start Omega Chain

cd $HOME
cd omega

Start the Omega Blockchain:

ignite chain serve --config omega.yml

Configure the Hermes Relayer

You can confige the hermes relayer with the following command:

ignite relayer hermes configure "alpha-1" "http://localhost:26657" "http://localhost:9090" "omega-1" "http://localhost:26649" "http://localhost:9082" --chain-a-faucet "http://0.0.0.0:4501" --chain-b-faucet "http://0.0.0.0:4500" --generate-wallets --overwrite-config

To see the documentation on the Hermes App, please see the repository readme. Link

Start the Hermes Relayer

Note we can start the hermes relayer with one command. For me it just showed a blinking cursor, and only logged status when there were errors.

ignite relayer hermes start "alpha-1" "omega-1"

Send a Test Transaction

For this tutorial we will be sending a transaction from alice on our Alpha chain to kevin on our Omega chain, note the address below for kevin will be different for your chain.

alphad tx ibc-transfer transfer transfer channel-0 cosmos1a80keumufqgrvzvjyy2js20876kjkuxwv9qsyk 100token --node http://0.0.0.0:26657 --home ~/.alpha --chain-id alpha-1 --from alice --keyring-backend test  

Check if Transaction was sent

We can verify the transaction was sent, with this

aplhad query bank balances [alice address]

When you check it, it should show the 100 tokens have been deducted.