---
# System prepended metadata

title: Paloma IBC and ICA testing

---

# Paloma IBC and ICA testing

## Paloma setup

### Clone repo and install
``` bash
git clone https://github.com/palomachain/paloma.git
git checkout aleem/fix-ibc
export VERSION=v0.11.7
make install
```

* Confirm osmosis binary installed

``` sh
$ palomad version
v0.11.7
```
### Setup paloma validator
* Initialize node
``` bash
palomad init validator --chain-id paloma-1
```
* Add keys and copy the `relayer` mnemonic seed(required for relayer)

``` sh
palomad keys add validator --keyring-backend test
palomad keys add key1 --keyring-backend test
palomad keys add relayer --keyring-backend test
```

``` bash
palomad add-genesis-account validator 1000000000000000000000000ugrain --keyring-backend test
palomad add-genesis-account key1 1000000000000000000000000ugrain --keyring-backend test
palomad add-genesis-account relayer 1000000000000000000000000ugrain --keyring-backend test

sed -i "s/172800s/600s/g" ~/.paloma/config/genesis.json


palomad gentx validator 9000000000000000000ugrain --chain-id paloma-1 --keyring-backend test

palomad collect-gentxs

palomad start
```

## Osmosis setup

### install osmosis binary

Download and install osmosis binary from https://github.com/osmosis-labs/osmosis/releases/tag/v15.1.0

* Confirm osmosis binary installed

``` bash
$ osmosis version
15.1.0
```

### setup osmosis validator node

* Initialize node
``` bash
osmosis init validator --chain-id osmosis-1

```
* Add keys and copy the `relayer` mnemonic seed(required for relayer)
``` bash
osmosis keys add validator --keyring-backend test
osmosis keys add key1 --keyring-backend test
osmosis keys add relayer --keyring-backend test
```

``` bash
osmosis add-genesis-account validator 10000000000000000000uosmo --keyring-backend test
osmosis add-genesis-account key1 10000000000000000000uosmo --keyring-backend test
osmosis add-genesis-account relayer 10000000000000000000uosmo --keyring-backend test
sed -i "s/stake/uosmo/g" ~/.osmosisd/config/genesis.json
osmosis gentx validator 100000000000000000uosmo --chain-id osmosis-1 --keyring-backend test
osmosis collect-gentxs
```

Note: As we are running both chains on the same system, we cannot use the same ports for both networks. Therefore, we need to update the configuration of the second network.

### Update osmosis node configuration

* Open .osmosisd/config/config.toml file and chage the ports.

``` toml
proxy_app "tcp://127.0.0.1:26658" => "tcp://127.0.0.1:16658"

rpc.laddr "tcp://127.0.0.1:26658" => "tcp://127.0.0.1:16658"

p2p.laddr = "tcp://0.0.0.0:26656" => "tcp://127.0.0.1:16656"
```

* Open .osmosisd/config/app.toml file and chage the ports.

``` toml
api.enable false => true
api.address "tcp://0.0.0.0:1317" => "tcp://0.0.0.0:1318"

grpc.address "0.0.0.0:9090" => "0.0.0.0:9100"
grpc-web.address "0.0.0.0:9091" => "0.0.0.0:9101"
```

### start osmosis validator node

``` bash
osmosis start
```

* After successfully running both the chains we have to install the hermes relayer.

### Hermes relayer setup

* Follow these instructions to install Hermes relayer https://hermes.informal.systems/quick-start/installation.html

* After Hermes installation create a `.hermes/config.toml` file and paste the following data.

``` toml
[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 = 'paloma-1'
rpc_addr = 'http://localhost:26657'
grpc_addr = 'http://localhost:9090'
websocket_addr = 'ws:/localhost:26657/websocket'
rpc_timeout = '15s'
account_prefix = 'paloma'
key_name = 'key'
store_prefix = 'ibc'
gas_price = { price = 0.01, denom = 'ugrain' }
max_gas = 10000000
clock_drift = '5s'
trusting_period = '1days'
trust_threshold = { numerator = '1', denominator = '3' }

[[chains]]
id = 'osmosis-1'
rpc_addr = 'http://localhost:16657'
grpc_addr = 'http://localhost:9100'
websocket_addr = 'ws:/localhost:16657/websocket'
rpc_timeout = '15s'
account_prefix = 'osmo'
key_name = 'key1'
store_prefix = 'ibc'
gas_price = { price = 0.01, denom = 'uosmo' }
max_gas = 10000000
clock_drift = '5s'
trusting_period = '1days'
trust_threshold = { numerator = '1', denominator = '3' }
```

* Now create a new text file `paloma.txt` and paste mnemonic seed of relayer key.
* * Now create a new text file `osmosis.txt` and paste mnemonic seed of relayer key.

* Now add keys for both network

```
hermes keys add --mnemonic-file paloma.txt --chain paloma-1 
hermes keys add --mnemonic-file osmosis.txt --chain osmosis-1 
```

* Now check the keys is successfully added or not with this command:

``` bash
hermes keys list --chain paloma-1
hermes keys list --chain osmosis-1
```

### IBC transfers
* Now we have to create a transfer channel between both the chains to perform IBC transfers.

``` sh
hermes create channel --a-chain paloma-1 --b-chain osmosis-1 --a-port transfer --b-port transfer --new-client-connection

```

* After successfully creating channel and connection start the Hermes relayer.

``` sh
hermes start
```

* IBC transfer from Paloma chain to Osmosis chain

``` bash
palomad tx ibc-transfer transfer transfer channel-0  osmo1402gct50k0ylfrk37vd7uzw0c8q2uq8e202jhy 100000ugrain --chain-id paloma-1 --from key1 --keyring-backend test
```

NOTE: you can find channel id with `palomad q ibc channel channels`

* Now switch to Osmosis and check the account balance of `osmo1402gct50k0ylfrk37vd7uzw0c8q2uq8e202jhy`. There should be a token with IBC denom.

* Now do IBC transfer from Osmosis to Paloma chain

``` bash
osmosis tx ibc-transfer transfer transfer channel-0 paloma1sardq8anj85k49sfh3vchvd4elphy24kx9w43g 10000stake --from key1 --chain-id osmosis-1 --keyring-backend test --node tcp://0.0.0.0:16657 --fees 900stake
```

NOTE: you can find channel id with `osmosis q ibc channel channels`

* Now switch to Paloma and check the account balance of `paloma1sardq8anj85k49sfh3vchvd4elphy24kx9w43g`. There should be a token with IBC denom.


## Paloma upgrade to v0.11.8

* After performing IBC transfers submit a software upgrade proposal


``` bash
palomad tx gov submit-proposal software-upgrade v0.11.8 --upgrade-height 1500 --title v0.11.8 --description "testing v0.11.8 upgrade" --deposit 1000000ugrain --from key1 --keyring-backend test --chain-id paloma-1
palomad tx gov vote 1 yes --from validator --keyring-backend test --chain-id paloma-1
palomad tx gov vote 1 yes --from key1 --keyring-backend test --chain-id paloma-1
```

* Wait for upgrade hight to hit. After the upgrade height hit, stop the Paloma node.

``` bash
git checkout master
export VERSION=v0.11.8
make install
palomad start
```

After starting the Paloma chain with new binary, test IBC transfer again.




## ICA testing

* Stop the osmosis node if it is running before testing ICA.

To test ICA we need a chain with both ICA controller and host enabled.

### ICA demo chain setup

``` bash
git clone https://github.com/cosmos/interchain-accounts-demo.git
cd interchain-accounts-demo
make install
```

* Check binary installed

``` bash
ica version --long
```

* Setup ICA demo chain

Note: Copy relayer key mnemonic seed, we need it for relayer account.

``` bash 
icad init validator --chain-id icademo-1
icad keys add validator --keyring-backend test
icad keys add key1 --keyring-backend test
icad keys add relayer --keyring-backend test
icad genesis add-genesis-account validator 10000000000stake --keyring-backend test
icad genesis add-genesis-account key1 10000000000stake --keyring-backend test
icad genesis add-genesis-account relayer 10000000000stake --keyring-backend test
icad genesis gentx validator 10000000000stake --keyring-backend test --chain-id icademo-1
sed -i "s/172800s/600s/g" ~/.ica/config/genesis.json
icad genesis collect-gentxs
```

### Update ICA demo node configuration

* Open .ica/config/config.toml file and chage the ports.

``` toml
proxy_app "tcp://127.0.0.1:26658" => "tcp://127.0.0.1:16658"

rpc.laddr "tcp://127.0.0.1:26658" => "tcp://127.0.0.1:16658"

p2p.laddr = "tcp://0.0.0.0:26656" => "tcp://127.0.0.1:16656"
```

* Open .ica/config/app.toml file and chage the ports.

``` toml
api.enable false => true
api.address "tcp://0.0.0.0:1317" => "tcp://0.0.0.0:1318"

grpc.address "0.0.0.0:9090" => "0.0.0.0:9100"
grpc-web.address "0.0.0.0:9091" => "0.0.0.0:9101"
```
* Start the ICA demo app node

``` bash
icad start
```

* Now open hermes configuration file and remove osmosis chain information and add the following ICA demo chain information to the `config.toml` file.

``` toml
[[chains]]
id = 'icademo-1'
rpc_addr = 'http://localhost:16657'
grpc_addr = 'http://localhost:9100'
websocket_addr = 'ws:/localhost:16657/websocket'
rpc_timeout = '15s'
account_prefix = 'cosmos'
key_name = 'key1'
store_prefix = 'ibc'
gas_price = { price = 0.01, denom = 'stake' }
max_gas = 10000000
clock_drift = '5s'
trusting_period = '1days'
trust_threshold = { numerator = '1', denominator = '3' }
```

* Now add a relayer account for ICA demo chain.

``` bash
hermes keys add --chain icademo-1 --mnemonic-file <path-to-relayer-mnemonic-file>
```

* After adding account start the hermes relayer.

``` bash
hermes start
```

* Create a new connection between Paloma chain and ICA demo chain

``` bash 
hermes create connection --a-chain paloma-1 --b-chain icademo-1
```
* Note down channel and connection


#### create interchain account on paloma chain

``` bash
# Register an interchain account on behalf of key1
icad tx intertx register --from key1 --connection-id connection-0 --chain-id icademo-1 --node tcp://localhost:16657 --keyring-backend test -y


export ICADEMO_KEY1=$(icad keys show -a key1 --keyring-backend test)

# Query the address of the interchain account
icad query intertx interchainaccounts connection-0 $ICADEMO_KEY1 --node tcp://localhost:16657



# Store the interchain account address by parsing the query result
export ICADEMO_ADDR=$(icad query intertx interchainaccounts connection-0 $ICADEMO_KEY1 --node tcp://localhost:16657 -o json | jq -r '.interchain_account_address') && echo $ICADEMO_ADDR
```

#### Funding the Interchain Account wallet

``` bash
# Query the interchain account balance on the host chain. It should be empty.
palomad q bank balances $ICADEMO_ADDR --chain-id paloma-1 --node tcp://localhost:26657

# Send funds to the interchain account.
palomad tx bank send key1 $ICADEMO_ADDR 10000ugrain --chain-id paloma-1 --node tcp://localhost:26657 --keyring-backend test -y

# Query the balance once again and observe the changes
icad q bank balances $ICADEMO_ADDR --chain-id test-2 --node tcp://localhost:26657
```

#### Sending ICA transactions

``` bash
# Submit a staking delegation tx using the interchain account via ibc
icad tx intertx submit \
'{
    "@type":"/cosmos.staking.v1beta1.MsgDelegate",
    "delegator_address":"<SET $ICADEMO_ADDR HERE>",
    "validator_address":"<PALOMA NODE VALIDATOR ADDRESS>",
    "amount": {
        "denom": "ugrain",
        "amount": "10"
    }
}' --connection-id connection-0 --from key1 --chain-id icademo-1 --node tcp://localhost:16657 --keyring-backend test -y

# Inspect the staking delegations of ICA account on the host chain 
palomad q staking delegations $ICADEMO_ADDR
```


* Follow same steps if you want to create ICA account from the Paloma chain.