setTransactionMessageLifetimeUsingBlockhash

function setTransactionMessageLifetimeUsingBlockhash<
    TTransactionMessage,
>(
    blockhashLifetimeConstraint,
    transactionMessage,
): ExcludeTransactionMessageLifetime<TTransactionMessage> &
    TransactionMessageWithBlockhashLifetime;

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

Type Parameter
TTransactionMessage extends Readonly<{ instructions: readonly Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]; version: TransactionVersion; }> & Partial<TransactionMessageWithLifetime>

Parameters

ParameterType
blockhashLifetimeConstraintBlockhashLifetimeConstraint
transactionMessageTTransactionMessage

Returns

ExcludeTransactionMessageLifetime<TTransactionMessage> & TransactionMessageWithBlockhashLifetime

Example

import { setTransactionMessageLifetimeUsingBlockhash } from '@solana/transaction-messages';
 
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
const txMessageWithBlockhashLifetime = setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, txMessage);

On this page