Kit
Functions

isTransactionMessageWithDurableNonceLifetime

isTransactionMessageWithDurableNonceLifetime(transactionMessage): transactionMessage is Readonly<{ instructions: readonly Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]; version: TransactionVersion }> & 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
transactionMessageReadonly<{ instructions: readonly Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]; version: TransactionVersion; }> | Readonly<{ instructions: readonly Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]; version: TransactionVersion; }> & TransactionMessageWithDurableNonceLifetime<string, string, string>

Returns

transactionMessage is Readonly<{ instructions: readonly Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]; version: TransactionVersion }> & 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