estimateComputeUnitLimitFactory

function estimateComputeUnitLimitFactory(
    factoryConfig,
): EstimateComputeUnitLimitFunction;

Returns a function that estimates the compute units consumed by a transaction message by simulating it.

The estimator sets the compute unit limit to the maximum (1,400,000) before simulating, so the simulation does not fail due to compute unit exhaustion. For blockhash-lifetime transactions, the RPC is asked to replace the blockhash during simulation, so any blockhash value will work. For durable nonce transactions, the actual nonce value is used.

Parameters

ParameterTypeDescription
factoryConfigEstimateComputeUnitLimitFactoryConfigAn object containing the RPC instance to use for simulation.

Returns

EstimateComputeUnitLimitFunction

A function that accepts a transaction message and returns the estimated compute units.

Example

import { estimateComputeUnitLimitFactory } from '@solana/kit';
 
const estimateComputeUnitLimit = estimateComputeUnitLimitFactory({ rpc });
const estimatedUnits = await estimateComputeUnitLimit(transactionMessage);

On this page