# Relayer

Relayers are in charge of delivering and tracking [IBC](https://ibc.cosmos.network/main) packets.

## Hermes

### Prerequisites

* Rust 1.72 +

### Clone Repository

Open a terminal and clone Hermes repository.

```shell
git clone https://github.com/informalsystems/hermes.git
```

Change to the repository directory.

```bash
cd hermes
```

### Install and Setup Hermes

```bash
cargo install --path ./crates/ibc-relayer-cli

# check installed herems
hermes --version

# create working directory for herems
mkdir ~/.hermes

# copy default config.toml to working directory
cp ./config.toml ~/.hermes/config.toml
```

### Update Chain Configs

Append following chain configs to `~/.hermes/config.toml` and remove pre-existing `ibc-0` & `ibc-1` chain configs. You need to replace all config sections with `<>` to real values.

{% hint style="info" %}
You are highly recommended to use your own RPC endpoints for both l1 and l2.
{% endhint %}

```toml
...

[[chains]]
id = '<l1-chain-id>' # mahalo-1
type = "CosmosSdk"
rpc_addr = '<l1-rpc-endpoint>' # https://rpc.mahalo-1.initia.xyz (mahalo-1)
grpc_addr = '<l1-grpc-endpoint>' # http://34.143.171.2:9090 (mahalo-1)
event_source = { mode = 'push', url = '<l1-websocket-endpoint>', batch_delay = '500ms' } # wss://rpc.mahalo-1.initia.xyz/websocket (mahalo-1)
rpc_timeout = '10s'
trusted_node = false
account_prefix = 'init'
key_name = 'relayer'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.15, denom = 'uinit' }
gas_multiplier = 1.5
max_msg_num = 30
max_tx_size = 2097152
clock_drift = '5s'
max_block_time = '10s'
address_type = { derivation = 'cosmos' }

[[chains]]
id = '<l2-chain-id>' # $L2_CHAIN_ID
type = "CosmosSdk"
rpc_addr = '<l2-rpc-endpoint>' # http://127.0.0.1:26657
grpc_addr = '<l2-grpc-endpoint>' # http://127.0.0.1:9090
event_source = { mode = 'push', url = '<l2-websocket-endpoint>', batch_delay = '500ms' } # ws://127.0.0.1:26657/websocket
rpc_timeout = '10s'
trusted_node = false
account_prefix = 'init'
key_name = 'relayer'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.15, denom = '<denom>' } # $DENOM
gas_multiplier = 1.5
max_msg_num = 30
max_tx_size = 2097152
clock_drift = '5s'
# this should be configured as `2 * create_empty_blocks_interval`
# in your ~/.minitia/config/config.toml
max_block_time = '2m0s' 
address_type = { derivation = 'cosmos' }

```

### Create Relayer Key

{% hint style="info" %}
You need to fund the relayer account before setting the keys on both L1 and L2.
{% endhint %}

```bash
# create temporal keyfile for herems
echo "relayer mnemonic" > mnemonic.key

# add relayer key for the chains
hermes keys add --key-name relayer --chain $L1_CHAIN_ID --mnemonic-file ./mnemonic.key
hermes keys add --key-name relayer --chain $L2_CHAIN_ID --mnemonic-file ./mnemonic.key

rm ./mnemonic.key
```

## Channel transfer channel

```bash
# create channel with clients and connections
# tooks 5 minutes (send any tx to boost)
hermes create channel \
  --a-chain $L1_CHAIN_ID \
  --b-chain $L2_CHAIN_ID \
  --a-port transfer \
  --b-port transfer \
  --new-client-connection 

SUCCESS Channel {
    ...
}
```

### Start Hermes

```bash
hermes start
```


---

# 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://initia.gitbook.io/initia/kBNuZF5MglV9d3zOOUeW/developers/build-your-own-minitia/connect-minitia-to-l1/relayer.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.
