Kit
Functions

getSignersFromTransactionMessage

getSignersFromTransactionMessage<TAddress, TSigner, TTransactionMessage>(transaction): readonly TSigner[]

Extracts and deduplicates all TransactionSigners stored inside a given transaction message.

This includes any TransactionSigners stored as the fee payer or in the instructions of the transaction message.

Any extracted signers that share the same Address will be de-duplicated.

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.
TTransactionMessage extends TransactionMessageWithSigners<TAddress, TSigner, readonly AccountMetaWithSigner<TSigner>[]>TransactionMessageWithSigners<TAddress, TSigner, readonly AccountMetaWithSigner<TSigner>[]>The inferred type of the transaction message provided.

Parameters

ParameterType
transactionTTransactionMessage

Returns

readonly TSigner[]

Example

import { Instruction } from '@solana/instructions';
import { InstructionWithSigners, TransactionMessageWithSigners, getSignersFromTransactionMessage } from '@solana/signers';
 
const signerA = { address: address('1111..1111'), signTransactions: async () => {} };
const signerB = { address: address('2222..2222'), signTransactions: async () => {} };
const firstInstruction: Instruction & InstructionWithSigners = {
    programAddress: address('1234..5678'),
    accounts: [{ address: signerA.address, signer: signerA, ... }],
};
const secondInstruction: Instruction & InstructionWithSigners = {
    programAddress: address('1234..5678'),
    accounts: [{ address: signerB.address, signer: signerB, ... }],
};
const transactionMessage: TransactionMessageWithSigners = {
    feePayer: signerA,
    instructions: [firstInstruction, secondInstruction],
}
 
const transactionSigners = getSignersFromTransactionMessage(transactionMessage);
// ^ [signerA, signerB]

On this page