in-solana by Supanode

Program failed to complete

The program consumed all its allocated compute units before finishing execution.

Common causes

  1. Not enough compute units requested. The default is 200,000 CUs per instruction. Complex operations like multiple CPI calls, large data processing, or heavy math can exceed this.
  2. Infinite or very long loop. A loop in the program runs too many iterations.
  3. Large account deserialization. Deserializing many accounts or large data structures costs significant compute.

How to fix

  1. Request more compute units. Add a SetComputeUnitLimit instruction from the Compute Budget Program before your program instruction:
import { ComputeBudgetProgram } from "@solana/web3.js";

const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
  units: 400_000,
});
  1. Optimize the program. Reduce unnecessary computation, minimize CPI calls, and avoid large loops.
  2. Split into multiple transactions. If the work cannot fit in one transaction, break it into smaller steps.

Compute unit costs

OperationApproximate CU cost
Basic instruction200
SHA256 hash100 per 32 bytes
CPI call1,000 base + invoked program CUs
Account creation2,500
Log message100 per log

The maximum compute budget per transaction is 1,400,000 CUs.

FAQ

What is the default compute unit limit? 200,000 CUs per instruction, with a maximum of 1,400,000 CUs per transaction.

Do compute units affect transaction fees? Yes. When you set a compute unit price via SetComputeUnitPrice, the priority fee is calculated as computeUnits × microLamportsPerCU. Requesting more CUs increases the maximum possible fee, but you only pay for CUs actually consumed.

How do I check how many CUs my transaction uses? Use simulateTransaction — the response includes unitsConsumed.

Error text variants

  • Program failed to complete
  • exceeded CUs meter at BPF instruction
  • ComputationalBudgetExceeded

Updated: