getSignatureFromTransactionIfPresent

function getSignatureFromTransactionIfPresent(
    transaction,
): Signature | undefined;

Given a transaction, this method will return the Signature that uniquely identifies it, or undefined when its fee payer has not signed it yet.

Use this in preference to getSignatureFromTransaction when a transaction is legitimately allowed to be unsigned by its fee payer — for instance one that has been partially signed by an authority and is destined for a relayer that will pay for it.

Parameters

ParameterType
transactionTransaction

Returns

Signature | undefined

The transaction's signature, or undefined if its fee payer has not signed it.

Example

import { getSignatureFromTransactionIfPresent } from '@solana/transactions';
 
const signature = getSignatureFromTransactionIfPresent(tx);
if (signature !== undefined) {
    console.debug(`Inspect this transaction at https://explorer.solana.com/tx/${signature}`);
}

See

getSignatureFromTransaction if you expect the transaction to have been signed by its fee payer and want to throw otherwise.

On this page