Kit
Functions

appendTransactionMessageInstruction

appendTransactionMessageInstruction<TTransactionMessage, TInstruction>(instruction, transactionMessage): AppendTransactionMessageInstructions<TTransactionMessage, [TInstruction]>

Given an instruction, this method will return a new transaction message with that instruction having been added to the end 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; }>
TInstruction extends Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>

Parameters

ParameterType
instructionTInstruction
transactionMessageTTransactionMessage

Returns

AppendTransactionMessageInstructions<TTransactionMessage, [TInstruction]>

See

appendTransactionInstructions if you need to append multiple instructions to a transaction message.

Example

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

On this page