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
instructionsare fetched and decoded. - Handle decode errors with a custom
onErrorcallback instead of letting them propagate.
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
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:--solana-rpc-endpoint to point at a different RPC endpoint:
#name fragment the program address itself becomes the module name.
From a URL
Generated module structure
For an input namedorca_whirlpool, the tool creates:
instructions.ts is a TypeScript interface (the decoded shape) alongside a constant carrying the discriminator and decode logic:
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 theinstructions map become field names in the decoded output batch. Each field is an array of decoded instruction objects: