Kit
Functions

prependTransactionMessageInstructions

prependTransactionMessageInstructions<TTransactionMessage, TInstructions>(instructions, transactionMessage): PrependTransactionMessageInstructions<TTransactionMessage, TInstructions>

Given an array of instructions, this method will return a new transaction message with those instructions having been added to the beginning of the list of existing instructions.

Type Parameters

Type Parameter
TTransactionMessage extends Readonly<{ instructions: readonly Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]; version: TransactionVersion; }>
TInstructions extends readonly Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]

Parameters

ParameterType
instructionsTInstructions
transactionMessageTTransactionMessage

Returns

PrependTransactionMessageInstructions<TTransactionMessage, TInstructions>

See

prependTransactionInstruction if you only need to prepend one instruction to a transaction message.

Example

import { address } from '@solana/addresses';
import { prependTransactionMessageInstructions } from '@solana/transaction-messages';
 
const memoTransaction = prependTransactionMessageInstructions(
    [
        {
            data: new TextEncoder().encode('Hello world!'),
            programAddress: address('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'),
        },
        {
            data: new TextEncoder().encode('How are you?'),
            programAddress: address('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'),
        },
    ],
    tx,
);

On this page