range: Slot range{ from: number | string | 'latest', to?: number }(required)program: The program the instructions belong to, usually its typegen module withprogramIdandinstructions(required). The decoder reads one address,program.programId. Every entry ininstructionsmust be one ofprogram.instructions.programId: Deprecated, useprogram. Program address(es)string | string[], accepted in place ofprogram. The decoder then checks discriminators only, so an instruction from another program with the same discriminator can decode under the wrong key.instructions: Map of instruction names to ABI instruction objects (required)profiler: Profiler config shard that’ll be used for labeling the transformer in profiling data{ name: string }(optional)onError: Error handler(ctx: BatchContext, error: any) => unknown | Promise<unknown>(optional)
Decoded instruction structure
Each entry in the output arrays is aDecodedInstruction object:
Instruction discriminators
Instructions are filtered by discriminators (prefix bytes of instruction data). The discriminator name indicates how many leading bytes of the instruction data it covers:
The decoder automatically extracts the appropriate discriminator from the ABI instruction definition.
Multiple programs
A decoder covers one program. Anchor derives an instruction’s discriminator from its name alone, so two programs that each have aswap share a discriminator, and one decoder could not tell them apart. Give each program its own decoder and pass both as outputs:
program: { ...orcaWhirlpool, programId: '<address>' }.
The decoder checks this when it starts. An instruction that is not one of program.instructions, a program with an empty address, an instruction with no discriminator or more than one, discriminators of mixed widths, or two instructions that share a discriminator fail with E0003.