Skip to main content
EvmRpcDataSourceBuilder builds a data source that ingests EVM data from any JSON-RPC endpoint. It is the RPC counterpart of the EVM Portal stream: the query surface (setFields, addLog, addTransaction, addTrace, addStateDiff, includeAllBlocks, addQuery) is identical, and the built source runs anywhere a Portal source does — including run() and Processor and the EVM fallback data source. The only difference is setRpc(...) in place of setPortal(...). Use it when a Portal dataset is not available for your network, or as a standby source behind a Portal primary — see High availability.

Install

@subsquid/evm-rpc and @subsquid/evm-normalization are optional peers of the SDK package — required only when an RPC source is used.

Complete example

setRpc(options)

Accepts a bare endpoint URL string, or an options object:

Network presets

Setting network to a known slug (or its chainId) enables block validation and selects the right trace/debug methods for that chain, so the produced dataset matches what the Portal serves: ethereum-mainnet, optimism-mainnet, base-mainnet, arbitrum-one, gnosis-mainnet, polygon-mainnet, cronos-mainnet Known slugs are offered in TypeScript autocomplete. Any other slug or chainId is accepted but runs without a preset.
With no matching preset and no explicit rpc/method overrides, block validation is disabled and dataset parity with the Portal is not guaranteed — the source logs a warning at build time. Supplying your own rpc/method overrides counts as taking ownership of the per-chain configuration and silences the warning.

Query methods

setFields, setBlockRange, addLog, addTransaction, addTrace, addStateDiff, includeAllBlocks, and addQuery behave exactly as on the Portal builder — see the EVM Portal stream reference for the full query surface.

build()

Returns an EVM data source with the standard interface (getHead, getFinalizedHead, getStream, getFinalizedStream). Pass it to run() or Processor, use it as a downstream source of an EVM fallback, or consume the stream directly. Throws if setRpc(...) was not called.