getInstructionsFromCompiledTransactionMessage

function getInstructionsFromCompiledTransactionMessage(
    compiledMessage,
    loadedAddresses?,
): ResolvedInstruction<string>[];

Returns the outer instructions of a compiled transaction message as kit Instruction objects.

Each returned instruction has its account indices resolved to AccountMetas (with the proper signer/writable bits) and its data exposed as a ReadonlyUint8Array — the form the auto-generated @solana-program/* parseXInstruction functions expect. accounts and data are omitted when empty.

Supports legacy, v0, and v1 compiled messages. Throws SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED for any other version, SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND if a programAddressIndex falls outside the resolved account list, and SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_ACCOUNT_INDEX_OUT_OF_RANGE if an account index does.

Parameters

ParameterType
compiledMessageCompiledTransactionMessage
loadedAddresses?| Readonly<{ readonly: readonly Address[]; writable: readonly Address[]; }> | null

Returns

ResolvedInstruction<string>[]

Example

const instructions = getInstructionsFromCompiledTransactionMessage(
    compiled,
    rpcResponse.meta?.loadedAddresses,
);
for (const ix of instructions) {
    if (ix.programAddress === TOKEN_PROGRAM_ADDRESS && isInstructionWithData(ix)) {
        const kind = identifyTokenInstruction(ix);
        // ...
    }
}

On this page