CU Estimation via Simulation

Programming Model · Deep

The practice of calling simulateTransaction to measure exact compute unit consumption before submitting a transaction, then setting SetComputeUnitLimit to the simulated value plus a small margin (typically 10-20%). This pattern avoids both over-requesting CU (which inflates priority fee costs since fee = CU_price * CU_limit) and under-requesting (which causes the transaction to fail with a ComputeBudget exceeded error). The simulation returns unitsConsumed in its response, which developers use to right-size the compute budget instruction.

Related terms