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

# Chain data sources

> Read contract state and accounts from Ethereum, Base, Polygon, Arbitrum, Solana and other chains in a source, and choose a finality that every node agrees on.

A source can read chain state as well as HTTP APIs. An input of kind `evm`, `starknet` or `svm` names a chain by its CAIP-2 id, never an RPC endpoint: each node reads through its own providers, so no single operator or provider sits in every node's read path. For how an input fits into a source, see [Source format](https://docs.molpha.io/concepts/sources.md#inputs).

## What a source can read

| Kind | Reads | Decoded with |
| - | - | - |
| `evm` | A contract call (`sig` and `args`, or raw `data`), a storage slot, or an account balance | `abi` |
| `starknet` | A contract call or a storage slot | `felts` |
| `svm` | An account's data, an account's metadata (`accountInfo`: `lamports`, `owner`, `executable`, `space`), or a token mint's supply | `layout` for account data; none for `accountInfo` and `tokenSupply` |

```ts theme={null}
import { defineSource, sx } from "@molpha/sdk";

// USDC's decimals on Base, read at a block at least 30 s old and 10 blocks deep.
const source = defineSource({
  inputs: {
    usdc: sx.evmCall({
      chain: "eip155:8453", to: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", sig: "decimals()",
      finality: { mode: "confirmations", n: 10, lagMs: 30_000 },
      decode: sx.abiDecode(["uint256"], { v: "0" }),
    }),
  },
  transform: sx.ref("usdc.v"),
  output: { type: "uint256", decimals: 0 },
});
```

> [!NOTE]
>
> Starknet addresses, keys and calldata are canonical felts: `0x`, lowercase hex, **no leading zeros**. Explorers show the Starknet ETH token as `0x049d3657…`; write `0x49d3657…`. A zero-padded value is rejected with `must be a canonical felt`.

## One block for every node (EVM and Starknet)

Nodes do not each read "the latest block": they would disagree, and exact mode needs every node to sign the same bytes. Instead the round's timestamp fixes the block. For a round at time `t` the nodes read the newest block at or before `t - lagMs` that is also final enough, so every honest node derives the same block number and reads the same state, whichever of its endpoints answers. That is why a value that changes every few minutes, such as a price oracle's answer, can be signed in **exact** mode when it is read on-chain. A transform can refer to the pinned block as `$block` when the source has exactly one chain input.

`finality` has three parts:

| Field | Meaning |
| - | - |
| `mode` | `finalized` or `safe` (the chain's own tags), or `confirmations` (the block must be `n` blocks deep). Starknet offers `finalized` and `confirmations`. |
| `lagMs` | How far behind the round to read, a multiple of 1000. It must be at least the chain's minimum for the mode and at most its state window. |
| `n` | For `confirmations`, how many blocks deep (1 up to the chain's maximum). `null` otherwise. |

A node needs a block that is both older than `t - lagMs` **and** final. If the chain's finalized head is newer than the pinned time (the lag is shorter than the finality delay), no block qualifies: the node waits out the round and refuses it with `finality head has not reached the pinned time`. The minimums below exist to prevent that, and a gateway refuses a source outside them with a `400` before anything is reserved.

> [!NOTE]
>
> Ethereum's `finalized` head is two to three epochs old (13 to 19 minutes) and its `safe` head one to two epochs (6 to 13 minutes), so the minimum lags are **20 minutes** and **14 minutes**. A lag of 15 minutes looks reasonable and fails about half the time.

For `confirmations` the minimum lag is `(n + 2)` block times, rounded up to a whole second: the pinned block must be `n` deep with a block or two of propagation to spare.

The upper bound is the **state window**: about 120 blocks, within the roughly 128 recent states a pruned full node keeps. A longer lag would read state that some node can no longer serve.

## Solana accounts

Solana reads are not pinned to a block: nodes read the account at the commitment you choose (`finalized` or `confirmed`) and refuse a read whose slot is older than `maxAgeMs`. Nodes land on slots a few hundred milliseconds apart, so an account that changes every slot (an AMM pool, an order book) gives different bytes on different nodes and fails in exact mode. Use [tolerance mode](https://docs.molpha.io/concepts/feeds.md#exact-and-tolerance-mode) for those, or read something that changes slowly: a token mint's `decimals`, a configuration account.

A source cannot read an account owned by the Molpha program itself, so a feed's output can never become one of its own inputs.

## Supported chains

The list is published with the SDK (`CHAIN_LIST`, checked by `checkChains`) and enforced by the gateway and the nodes with the same numbers. They are protocol estimates, set conservatively, not measurements of each chain's current behavior.

### EVM

| Chain | CAIP-2 id | Block time | Finality modes | State window |
| - | - | - | - | - |
| Ethereum | `eip155:1` | 12 s | `finalized` (lag ≥ 20 min), `safe` (lag ≥ 14 min), `confirmations` (n ≤ 64) | ≤ 25 min |
| Ethereum Sepolia | `eip155:11155111` | 12 s | `finalized` (lag ≥ 20 min), `safe` (lag ≥ 14 min), `confirmations` (n ≤ 64) | ≤ 25 min |
| Base | `eip155:8453` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Base Sepolia | `eip155:84532` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Arbitrum One | `eip155:42161` | 1 s | `confirmations` (n ≤ 60) | ≤ 2 min |
| OP Mainnet | `eip155:10` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Polygon PoS | `eip155:137` | 2 s | `finalized` (lag ≥ 15 s), `confirmations` (n ≤ 60) | ≤ 4 min |
| BNB Smart Chain | `eip155:56` | 0.5 s | `finalized` (lag ≥ 5 s), `confirmations` (n ≤ 60) | ≤ 60 s |
| Avalanche C-Chain | `eip155:43114` | 2 s | `finalized` (lag ≥ 5 s), `confirmations` (n ≤ 60) | ≤ 4 min |
| Linea | `eip155:59144` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Scroll | `eip155:534352` | 3 s | `confirmations` (n ≤ 60) | ≤ 6 min |
| ZKsync Era | `eip155:324` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Blast | `eip155:81457` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Mantle | `eip155:5000` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Unichain | `eip155:130` | 1 s | `confirmations` (n ≤ 60) | ≤ 2 min |
| Celo | `eip155:42220` | 1 s | `confirmations` (n ≤ 60) | ≤ 2 min |
| Sei | `eip155:1329` | 0.5 s | `confirmations` (n ≤ 60) | ≤ 60 s |
| HyperEVM | `eip155:999` | 1 s | `confirmations` (n ≤ 60) | ≤ 2 min |
| Monad | `eip155:143` | 0.5 s | `finalized` (lag ≥ 5 s), `safe` (lag ≥ 3 s), `confirmations` (n ≤ 60) | ≤ 60 s |
| MegaETH | `eip155:4326` | 1 s | `confirmations` (n ≤ 60) | ≤ 2 min |
| Arbitrum Sepolia | `eip155:421614` | 1 s | `confirmations` (n ≤ 60) | ≤ 2 min |
| OP Sepolia | `eip155:11155420` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Polygon Amoy | `eip155:80002` | 2 s | `finalized` (lag ≥ 15 s), `confirmations` (n ≤ 60) | ≤ 4 min |
| BNB Smart Chain Testnet | `eip155:97` | 0.5 s | `finalized` (lag ≥ 5 s), `confirmations` (n ≤ 60) | ≤ 60 s |
| Avalanche Fuji | `eip155:43113` | 2 s | `finalized` (lag ≥ 5 s), `confirmations` (n ≤ 60) | ≤ 4 min |
| Linea Sepolia | `eip155:59141` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| ZKsync Sepolia | `eip155:300` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Blast Sepolia | `eip155:168587773` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Mantle Sepolia | `eip155:5003` | 2 s | `confirmations` (n ≤ 60) | ≤ 4 min |
| Unichain Sepolia | `eip155:1301` | 1 s | `confirmations` (n ≤ 60) | ≤ 2 min |
| Celo Sepolia | `eip155:11142220` | 1 s | `confirmations` (n ≤ 60) | ≤ 2 min |
| Sei Testnet | `eip155:1328` | 0.5 s | `confirmations` (n ≤ 60) | ≤ 60 s |
| HyperEVM Testnet | `eip155:998` | 1 s | `confirmations` (n ≤ 60) | ≤ 2 min |
| Monad Testnet | `eip155:10143` | 0.5 s | `finalized` (lag ≥ 5 s), `safe` (lag ≥ 3 s), `confirmations` (n ≤ 60) | ≤ 60 s |
| MegaETH Testnet | `eip155:6343` | 1 s | `confirmations` (n ≤ 60) | ≤ 2 min |

`finalized` is offered only where the tag tracks the chain's own finality within seconds. An Ethereum-settled rollup's `finalized` tag trails its head by 15 minutes to hours, far past its state window, so rollups offer `confirmations` only.

### Starknet

| Chain | CAIP-2 id | Block time | Finality modes | State window |
| - | - | - | - | - |
| Starknet | `starknet:SN_MAIN` | 6 s | `finalized` (lag ≥ 6 h), `confirmations` (n ≤ 100) | ≤ 24 h |
| Starknet Sepolia | `starknet:SN_SEPOLIA` | 6 s | `finalized` (lag ≥ 6 h), `confirmations` (n ≤ 100) | ≤ 24 h |

### Solana

| Cluster | CAIP-2 id | Commitments | `maxAgeMs` upper bound |
| - | - | - | - |
| Solana mainnet | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | `finalized` (maxAgeMs ≥ 20 s), `confirmed` (maxAgeMs ≥ 10 s) | ≤ 60 min |
| Solana devnet | `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1` | `finalized` (maxAgeMs ≥ 20 s), `confirmed` (maxAgeMs ≥ 10 s) | ≤ 60 min |

The Solana id is `solana:` followed by the first 32 characters of the cluster's genesis hash.

## Chains enabled on gateway.molpha.io

On 2026-11-30 the public gateway accepted chain inputs on these chains (`http` inputs need no chain):

| Kind | Chains |
| - | - |
| EVM | Ethereum (`eip155:1`), Ethereum Sepolia (`eip155:11155111`), Base (`eip155:8453`), Base Sepolia (`eip155:84532`), Arbitrum One (`eip155:42161`), Polygon PoS (`eip155:137`), BNB Smart Chain (`eip155:56`), Monad (`eip155:143`), HyperEVM (`eip155:999`) |
| Starknet | Starknet (`starknet:SN_MAIN`), Starknet Sepolia (`starknet:SN_SEPOLIA`) |
| Solana | Solana mainnet (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`), Solana devnet (`solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`) |

The current list is `previewChains` in [`GET /v1/info`](https://docs.molpha.io/gateways/api/info). A source can read mainnet state even though the Molpha program runs on Solana devnet: the chain an input reads and the chain an attestation is verified on are independent.

## Which chains a gateway and its nodes serve

Being on the list is necessary, not sufficient:

* **The gateway enables a subset.** A gateway accepts only the chains its operator has enabled, and answers `400` `chain … is not supported` for any other. The default is none, which serves HTTP sources only.
* **Every node must serve the chain.** A node serves a chain when it has an endpoint it has verified for it: API keys for the built-in RPC providers (Alchemy and Infura cover every chain above; Helius adds Solana), or the operator's own endpoints. A chain should be enabled on a gateway only when every active node serves it; otherwise rounds for it are refused with `chain … is not served by this node`, before any node does work.
* **Each chain has a fallback.** A node tries a chain's endpoints in order and moves to the next when one fails; an endpoint is verified once, at startup, against the chain it is configured for (its chain id or genesis hash) before it is ever used, so a misconfigured fallback cannot answer for the wrong network. Nodes do not re-check on a timer, so an idle node makes no chain RPC calls; a chain whose providers were all down at startup is checked again only when a round asks for it.

## Errors you may see

| Message | Meaning | Fix |
| - | - | - |
| `400` `source.inputs.<name>.chain: chain … is not supported` | The gateway has not enabled the chain, or it is not on the list | Use an enabled chain; ask the gateway's operator |
| `400` `…finality.lagMs: must be between X and Y for …` | The lag is outside the chain's bounds for that mode | Use a lag inside the range in the table |
| `503` `chain … is not served by this node` | The gateway enables the chain but the nodes do not all serve it | Operator: give the nodes provider keys |
| `503` `pinning …: finality head has not reached the pinned time` | The chain's finalized head is older than the pinned time (a lag at the edge of the minimum, or a chain that is behind) | Lengthen `lagMs` |
| `503` `reading …: slot … is older than maxAgeMs` | A Solana read was staler than the source allows | Raise `maxAgeMs` within its bound, or choose a faster commitment |

A `503` for a source that the nodes ran and could not evaluate is reported by the MCP server as `source_failed`; see [the tools' errors](https://docs.molpha.io/mcp/tools.md#errors).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.