TransactionMessageWithSigners

type TransactionMessageWithSigners<TAddress, TSigner, TAccounts> = Partial<Pick<
  | TransactionMessageWithFeePayer<TAddress>
  | TransactionMessageWithFeePayerSigner<TAddress, TSigner>, "feePayer">> & Readonly<{
  instructions: readonly Instruction & InstructionWithSigners<TSigner, TAccounts>[];
}>;

A TransactionMessage type extension that accept TransactionSigners.

Namely, it allows:

Type Parameters

Type ParameterDefault typeDescription
TAddress extends stringstringSupply a string literal to define an account having a particular address.
TSigner extends TransactionSigner<TAddress>TransactionSigner<TAddress>Optionally provide a narrower type for TransactionSigners.
TAccounts extends readonly AccountMetaWithSigner<TSigner>[]readonly AccountMetaWithSigner<TSigner>[]Optionally provide a narrower type for the account metas.

Example

import { Instruction } from '@solana/instructions';
import { TransactionMessage } from '@solana/transaction-messages';
import { generateKeyPairSigner, InstructionWithSigners, TransactionMessageWithSigners } from '@solana/signers';
 
const signer = await generateKeyPairSigner();
const firstInstruction: Instruction = { ... };
const secondInstruction: InstructionWithSigners = { ... };
const transactionMessage: TransactionMessage & TransactionMessageWithSigners = {
    feePayer: signer,
    instructions: [firstInstruction, secondInstruction],
}

On this page