• Given a blockhash and the last block height at which that blockhash is considered usable to land transactions, this method will return a new transaction message having the same type as the one supplied plus the TransactionMessageWithBlockhashLifetime type.

    Type Parameters

    • TTransactionMessage extends Partial<Pick<TransactionMessageWithLifetime, "lifetimeConstraint">> & TransactionMessage

    Parameters

    • blockhashLifetimeConstraint: Readonly<{
          blockhash: Blockhash;
          lastValidBlockHeight: bigint;
      }>
    • transactionMessage: TTransactionMessage

    Returns ExcludeTransactionMessageLifetime<TTransactionMessage> & TransactionMessageWithBlockhashLifetime

    import { setTransactionMessageLifetimeUsingBlockhash } from '@solana/transaction-messages';

    const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
    const txMessageWithBlockhashLifetime = setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, txMessage);