getMessagePackerInstructionPlanFromInstructions

function getMessagePackerInstructionPlanFromInstructions<TInstruction>(
    instructions,
): MessagePackerInstructionPlan;

Creates a MessagePackerInstructionPlan from a list of instructions.

This can be useful to prepare a set of instructions that can be iterated over — e.g. to pack a list of instructions that gradually reallocate the size of an account one REALLOC_LIMIT (10'240 bytes) at a time.

Type Parameters

Type ParameterDefault type
TInstruction extends Instruction<string, readonly (/api/functions/ | AccountLookupMeta<string, string> | AccountMeta<string>)[]>Instruction<string, readonly (/api/functions/ | AccountLookupMeta<string, string> | AccountMeta<string>)[]>

Parameters

ParameterType
instructionsTInstruction[]

Returns

MessagePackerInstructionPlan

Example

const plan = getMessagePackerInstructionPlanFromInstructions([
  instructionA,
  instructionB,
  instructionC,
]);
 
const messagePacker = plan.getMessagePacker();
firstTransactionMessage = messagePacker.packMessageToCapacity(firstTransactionMessage);
// Contains instruction A and instruction B.
secondTransactionMessage = messagePacker.packMessageToCapacity(secondTransactionMessage);
// Contains instruction C.
messagePacker.done(); // true

See

On this page