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

    Type Parameters

    • TTransactionMessage extends TransactionMessage
    • TInstruction extends Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>

    Parameters

    Returns PrependTransactionMessageInstructions<TTransactionMessage, [TInstruction]>

    prependTransactionInstructions if you need to prepend multiple instructions to a transaction message.

    import { address } from '@solana/addresses';
    import { prependTransactionMessageInstruction } from '@solana/transaction-messages';

    const memoTransaction = prependTransactionMessageInstruction(
    {
    data: new TextEncoder().encode('Hello world!'),
    programAddress: address('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'),
    },
    tx,
    );