isTransactionMessageWithDurableNonceLifetime

function isTransactionMessageWithDurableNonceLifetime(
    transactionMessage,
): transactionMessage is TransactionMessage &
    TransactionMessageWithDurableNonceLifetime<string, string, string>;

A type guard that returns true if the transaction message conforms to the TransactionMessageWithDurableNonceLifetime type, and refines its type for use in your program.

Parameters

ParameterType
transactionMessage| TransactionMessage | TransactionMessage & TransactionMessageWithDurableNonceLifetime<string, string, string>

Returns

transactionMessage is TransactionMessage & TransactionMessageWithDurableNonceLifetime<string, string, string>

Example

import { isTransactionMessageWithDurableNonceLifetime } from '@solana/transaction-messages';
import { fetchNonce } from "@solana-program/system";
 
if (isTransactionMessageWithDurableNonceLifetime(message)) {
    // At this point, `message` has been refined to a
    // `TransactionMessageWithDurableNonceLifetime`.
    const { nonce, nonceAccountAddress } = message.lifetimeConstraint;
    const { data: { blockhash: actualNonce } } = await fetchNonce(nonceAccountAddress);
    setNonceIsValid(nonce === actualNonce);
} else {
    setError(
        `${getSignatureFromTransaction(transaction)} does not have a nonce-based lifetime`,
    );
}

On this page