@subsquid/solana-stream is the Portal-native Solana data source for Squid SDK. DataSourceBuilder.build() returns a source that you can pass to run() or Processor, or consume directly.
Complete example
{store, blocks, isHead}. It does not inject ctx.log.
Builder methods
setPortal(portal) is required and accepts a URL, PortalClientOptions, or PortalClient. build() throws Portal settings not set when it is omitted.
setBlockRange({from, to?}) applies a global range. Solana ranges use slot numbers, the same values returned as block.header.number. includeAllBlocks(range?) includes blocks without matching items.
setFields(fields) has no default optional fields. The selector sections are block, transaction, instruction, log, balance, tokenBalance, and reward.
addQuery(query) accepts a Query or QueryBuilder when several filters share one range. The builder also provides these shorthands:
| Method | where filters | include relations |
|---|---|---|
addTransaction() | feePayer | instructions, logs, balances, tokenBalances |
addInstruction() | programId, d1, d2, d3, d4, d8, discriminator, a0 through a9, isCommitted | transaction, transactionBalances, transactionTokenBalances, transactionInstructions, logs, innerInstructions |
addLog() | programId, kind | transaction, instruction |
addBalance() | account | transaction, transactionInstructions |
addTokenBalance() | account, preProgramId, postProgramId, preMint, postMint, preOwner, postOwner | transaction, transactionInstructions |
addReward() | pubkey | none |
0x-prefixed hexadecimal byte prefixes. The d1, d2, d3, d4, and d8 filters require exactly that many bytes; discriminator accepts any prefix length.
build()
Returns the Solana data source. Pass it 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.
Block data
Each block hasheader, transactions, instructions, logs, balances, tokenBalances, and rewards.
Required header fields are:
slot and parentSlot are not field names. Use number and parentNumber.
The stream converts Portal’s raw Solana block time from seconds to milliseconds. Pass timestamp directly to new Date(timestamp) without multiplying it by 1000.
Balances use one account per item:
pre* fields describe the value before the transaction and post* fields describe it after the transaction.
Prometheus
Pass aPrometheusServer through the fourth run() argument:
PROCESSOR_PROMETHEUS_PORT takes precedence over PROMETHEUS_PORT. Metrics are disabled if neither variable is set.
Solana typegen
@subsquid/solana-typegen accepts an Anchor IDL file, an HTTP(S) IDL URL, or a program address. For addresses it checks the chain and the SolanaFM registry.
@subsquid/solana-stream also exports getInstructionData() and getInstructionDescriptor() for working with generated instruction metadata.