setTransactionMessageLifetimeUsingDurableNonce

function setTransactionMessageLifetimeUsingDurableNonce<
    TTransactionMessage,
    TNonceAccountAddress,
    TNonceAuthorityAddress,
    TNonceValue,
>(
    __namedParameters,
    transactionMessage,
): SetTransactionMessageWithDurableNonceLifetime<
    TTransactionMessage,
    TNonceAccountAddress,
    TNonceAuthorityAddress,
    TNonceValue
>;

Given a nonce, the account where the value of the nonce is stored, and the address of the account authorized to consume that nonce, this method will return a new transaction having the same type as the one supplied plus the TransactionMessageWithDurableNonceLifetime type.

In particular, this method prepends an instruction to the transaction message designed to consume (or 'advance') the nonce in the same transaction whose lifetime is defined by it.

Type Parameters

Type ParameterDefault type
TTransactionMessage extends Readonly<{ instructions: readonly Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]; version: TransactionVersion; }>-
TNonceAccountAddress extends stringstring
TNonceAuthorityAddress extends stringstring
TNonceValue extends stringstring

Parameters

ParameterType
__namedParametersDurableNonceConfig<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>
transactionMessageTTransactionMessage

Returns

SetTransactionMessageWithDurableNonceLifetime<TTransactionMessage, TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>

Example

import { Nonce, setTransactionMessageLifetimeUsingDurableNonce } from '@solana/transaction-messages';
import { fetchNonce } from '@solana-program/system';
 
const nonceAccountAddress = address('EGtMh4yvXswwHhwVhyPxGrVV2TkLTgUqGodbATEPvojZ');
const nonceAuthorityAddress = address('4KD1Rdrd89NG7XbzW3xsX9Aqnx2EExJvExiNme6g9iAT');
 
const {
    data: { blockhash },
} = await fetchNonce(rpc, nonceAccountAddress);
const nonce = blockhash as string as Nonce;
 
const durableNonceTransactionMessage = setTransactionMessageLifetimeUsingDurableNonce(
    { nonce, nonceAccountAddress, nonceAuthorityAddress },
    tx,
);

On this page