# 🧵 Setting up connection to IBC with Hermes

### *Prerequisites*

* A Linux server (Ubuntu/Debian recommended)
* Minimum: 4 GB RAM, 2 CPU, 100 GB SSD
* Rust and Cargo installed
* Access to RPC nodes for Celestia and Osmosis (or own full nodes)
* Wallets funded with a small amount of TIA (Celestia) and OSMO (Osmosis)

### *Install Hermes Relayer*

```bash
# Update system
sudo apt update && sudo apt upgrade -y

# Install dependencies
sudo apt install -y build-essential git curl jq pkg-config libssl-dev

# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

# Clone and install Hermes
git clone https://github.com/informalsystems/hermes.git
cd hermes
git checkout v1.13.0  # Use a stable version
cargo install --locked --path crates/relayer-cli

# Verify installation
hermes version
```

***

### *Configure Hermes with Fee Support*

```bash
# Create config directory
mkdir -p $HOME/.hermes/keys

# Create configuration file
cat > $HOME/.hermes/config.toml << EOF
[global]
log_level = 'info'
clear_packets_interval = 100
tx_confirmation = true

[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

[rest]
enabled = true
host = '127.0.0.1'
port = 3000

[telemetry]
enabled = true
host = '127.0.0.1'
port = 3001

[[chains]]
id = 'celestia'
type = 'CosmosSdk'
rpc_addr = 'https://rpc.celestia.org:443'
grpc_addr = 'https://grpc.celestia.org:443'
websocket_addr = 'wss://rpc.celestia.org:443/websocket'
rpc_timeout = '10s'
account_prefix = 'celestia'
key_name = 'celestia-key'
key_store_type = 'Test'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.025, denom = 'utia' }
gas_multiplier = 1.3
max_msg_num = 30
max_tx_size = 180000
clock_drift = '5s'
max_block_time = '30s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }

[[chains.packet_filter]]
policy = 'allow'
list = [
  ['transfer', '*'],
]

[chains.packet_filter.min_fees]
enabled = true
recv_fee = [{ amount = "100", denom = "utia" }]
ack_fee = [{ amount = "100", denom = "utia" }]
timeout_fee = [{ amount = "100", denom = "utia" }]

[[chains]]
id = 'osmosis-1'
type = 'CosmosSdk'
rpc_addr = 'https://rpc.osmosis.zone:443'
grpc_addr = 'https://grpc.osmosis.zone:443'
websocket_addr = 'wss://rpc.osmosis.zone:443/websocket'
rpc_timeout = '10s'
account_prefix = 'osmo'
key_name = 'osmo-key'
key_store_type = 'Test'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.025, denom = 'uosmo' }
gas_multiplier = 1.3
max_msg_num = 30
max_tx_size = 180000
clock_drift = '5s'
max_block_time = '30s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }

[[chains.packet_filter]]
policy = 'allow'
list = [
  ['transfer', '*'],
]

[chains.packet_filter.min_fees]
enabled = true
recv_fee = [{ amount = "100", denom = "uosmo" }]
ack_fee = [{ amount = "100", denom = "uosmo" }]
timeout_fee = [{ amount = "100", denom = "uosmo" }]
EOF
```

***

### *Add Wallet Keys*

```bash
# Save your mnemonics securely
echo "your celestia mnemonic here" > $HOME/celestia_mnemonic.txt
echo "your osmosis mnemonic here" > $HOME/osmosis_mnemonic.txt
chmod 600 $HOME/celestia_mnemonic.txt $HOME/osmosis_mnemonic.txt

# Import keys
hermes keys add --chain celestia --mnemonic-file $HOME/celestia_mnemonic.txt
hermes keys add --chain osmosis-1 --mnemonic-file $HOME/osmosis_mnemonic.txt

# Check keys
hermes keys list --chain celestia
hermes keys list --chain osmosis-1
```

***

### *Validate Configuration and Network Access*

```bash
# Validate Hermes configuration
hermes config validate

# Check network health
hermes health-check
```

***

### *Create Clients, Connections, and Channel*

```bash
# Create clients
hermes create client --host-chain celestia --reference-chain osmosis-1
hermes create client --host-chain osmosis-1 --reference-chain celestia

# Query created clients
hermes query clients --host-chain celestia
hermes query clients --host-chain osmosis-1

# Create connection
hermes create connection --a-chain celestia --b-chain osmosis-1

# Query connections
hermes query connections --chain celestia
hermes query connections --chain osmosis-1

# Create channel for token transfers
hermes create channel --a-chain celestia --b-chain osmosis-1 --a-port transfer --b-port transfer --new-client-connection

# Query channels
hermes query channels --chain celestia
hermes query channels --chain osmosis-1
```

***

### *Run Hermes Relayer*

```bash
# Run Hermes in background
nohup hermes start > hermes.log 2>&1 &

# Check if running
ps aux | grep hermes

# View logs
tail -f hermes.log
```

***

### *Setup Hermes as a systemd Service*

```bash
# Create a systemd service
sudo tee /etc/systemd/system/hermes.service > /dev/null << EOF
[Unit]
Description=Hermes IBC Relayer
After=network-online.target

[Service]
User=$USER
ExecStart=$(which hermes) start
Restart=always
RestartSec=3
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target
EOF

# Enable and start service
sudo systemctl daemon-reload
sudo systemctl enable hermes
sudo systemctl start hermes

# Check service status
sudo systemctl status hermes
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://services.validexis.com/setting-up-connection-to-ibc-with-hermes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
