isTransactionMessageWithBlockhashLifetime

function isTransactionMessageWithBlockhashLifetime(
    transactionMessage,
): transactionMessage is TransactionMessage &
    TransactionMessageWithBlockhashLifetime;

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

Parameters

ParameterType
transactionMessage| TransactionMessage | TransactionMessage & TransactionMessageWithBlockhashLifetime

Returns

transactionMessage is TransactionMessage & TransactionMessageWithBlockhashLifetime

Example

import { isTransactionMessageWithBlockhashLifetime } from '@solana/transaction-messages';
 
if (isTransactionMessageWithBlockhashLifetime(message)) {
    // At this point, `message` has been refined to a `TransactionMessageWithBlockhashLifetime`.
    const { blockhash } = message.lifetimeConstraint;
    const { value: blockhashIsValid } = await rpc.isBlockhashValid(blockhash).send();
    setBlockhashIsValid(blockhashIsValid);
} else {
    setError(
        `${getSignatureFromTransaction(transaction)} does not have a blockhash-based lifetime`,
    );
}

On this page