Kit
Functions

createNonceInvalidationPromiseFactory

Call Signature

createNonceInvalidationPromiseFactory(config): GetNonceInvalidationPromiseFn

Creates a promise that throws when the value stored in a nonce account is not the expected one.

When a transaction's lifetime is tied to the value stored in a nonce account, that transaction can be landed on the network until the nonce is advanced to a new value.

Parameters

ParameterTypeDescription
configCreateNonceInvalidationPromiseFactoryConfig<"devnet">

Returns

GetNonceInvalidationPromiseFn

Example

import { isSolanaError, SolanaError } from '@solana/errors';
import { createNonceInvalidationPromiseFactory } from '@solana/transaction-confirmation';
 
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory({
    rpc,
    rpcSubscriptions,
});
try {
    await getNonceInvalidationPromise({
        currentNonceValue,
        nonceAccountAddress,
    });
} catch (e) {
    if (isSolanaError(e, SOLANA_ERROR__NONCE_INVALID)) {
        console.error(`The nonce has advanced to ${e.context.actualNonceValue}`);
        // Re-sign and retry the transaction.
        return;
    } else if (isSolanaError(e, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND)) {
        console.error(`No nonce account was found at ${nonceAccountAddress}`);
    }
    throw e;
}

Call Signature

createNonceInvalidationPromiseFactory(config): GetNonceInvalidationPromiseFn

Creates a promise that throws when the value stored in a nonce account is not the expected one.

When a transaction's lifetime is tied to the value stored in a nonce account, that transaction can be landed on the network until the nonce is advanced to a new value.

Parameters

ParameterTypeDescription
configCreateNonceInvalidationPromiseFactoryConfig<"testnet">

Returns

GetNonceInvalidationPromiseFn

Example

import { isSolanaError, SolanaError } from '@solana/errors';
import { createNonceInvalidationPromiseFactory } from '@solana/transaction-confirmation';
 
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory({
    rpc,
    rpcSubscriptions,
});
try {
    await getNonceInvalidationPromise({
        currentNonceValue,
        nonceAccountAddress,
    });
} catch (e) {
    if (isSolanaError(e, SOLANA_ERROR__NONCE_INVALID)) {
        console.error(`The nonce has advanced to ${e.context.actualNonceValue}`);
        // Re-sign and retry the transaction.
        return;
    } else if (isSolanaError(e, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND)) {
        console.error(`No nonce account was found at ${nonceAccountAddress}`);
    }
    throw e;
}

Call Signature

createNonceInvalidationPromiseFactory(config): GetNonceInvalidationPromiseFn

Creates a promise that throws when the value stored in a nonce account is not the expected one.

When a transaction's lifetime is tied to the value stored in a nonce account, that transaction can be landed on the network until the nonce is advanced to a new value.

Parameters

ParameterTypeDescription
configCreateNonceInvalidationPromiseFactoryConfig<"mainnet">

Returns

GetNonceInvalidationPromiseFn

Example

import { isSolanaError, SolanaError } from '@solana/errors';
import { createNonceInvalidationPromiseFactory } from '@solana/transaction-confirmation';
 
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory({
    rpc,
    rpcSubscriptions,
});
try {
    await getNonceInvalidationPromise({
        currentNonceValue,
        nonceAccountAddress,
    });
} catch (e) {
    if (isSolanaError(e, SOLANA_ERROR__NONCE_INVALID)) {
        console.error(`The nonce has advanced to ${e.context.actualNonceValue}`);
        // Re-sign and retry the transaction.
        return;
    } else if (isSolanaError(e, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND)) {
        console.error(`No nonce account was found at ${nonceAccountAddress}`);
    }
    throw e;
}

On this page