I need to get all the transaction instructions from the Versioned transaction object. Any idea about this?
1 Answer
The instructions are available in the transaction's VersionedMessage
, which you can access like this:
const compiledInstructions = transaction.message.compiledInstructions;
Each instruction is a record of the following type:
type MessageCompiledInstruction = {
/**
* Ordered indices into the transaction keys array
* indicating which accounts to pass to the program
*/
accountKeyIndexes: number[];
/**
* The program input data
*/
data: Uint8Array;
/**
* Index into the transaction keys array indicating the
* program account that executes this instruction
*/
programIdIndex: number;
};
-
But how indexes work with versioned transactions? Indexes there might be bigger than
transaction key array
Commented Feb 4, 2023 at 17:22 -
1@RowanStone can you provide an example transaction you're trying to deserialize? An explorer link (or just base64 bytes) would go a long way toward helping us see what you're seeing.– JordanCommented Feb 7, 2023 at 1:53
VersionedTransaction
object in JavaScript?