estimateResourceLimitsFactory
Returns a function that estimates the resource limits required by a transaction message by simulating it.
The estimator sets the compute unit limit to the maximum (1,400,000) and the loaded accounts data size limit to the maximum (64 MiB) before simulating, so the simulation does not fail due to resource 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.
For version 1 transaction messages, both computeUnitLimit and loadedAccountsDataSizeLimit are
returned. The function throws if the RPC does not return a loadedAccountsDataSize value, since
this value is required for version 1 transactions. For legacy and version 0 messages, only
computeUnitLimit is returned.
Parameters
| Parameter | Type | Description |
|---|---|---|
factoryConfig | EstimateResourceLimitsFactoryConfig | An object containing the RPC instance to use for simulation. |
Returns
EstimateResourceLimitsFunction
A function that accepts a transaction message and returns the estimated resource limits.