Skip to main content
@subsquid/evm-stream is the Portal-native EVM data source for Squid SDK. It replaces the gateway and RPC ingestion layer of EvmBatchProcessor with a DataSourceBuilder. Pass the built source to run() or Processor, or consume its stream directly.
Portal is public and does not use the SQD_API_KEY required by v2 gateways. To migrate an existing EvmBatchProcessor project, follow Migrate a squid to Portal.

Install

Complete example

DataHandlerContext from @subsquid/batch-processor contains {store, blocks, isHead}. It does not inject ctx.log or ctx._chain. Create a logger explicitly, as above, and add an RPC client only when your handler makes direct RPC calls.

DataSourceBuilder

All builder methods return the same builder unless noted.

setPortal(portal)

Required. Accepts a Portal URL, PortalClientOptions, or an existing PortalClient.

setBlockRange({from, to?})

Applies a global range to all requests. EVM ranges use block heights.

setFields(fields)

Selects fetched fields and narrows the inferred block type. There are no default optional fields. List every field the handler reads. Required identifiers such as header.number, header.hash, transactionIndex, logIndex, traceAddress, and state-diff kind/address/key remain available. The selectors are block, transaction, log, trace, and stateDiff. Trace action and result fields use prefixes such as callTo, callCallType, callResultOutput, and createResultAddress.

addLog(options)

addTransaction(options)

Filters support from, to, sighash, and type. Relations support logs, traces, and stateDiffs.

addTrace(options)

Filters support type, createFrom, callTo, callFrom, callSighash, suicideRefundAddress, and rewardAuthor. Relations support transaction, transactionLogs, subtraces, and parents.

addStateDiff(options)

Filters support address, key, and kind. Set include.transaction to include parent transactions.

includeAllBlocks(range?)

Includes blocks without matching items. Without it, Portal may omit empty blocks.

addQuery(query)

Adds a Query or QueryBuilder when several filters should share one range:
QueryBuilder also has addTrace(), addStateDiff(), and build().

build()

Returns an EVMDataSource. It throws Portal settings not set if setPortal() was not called. Pass the result to run() or Processor for restart-safe processing. You can also call getHead(), getFinalizedHead(), getStream(), getFinalizedStream(), and the optional getBlocksCountInRange() helper directly. See Read a data source directly.

Raw and augmented block types

The data source returns raw blocks from @subsquid/evm-stream. augmentBlock() from @subsquid/evm-objects adds IDs and navigation helpers such as log.getTransaction(), trace.getParent(), and transaction logs, traces, and stateDiffs collections. Use header.number for the block height. header.height remains available only as a deprecated alias.