in-solana by Supanode

Solana Compute Unit Estimator

Estimate compute unit (CU) consumption for Solana transactions. Paste a serialized transaction or build one from instructions to see CU usage before sending.

How compute units work

Every Solana transaction has a compute unit budget:

  • Default: 200,000 CUs per instruction (up to 1.4M per transaction)
  • Custom: Set via SetComputeUnitLimit instruction
  • Priority fee: SetComputeUnitPrice × CU limit = priority fee

Setting the CU limit accurately matters:

  • Too high: You pay priority fees on unused CUs.
  • Too low: The transaction fails with “exceeded CUs.”

Estimating via simulation

const simulation = await connection.simulateTransaction(transaction, {
  replaceRecentBlockhash: true,
  sigVerify: false,
});

if (simulation.value.unitsConsumed) {
  const consumed = simulation.value.unitsConsumed;
  const recommended = Math.ceil(consumed * 1.1); // 10% buffer
  console.log(`Consumed: ${consumed} CUs`);
  console.log(`Recommended limit: ${recommended} CUs`);
}

Common CU costs

OperationApproximate CUs
SOL transfer~300
SPL Token transfer~4,000
Memo~200
Jupiter swap (simple)~100,000–200,000
Jupiter swap (multi-hop)~200,000–400,000
Raydium swap~60,000–150,000
NFT mint (Metaplex)~200,000–300,000
Anchor instruction (simple)~20,000–50,000

Optimization tips

  1. Simulate first: Always simulate to get the actual CU consumption.
  2. Add a buffer: Use 10–20% above the simulated amount for safety.
  3. Set explicit limits: Don’t rely on the 200K default — set SetComputeUnitLimit to your measured value plus buffer.
  4. Batch similar operations: Multiple transfers in one transaction share fixed costs.

FAQ

Why should I set a compute unit limit? Priority fees are calculated as computeUnitPrice × computeUnitLimit. If you don’t set a limit, the default 200K is used, and you pay priority fees on all 200K even if you only use 5K. Setting an accurate limit reduces your effective fee.

What happens if I exceed the compute unit limit? The transaction fails with a compute budget exceeded error. No fees are charged for failed transactions (except the base fee, which is always charged).

Do simulations give exact CU counts? Simulations give a close estimate but may differ from actual execution due to different account states between simulation and execution. Add a 10–20% buffer to account for this variance.

Data powered by Supanode RPC

Updated: