Kit
Functions

createBlockHeightExceedencePromiseFactory

Call Signature

createBlockHeightExceedencePromiseFactory(config): GetBlockHeightExceedencePromiseFn

Creates a promise that throws when the network progresses past the block height after which the supplied blockhash is considered expired for use as a transaction lifetime specifier.

When a transaction's lifetime is tied to a blockhash, that transaction can be landed on the network until that blockhash expires. All blockhashes have a block height after which they are considered to have expired.

Parameters

ParameterTypeDescription
configCreateBlockHeightExceedencePromiseFactoryConfig<"devnet">

Returns

GetBlockHeightExceedencePromiseFn

Example

import { isSolanaError, SolanaError } from '@solana/errors';
import { createBlockHeightExceedencePromiseFactory } from '@solana/transaction-confirmation';
 
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({
    rpc,
    rpcSubscriptions,
});
try {
    await getBlockHeightExceedencePromise({ lastValidBlockHeight });
} catch (e) {
    if (isSolanaError(e, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED)) {
        console.error(
            `The block height of the network has exceeded ${e.context.lastValidBlockHeight}. ` +
                `It is now ${e.context.currentBlockHeight}`,
        );
        // Re-sign and retry the transaction.
        return;
    }
    throw e;
}

Call Signature

createBlockHeightExceedencePromiseFactory(config): GetBlockHeightExceedencePromiseFn

Creates a promise that throws when the network progresses past the block height after which the supplied blockhash is considered expired for use as a transaction lifetime specifier.

When a transaction's lifetime is tied to a blockhash, that transaction can be landed on the network until that blockhash expires. All blockhashes have a block height after which they are considered to have expired.

Parameters

ParameterTypeDescription
configCreateBlockHeightExceedencePromiseFactoryConfig<"testnet">

Returns

GetBlockHeightExceedencePromiseFn

Example

import { isSolanaError, SolanaError } from '@solana/errors';
import { createBlockHeightExceedencePromiseFactory } from '@solana/transaction-confirmation';
 
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({
    rpc,
    rpcSubscriptions,
});
try {
    await getBlockHeightExceedencePromise({ lastValidBlockHeight });
} catch (e) {
    if (isSolanaError(e, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED)) {
        console.error(
            `The block height of the network has exceeded ${e.context.lastValidBlockHeight}. ` +
                `It is now ${e.context.currentBlockHeight}`,
        );
        // Re-sign and retry the transaction.
        return;
    }
    throw e;
}

Call Signature

createBlockHeightExceedencePromiseFactory(config): GetBlockHeightExceedencePromiseFn

Creates a promise that throws when the network progresses past the block height after which the supplied blockhash is considered expired for use as a transaction lifetime specifier.

When a transaction's lifetime is tied to a blockhash, that transaction can be landed on the network until that blockhash expires. All blockhashes have a block height after which they are considered to have expired.

Parameters

ParameterTypeDescription
configCreateBlockHeightExceedencePromiseFactoryConfig<"mainnet">

Returns

GetBlockHeightExceedencePromiseFn

Example

import { isSolanaError, SolanaError } from '@solana/errors';
import { createBlockHeightExceedencePromiseFactory } from '@solana/transaction-confirmation';
 
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({
    rpc,
    rpcSubscriptions,
});
try {
    await getBlockHeightExceedencePromise({ lastValidBlockHeight });
} catch (e) {
    if (isSolanaError(e, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED)) {
        console.error(
            `The block height of the network has exceeded ${e.context.lastValidBlockHeight}. ` +
                `It is now ${e.context.currentBlockHeight}`,
        );
        // Re-sign and retry the transaction.
        return;
    }
    throw e;
}

On this page