estimateAndSetComputeUnitLimitFactory
Returns a function that estimates the compute unit limit for a transaction message and sets it on the message. If the message already has an explicit compute unit limit set (one that is not the provisory value of 0, and not the maximum of 1,400,000), the message is returned unchanged.
This is designed to work with fillTransactionMessageProvisoryComputeUnitLimit: first add a provisory limit during transaction construction, then later estimate and replace it before sending.
Parameters
| Parameter | Type | Description |
|---|---|---|
estimateComputeUnitLimit | EstimateComputeUnitLimitFunction | The estimator function, typically created by estimateComputeUnitLimitFactory. You can also pass a custom wrapper that adds a buffer (e.g. multiply the estimate by 1.1). |
Returns
A function that accepts a transaction message and returns it with the compute unit limit set to the estimated value.
Type Parameters
| Type Parameter |
|---|
TTransactionMessage extends TransactionMessage & TransactionMessageWithFeePayer<string> |
Parameters
| Parameter | Type |
|---|---|
transactionMessage | TTransactionMessage |
config? | Readonly<{ abortSignal?: AbortSignal; commitment?: Commitment; minContextSlot?: bigint; }> |
Returns
Promise<TTransactionMessage>