---
title: Connect to a network
description: Select a network, verify its RPC chain ID, and read the atom creation cost from the MultiVault deployed there.
url: https://docs.intuition.systems/docs/build/connect
markdown_url: https://docs.intuition.systems/docs/build/connect.md
version: V2
llms_index: https://docs.intuition.systems/llms.txt
kind: how-to
reader:
  - app
packages:
  - '@0xintuition/deployments@0.1.1'
  - '@0xintuition/protocol@4.1.0'
---

Connect a read-only client to Intuition mainnet, testnet, or local Anvil and verify the MultiVault by reading its atom creation cost.

**Prompt for your agent:** Verify a network and read its atom creation cost

```text
Goal: write a read-only script that proves my app is talking to the right Intuition network.
Read https://docs.intuition.systems/docs/build/connect.md, https://docs.intuition.systems/docs/reference/networks.md and https://docs.intuition.systems/docs/contracts/deployments.md.
Use exact package versions from https://docs.intuition.systems/intuition-release.json and public entry points only.
Network: Intuition testnet, chain 13579, unless I say otherwise. Resolve the MultiVault address for that chain from the deployments package.
Before any contract call, read the RPC chain ID and stop with a clear error if it does not match.
Then read getAtomCost and getAtomUriConfig from MultiVault and print them, with the cost in both wei and TRUST.
Make no writes and request no signatures.
Report the checks you actually ran and anything you could not verify.
```

## Before you start

Use Node 22.21.0 and the dependencies in the [pinned install guide](https://docs.intuition.systems/docs/build/install). The commands below run from a checkout of the docs repository containing the example. Install its dependencies with `npm ci --prefix examples/v2 --ignore-scripts`. For Anvil, complete the deployment step in [Test locally](https://docs.intuition.systems/docs/build/test-locally) first. The helper needs only the public RPC and contract address. [Complete connection helper](https://github.com/0xIntuition/intuition-docs/blob/bb420395aff3432f1f5da08cb76ac75a99945bff/examples/v2/first-write/src/connect-guide.ts).

## Steps

### 1. Choose the chain and deployment together

| Target | Chain ID | RPC seen by the caller | MultiVault source |
| --- | --- | --- | --- |
| Intuition mainnet | 1155 | `https://rpc.intuition.systems/http` | Mainnet package entry |
| Intuition testnet | 13579 | `https://testnet.rpc.intuition.systems/http` | Testnet package entry |
| Local Anvil | 31337 | `http://localhost:8545` on the host, `http://anvil:8545` inside Core's Compose network | `.MultiVault` from your completed deployment's `devnet/deployments-devnet.json` |

The deployments package resolves an override for the named contract and chain first, then consults its built-in table. A missing entry throws. The package has no built-in MultiVault for 31337, so copy the proxy address generated for your running Anvil. [Network definitions](https://github.com/0xIntuition/packages/blob/ccae0f0d0277cddd8490b72c49d3771866e7ffea/packages/deployments/src/networks.ts) and [address lookup](https://github.com/0xIntuition/packages/blob/ccae0f0d0277cddd8490b72c49d3771866e7ffea/packages/deployments/src/helpers.ts).

```ts
import {
  getMultiVaultAddressFromChainId,
  intuitionMainnet,
  intuitionTestnet,
} from '@0xintuition/deployments';
import { multiVaultGetAtomCost } from '@0xintuition/protocol';
import {
  createPublicClient,
  getAddress,
  http,
  isAddress,
  zeroAddress,
} from 'viem';
import { foundry } from 'viem/chains';

export function networkSettings(args: string[]) {
  const [name, deployedAddress] = args;
  if (args.length === 1 && (name === 'mainnet' || name === 'testnet')) {
    const chain = name === 'mainnet' ? intuitionMainnet : intuitionTestnet;
    return {
      chain,
      rpc: chain.rpcUrls.default.http[0],
      address: getMultiVaultAddressFromChainId(chain.id),
    };
  }

  if (args.length !== 2 || (name !== 'local' && name !== 'local-container'))
    throw new Error(
      'Choose mainnet, testnet, local ADDRESS or local-container ADDRESS.',
    );
  if (
    deployedAddress?.length !== 42 ||
    !isAddress(deployedAddress) ||
    deployedAddress === zeroAddress
  )
    throw new Error(
      'Supply the MultiVault proxy address from your local deployment.',
    );
  return {
    chain: foundry,
    rpc: name === 'local' ? 'http://localhost:8545' : 'http://anvil:8545',
    address: getMultiVaultAddressFromChainId(foundry.id, {
      MultiVault: { [foundry.id]: getAddress(deployedAddress) },
    }),
  };
}
```

### 2. Verify the chain before calling the contract

The client asks the RPC for its actual chain ID. After a match, `multiVaultGetAtomCost` reads the selected MultiVault's base creation cost in wei. Run one command for your chosen network.

```ts
export async function connect(args: string[]) {
  const { chain, rpc, address } = networkSettings(args);
  const publicClient = createPublicClient({
    chain,
    transport: http(rpc, { timeout: 5000, retryCount: 0 }),
  });
  const actual = await publicClient.getChainId();
  if (actual !== chain.id)
    throw new Error(
      `Expected chain ${chain.id}, but the RPC returned ${actual}.`,
    );
  const atomCost = await multiVaultGetAtomCost({ publicClient, address });
  return {
    chainId: actual,
    multiVault: address,
    atomCostWei: atomCost.toString(),
  };
}
```

```sh
node examples/v2/first-write/src/connect-guide.ts testnet
```

Use `mainnet` for mainnet. For a local read on your host, set `CORE_DIR` to your Core checkout and use the file produced by the successful deployment job. With `jq` installed, run the following command from the docs checkout.

```sh
vault=$(jq -er 'select(.chainId == 31337) | .MultiVault' "$CORE_DIR/devnet/deployments-devnet.json") &&
  node examples/v2/first-write/src/connect-guide.ts local "$vault"
```

An application running inside the same Compose network can use `local-container` with that address. Anvil's service name resolves there. A browser or Node process running on the host uses `localhost`.

## Check the result

The CLI prints `chainId`, `multiVault` and a decimal string named `atomCostWei`. Compare the chain ID to the table and, on Anvil, the proxy to the generated deployment file. The observed cost belongs to that contract at read time. Mainnet uses TRUST and testnet uses tTRUST, each with 18 decimal places. [Public deployment table](https://github.com/0xIntuition/packages/blob/ccae0f0d0277cddd8490b72c49d3771866e7ffea/packages/deployments/src/deployments.ts).

## Troubleshooting

| Result | What to check |
| --- | --- |
| Unexpected chain ID | Confirm which RPC the selected environment reaches. |
| Connection refused on 31337 | Check Anvil is running and choose the hostname for your calling process. |
| Missing address, empty return data, or reverted read | Verify the proxy belongs to this chain and still has the expected contract after any local redeployment. |

## Related

[Protocol writes](https://docs.intuition.systems/docs/concepts/protocol-writes) explains what changes when you introduce a signer. To read indexed atoms and triples, [query your own Core node](https://docs.intuition.systems/docs/build/query-core).

Applies to V2 · `@0xintuition/deployments` 0.1.1 · `@0xintuition/protocol` 4.1.0
