> ## Documentation Index
> Fetch the complete documentation index at: https://docs.uatu.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Adding a chain

> Extend the catalogue with a new EVM network.

Chain definitions are JSON files in `internal/blockchains/`, embedded into the binary
at build time.

<Steps>
  <Step title="Add the definition">
    Drop a JSON file into `internal/blockchains/`. It describes the chain, the tokens
    the seeder should walk, and the DEX deployments to price against.

    ```json theme={null}
    {
      "name": "Ethereum",
      "symbol": "ETH",
      "chainId": 1,
      "blockExplorer": "https://etherscan.io",
      "rpcUrl": "https://ethereum-rpc.publicnode.com",
      "nativeToken": "ETH",
      "blockChainLogo": "https://…/ethereum-eth-logo.svg",
      "tokens": [
        {
          "name": "Wrapped Ether",
          "symbol": "WETH",
          "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
          "decimals": 18,
          "logo": "https://…/eth.svg",
          "slug": "weth"
        }
      ],
      "dex": []
    }
    ```
  </Step>

  <Step title="Wire up the RPC endpoint">
    Add the chain's `*_RPC_URL` to the config struct and to your environment.

    ```env theme={null}
    MYCHAIN_RPC_URL=https://…
    ```
  </Step>

  <Step title="Rebuild">
    Definitions are embedded at build time, so a rebuild is required. Editing the
    JSON alone changes nothing in a running binary.

    ```sh theme={null}
    go build -o bin/uatu-cli ./cmd/cli
    ```
  </Step>

  <Step title="Re-seed">
    ```sh theme={null}
    uatu-cli seed
    ```

    The seeder queries the v2 and v3 factories over RPC and persists the pools it
    finds. Mind the [clean-database caveat](/self-hosting/running): only the
    `blockchains` insert upserts.
  </Step>
</Steps>

## Getting the DEX entry right

Each entry in `dex` carries the addresses uatu prices and encodes against. Which ones
matter depends on the protocol version: `v2FactoryAddress` and `v2RouterAddress` for
v2-style pools, `v3FactoryAddress`, `v3RouterAddress` and `v3QuoterAddress` for v3,
plus `universalRouterAddress`, `permit2Address` and `settlementAddress` where the
protocol uses them.

A DEX `slug` only needs to be unique within its chain. The same protocol on two
chains reuses the slug with different addresses.

<Tip>
  Copy the shape from an existing definition on a chain running the same protocol,
  then swap in the deployment addresses for your network.
</Tip>

## Verify

```sh theme={null}
curl "http://localhost:8080/blockchains" | grep -i mychain
curl "http://localhost:8080/blockchains/pools?chainId=<id>"
```

No pools usually means the seeder couldn't reach the RPC endpoint, or that the token
list produced no pairs the factories know about.
