Use @subsquid/solana-typegen to generate typed ABIs for custom programs. This provides type safety and eliminates the need to manually find instruction discriminators. See the Solana SDK typegen documentation for details on generating and using custom ABIs.
solanaInstructionDecoder returns a Transformer that automatically builds the necessary queries for instruction decoding. You donβt need a query builder when using this transformer - it handles query construction internally. However, you still need a portal source.
Use the AbiDecodeInstruction type helper to extract the decoded instruction data type from your ABI for better TypeScript type safety. See the Types & Methods reference for details.
Instructions are filtered by discriminators (prefix bytes of instruction data). The discriminator names indicate the number of hex characters returned:
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)
The decoder automatically extracts the appropriate discriminator from the ABI instruction definition.