Kit
Functions

getSignersFromInstruction

getSignersFromInstruction<TSigner>(instruction): readonly TSigner[]

Extracts and deduplicates all TransactionSigners stored inside the account metas of an instruction.

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

Type Parameters

Type ParameterDefault typeDescription
TSigner extends TransactionSignerTransactionSignerOptionally provide a narrower type for TransactionSigners.

Parameters

ParameterType
instructionInstructionWithSigners<TSigner>

Returns

readonly TSigner[]

Example

import { InstructionWithSigners, getSignersFromInstruction } from '@solana/signers';
 
const signerA = { address: address('1111..1111'), signTransactions: async () => {} };
const signerB = { address: address('2222..2222'), signTransactions: async () => {} };
const instructionWithSigners: InstructionWithSigners = {
    accounts: [
        { address: signerA.address, signer: signerA, ... },
        { address: signerB.address, signer: signerB, ... },
        { address: signerA.address, signer: signerA, ... },
    ],
};
 
const instructionSigners = getSignersFromInstruction(instructionWithSigners);
// ^ [signerA, signerB]

On this page