TracedInstruction

type TracedInstruction<TProgramAddress> = Readonly<{
  trace: InstructionTrace;
}> & ResolvedInstruction<TProgramAddress>;

A ResolvedInstruction carrying its location in the transaction as a trace property.

Because a TracedInstruction is itself a ResolvedInstruction, it can be passed directly to the auto-generated @solana-program/* identifyXInstruction / parseXInstruction helpers, and to isInstructionForProgram from @solana/instructions.

Type Parameters

Type ParameterDefault type
TProgramAddress extends stringstring

Example

import { isInstructionForProgram, isInstructionWithData } from '@solana/instructions';
import { TOKEN_PROGRAM_ADDRESS, identifyTokenInstruction } from '@solana-program/token';
 
for (const ix of walkInstructions({ compiledMessage, meta, loadedAddresses })) {
    if (isInstructionForProgram(ix, TOKEN_PROGRAM_ADDRESS) && isInstructionWithData(ix)) {
        // `ix.programAddress` is narrowed to TOKEN_PROGRAM_ADDRESS and `ix.data` is present.
        identifyTokenInstruction(ix);
        console.log(ix.trace.kind);
    }
}

On this page