solanaInstructionDecoder automatically decodes Solana program instructions using generated ABIs, providing typed access to instruction data.
Basic Usage
Configuration
| Option | Type | Required | Description |
|---|---|---|---|
programId | string | string[] | Yes | Program address(es) to filter |
instructions | Record<string, InstructionDef> | Yes | Map of instruction names to ABI definitions |
range | PortalRange | Yes | Slot range to process |
profiler | ProfilerOptions | No | Profiler configuration (default: { id: 'instruction decoder' }) |
onError | (ctx, error) => unknown | No | Error handler (default: throws error) |
Decoded Instruction Structure
Each decoded instruction contains:Discriminators
Solana programs use discriminators to identify instruction types. The SDK supports multiple discriminator sizes:| Name | Hex Characters | Bytes | Common Use |
|---|---|---|---|
d1 | 4 chars | 2 bytes | Simple programs |
d2 | 8 chars | 4 bytes | Some native programs |
d4 | 14 chars | 7 bytes | Custom programs |
d8 | 18 chars | 9 bytes | Anchor programs (most common) |
solanaInstructionDecoder, discriminators are handled automatically based on the ABI.
For manual queries with SolanaQueryBuilder:
Generating ABIs
Use@subsquid/solana-typegen to generate typed ABIs from program IDLs:
programId- The program addressinstructions- Typed instruction definitions with discriminators
Using Generated ABIs
Multiple Instruction Types
Decode multiple instructions from the same program:Composite Decoding
Decode instructions from multiple programs simultaneously:Query Building
The decoder automatically builds the Portal query based on the configured instructions. You donβt need to manually configureSolanaQueryBuilder when using the decoder - it handles:
- Field selection for instructions and related data
- Discriminator-based filtering
- Range configuration

