Skip to main content
solanaInstructionDecoder() bundles a Solana instruction query with a decoding transform into a single reusable module. Pass the result as an output to solanaPortalStream:
solanaInstructionDecoder() can:
  • Fetch from one or multiple programs — pass a single address or an array to programId.
  • Filter by instruction type — only instructions whose discriminator matches one of the entries in instructions are fetched and decoded.
  • Handle decode errors with a custom onError callback instead of letting them propagate.
See the solanaInstructionDecoder() reference for all parameters.

Generating a typed ABI module

Typed ABI modules for Solana programs are generated from Anchor IDL files by @subsquid/solana-typegen. Each generated module exports typed decode functions, so decoded instruction field types are statically known at compile time — you get precise type checking and IDE autocompletion across the entire pipeline. Install:

From a local IDL file

The output module name is derived from the filename (whirlpool). Override it with a #name fragment:

From a program address

For Anchor programs that publish their IDL on-chain, pass the program address directly:
The tool tries two sources in parallel: the on-chain IDL account (defaulting to Solana mainnet) and the SolanaFM IDL database. It fails only if both sources fail. Use --solana-rpc-endpoint to point at a different RPC endpoint:
Without the #name fragment the program address itself becomes the module name.

From a URL

Generated module structure

For an input named orca_whirlpool, the tool creates:
Each entry in instructions.ts is a TypeScript interface (the decoded shape) alongside a constant carrying the discriminator and decode logic:
The d8 discriminator and account index map are embedded in the constant — solanaInstructionDecoder() reads them automatically to build the source query filter.

Accessing decoded data

The keys of the instructions map become field names in the decoded output batch. Each field is an array of decoded instruction objects:
See the decoded instruction structure reference for the full field list.