> For the complete documentation index, see [llms.txt](https://docs.astralbeam.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.astralbeam.io/api-reference/chains.md).

# Chains

Endpoints for querying supported EVM chain information.

## List All Chains

Get all supported EVM chains with their configuration.

```
GET /api/v1/chains
```

### Query Parameters

| Name      | Type    | Default | Description                   |
| --------- | ------- | ------- | ----------------------------- |
| `enabled` | boolean | -       | Filter to only enabled chains |

### Response

```json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "chainId": 11155111,
      "name": "Ethereum Sepolia",
      "shortName": "sepolia",
      "rpcUrl": "https://rpc.sepolia.org",
      "explorerUrl": "https://sepolia.etherscan.io",
      "lockerAddress": "0x1234567890abcdef1234567890abcdef12345678",
      "nativeCurrency": "ETH",
      "confirmations": 64,
      "blockTime": 12.0,
      "isEnabled": true,
      "isPrimary": true
    },
    {
      "id": 2,
      "chainId": 84532,
      "name": "Base Sepolia",
      "shortName": "base-sepolia",
      "rpcUrl": "https://sepolia.base.org",
      "explorerUrl": "https://sepolia.basescan.org",
      "lockerAddress": "0xabcdef1234567890abcdef1234567890abcdef12",
      "nativeCurrency": "ETH",
      "confirmations": 64,
      "blockTime": 2.0,
      "isEnabled": true,
      "isPrimary": false
    },
    {
      "id": 3,
      "chainId": 421614,
      "name": "Arbitrum Sepolia",
      "shortName": "arbitrum-sepolia",
      "rpcUrl": "https://sepolia-rollup.arbitrum.io/rpc",
      "explorerUrl": "https://sepolia.arbiscan.io",
      "lockerAddress": "0x9876543210fedcba9876543210fedcba98765432",
      "nativeCurrency": "ETH",
      "confirmations": 64,
      "blockTime": 0.25,
      "isEnabled": true,
      "isPrimary": false
    }
  ]
}
```

### Robinhood rollout records

The migration seeds Robinhood Chain (`4663`) and Robinhood Chain Testnet (`46630`) with the following metadata:

| Chain                   | Short name          | RPC                                       | Explorer                                       | Block time | Confirmations | Enabled | Locker                                                                        |
| ----------------------- | ------------------- | ----------------------------------------- | ---------------------------------------------- | ---------: | ------------: | ------- | ----------------------------------------------------------------------------- |
| Robinhood Chain         | `robinhood`         | `https://rpc.mainnet.chain.robinhood.com` | `https://robinhoodchain.blockscout.com`        |       0.1s |        15,000 | `false` | `null` (undeployed; separate approval required)                               |
| Robinhood Chain Testnet | `robinhood-testnet` | `https://rpc.testnet.chain.robinhood.com` | `https://explorer.testnet.chain.robinhood.com` |       0.4s |         6,000 | `true`  | `0xaF0856690910F75DFA48e5F7CA4Af669be6c338d` (verified; round trip certified) |

These confirmation values are secondary depth floors. The relayer's primary mode is the protocol `finalized` block tag; `finalityMode` is relayer configuration and is not currently a field in the Chains API response. Until a locker is deployed and a row is explicitly enabled, `?enabled=true` excludes both records.

### Examples

**Get all chains:**

```bash
curl "https://api.csprbridge.com/api/v1/chains"
```

**Get only enabled chains:**

```bash
curl "https://api.csprbridge.com/api/v1/chains?enabled=true"
```

***

## Get Chain by ID

Get a specific chain by its chain ID.

```
GET /api/v1/chains/{chainId}
```

### Parameters

| Name      | In   | Type    | Required | Description  |
| --------- | ---- | ------- | -------- | ------------ |
| `chainId` | path | integer | yes      | EVM chain ID |

### Response

```json
{
  "success": true,
  "data": {
    "id": 1,
    "chainId": 11155111,
    "name": "Ethereum Sepolia",
    "shortName": "sepolia",
    "rpcUrl": "https://rpc.sepolia.org",
    "explorerUrl": "https://sepolia.etherscan.io",
    "lockerAddress": "0x1234567890abcdef1234567890abcdef12345678",
    "nativeCurrency": "ETH",
    "confirmations": 64,
    "blockTime": 12.0,
    "isEnabled": true,
    "isPrimary": true
  }
}
```

### Errors

| Code | Description     |
| ---- | --------------- |
| 404  | Chain not found |

### Example

```bash
curl "https://api.csprbridge.com/api/v1/chains/11155111"
```

***

## Get All Explorer URLs

Get block explorer URLs for all chains including Casper.

```
GET /api/v1/chains/explorers/all
```

### Response

```json
{
  "success": true,
  "data": {
    "casper": {
      "url": "https://testnet.cspr.live",
      "txPath": "/deploy/",
      "addressPath": "/account/"
    },
    "sepolia": {
      "url": "https://sepolia.etherscan.io",
      "txPath": "/tx/",
      "addressPath": "/address/"
    },
    "base-sepolia": {
      "url": "https://sepolia.basescan.org",
      "txPath": "/tx/",
      "addressPath": "/address/"
    },
    "arbitrum-sepolia": {
      "url": "https://sepolia.arbiscan.io",
      "txPath": "/tx/",
      "addressPath": "/address/"
    }
  }
}
```

### Usage

Build explorer URLs programmatically:

```javascript
const explorers = await getExplorers();
const txUrl = `${explorers.sepolia.url}${explorers.sepolia.txPath}${txHash}`;
// https://sepolia.etherscan.io/tx/0x...
```

### Example

```bash
curl "https://api.csprbridge.com/api/v1/chains/explorers/all"
```

***

## Chain Schema

### Chain Object

| Field            | Type         | Description                                                         |
| ---------------- | ------------ | ------------------------------------------------------------------- |
| `id`             | integer      | Database ID                                                         |
| `chainId`        | integer      | EVM chain ID (e.g., 11155111)                                       |
| `name`           | string       | Full display name                                                   |
| `shortName`      | string       | Short identifier (used in API paths)                                |
| `rpcUrl`         | string       | Public RPC endpoint                                                 |
| `explorerUrl`    | string       | Block explorer base URL                                             |
| `lockerAddress`  | string\|null | MultiSigLocker contract address; `null` while deployment is pending |
| `nativeCurrency` | string       | Native currency symbol (e.g., "ETH")                                |
| `confirmations`  | integer      | Required confirmations for finality                                 |
| `blockTime`      | number       | Average block time in seconds                                       |
| `isEnabled`      | boolean      | Whether chain is actively supported                                 |
| `isPrimary`      | boolean      | Whether this is the primary chain                                   |

### Known Chain IDs

| Chain                   | Chain ID | Short Name        |
| ----------------------- | -------- | ----------------- |
| Ethereum Mainnet        | 1        | ethereum          |
| Ethereum Sepolia        | 11155111 | sepolia           |
| Base Mainnet            | 8453     | base              |
| Base Sepolia            | 84532    | base-sepolia      |
| Arbitrum One            | 42161    | arbitrum          |
| Arbitrum Sepolia        | 421614   | arbitrum-sepolia  |
| Optimism                | 10       | optimism          |
| Polygon Mainnet         | 137      | polygon           |
| Polygon Amoy            | 80002    | polygon-amoy      |
| Robinhood Chain         | 4663     | robinhood         |
| Robinhood Chain Testnet | 46630    | robinhood-testnet |

***

## Usage Examples

### JavaScript: Chain Selector

```javascript
async function getChainOptions() {
  const response = await fetch(
    'https://api.csprbridge.com/api/v1/chains?enabled=true'
  );
  const { data: chains } = await response.json();

  return chains.map(chain => ({
    value: chain.chainId,
    label: chain.name,
    shortName: chain.shortName,
    icon: getChainIcon(chain.shortName)
  }));
}
```

### JavaScript: Build Explorer Link

```javascript
async function getExplorerLink(chain, type, hash) {
  const response = await fetch(
    'https://api.csprbridge.com/api/v1/chains/explorers/all'
  );
  const { data: explorers } = await response.json();

  const explorer = explorers[chain];
  if (!explorer) return null;

  const path = type === 'tx' ? explorer.txPath : explorer.addressPath;
  return `${explorer.url}${path}${hash}`;
}

// Usage
const txLink = await getExplorerLink('sepolia', 'tx', '0xabc...');
// https://sepolia.etherscan.io/tx/0xabc...
```

### Python: Get Chain Config

```python
import requests

def get_chain_config(chain_id):
    """Get configuration for a specific chain."""
    response = requests.get(
        f'https://api.csprbridge.com/api/v1/chains/{chain_id}'
    )

    if response.status_code == 404:
        return None

    return response.json()['data']

# Get Sepolia config
sepolia = get_chain_config(11155111)
print(f"Locker: {sepolia['lockerAddress']}")
print(f"Confirmations: {sepolia['confirmations']}")
```

### curl with jq

```bash
# List all chain IDs and names
curl -s "https://api.csprbridge.com/api/v1/chains" | \
  jq '.data[] | {chainId, name, shortName}'

# Get locker addresses for all chains
curl -s "https://api.csprbridge.com/api/v1/chains?enabled=true" | \
  jq '.data[] | {chain: .shortName, locker: .lockerAddress}'

# Build explorer URL for transaction
TX_HASH="0xabc123..."
curl -s "https://api.csprbridge.com/api/v1/chains/explorers/all" | \
  jq --arg hash "$TX_HASH" '.data.sepolia | "\(.url)\(.txPath)\($hash)"'
```

### React: Chain Dropdown Component

```jsx
import { useState, useEffect } from 'react';

function ChainSelector({ value, onChange }) {
  const [chains, setChains] = useState([]);

  useEffect(() => {
    fetch('https://api.csprbridge.com/api/v1/chains?enabled=true')
      .then(res => res.json())
      .then(({ data }) => setChains(data));
  }, []);

  return (
    <select value={value} onChange={e => onChange(Number(e.target.value))}>
      <option value="">Select Chain</option>
      {chains.map(chain => (
        <option key={chain.chainId} value={chain.chainId}>
          {chain.name}
        </option>
      ))}
    </select>
  );
}
```

***

## Adding Chain to Wallet

Use chain data to add network to MetaMask:

```javascript
async function addChainToWallet(chainId) {
  const response = await fetch(
    `https://api.csprbridge.com/api/v1/chains/${chainId}`
  );
  const { data: chain } = await response.json();

  await window.ethereum.request({
    method: 'wallet_addEthereumChain',
    params: [{
      chainId: `0x${chainId.toString(16)}`,
      chainName: chain.name,
      nativeCurrency: {
        name: chain.nativeCurrency,
        symbol: chain.nativeCurrency,
        decimals: 18
      },
      rpcUrls: [chain.rpcUrl],
      blockExplorerUrls: [chain.explorerUrl]
    }]
  });
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.astralbeam.io/api-reference/chains.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
