SOLSTACKAcademy

Advanced· Lesson 2 of 8· 4 min

Compute budget and priority fees

Every instruction runs under a metered budget, and the budget you request is what your priority fee is charged on. Set both deliberately and transactions land cheaper and more reliably.

Compute units (CU) meter the work a transaction does: every program instruction executed, every account loaded, every syscall. Unlike gas, the price is not set by the market per unit of work — the base fee is flat — but the budget is capped, and a tip per unit is how you buy priority. A transaction gets 200,000 CU per instruction by default, up to 1.4 million in total. Exceed the budget and it fails, fee still paid.

Two instructions

The Compute Budget program, ComputeBudget111111111111111111111111111111, exposes the knobs as instructions you put at the front of a transaction. SetComputeUnitLimit replaces the default budget; SetComputeUnitPrice sets the tip in micro-lamports per unit. A third, SetLoadedAccountsDataSizeLimit, caps how much account data the transaction may load, since loading data costs units too.

Solana Explorer showing the two Compute Budget instructions at the front of a swap: a compute unit limit of 131,387 and a price of 0.001092 lamports per unit
  1. First instruction: set the limit. It applies to the whole transaction.
  2. 131,387 units requested. The swap used 105,751 — a comfortable margin, not a wild one.
  3. 1,092 micro-lamports per unit. Times the limit, that is 143.5 lamports of tip: the 144 Solscan reports.
A well-tuned compute budget on a mainnet swap, captured 19 Sep 2026 · explorer.solana.com

Why the limit matters beyond the fee

Each block has a fixed compute budget (raised to 60 million CU in 2025), and any single account can be written by at most 12 million CU per block. The scheduler packs transactions by their requested limit, not their actual use. A transaction that asks for far more than it needs is harder to fit, is ranked lower for the same tip, and crowds out others on the accounts it writes. Asking for what you use, plus a margin, is both cheaper and faster.

The fee market is local

Priority is contested per account, not network-wide. A hot mint during a launch has thousands of transactions trying to write the same bonding curve; an ordinary transfer at the same moment lands with no tip at all. Leaders order by tip per unit among the transactions competing for the same writable accounts. The RPC method getRecentPrioritizationFees returns what recently landed transactions paid, optionally filtered to the accounts you will touch; that, not a global number, is the right input.

Quiet network, ordinary transfer0 micro-lamports. Median mainnet tip on a normal day is zero.
Contested DEX swapHundreds to a few thousand micro-lamports per unit: a fraction of a cent.
Launch snipe on a hot mintThe pump.fun buy in Bonding curves paid 150,000 lamports for 95,000 units — about 1.58 lamports per unit, more than a thousand times the swap's tip.

Where the money goes

The base fee is split: half burned, half to the block's leader. The priority fee goes entirely to the leader (since early 2025; before that, half was burned too). Validators that share block revenue pass a portion of it to their stakers — the second commission in Staking.

Solscan's compute unit distribution bar and the four instructions of the swap
  1. How the units split across instructions. The two budget instructions cost 150 each; the swap took 89,034.
  2. The limit instruction. Solscan decodes the requested cap.
  3. The price instruction. Together they define the tip.
Per-instruction compute use on Solscan, captured 19 Sep 2026 · solscan.io

Failures you will see

Computational budget exceededThe transaction ran out of units. Raise the limit — after checking the program isn't looping on bad input.
Insufficient funds for feeThe wallet can't cover base fee plus tip. Tips are charged on the limit, so a huge limit with a high price can be surprisingly large.
Never lands, no errorThe tip was too low for the contention on the accounts touched and the blockhash expired. Nothing charged. Raise the price, or wait.
Transaction cost on SolscanNot CU: a scheduler cost that also counts signatures and write locks. Only the CU line is your budget.

The recipe

  1. Simulate the transaction against current state and read the units consumed.
  2. Set the limit to consumed × 1.1, rounded up. Never leave the default for multi-instruction transactions.
  3. Read recent prioritization fees for the accounts you write; pick a percentile that matches how urgent you are.
  4. Send, and resend the same signed transaction until it confirms or the blockhash expires. Resending never double-spends: the same signature can land once.
  5. If it expires, rebuild with a fresh blockhash and a higher price.
JavaScript
import { ComputeBudgetProgram } from "@solana/web3.js";

tx.add(
  ComputeBudgetProgram.setComputeUnitLimit({ units: 120_000 }),
  ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 1_500 }),
  // ...the instructions that do the work
);
// tip = 120,000 × 1,500 µL = 180,000,000 µL = 180 lamports

Every Solstack tool simulates first and sets both instructions from the result, which is why its transactions show a tight limit and a small tip rather than the defaults.

What to remember

  • Compute units meter work. Default 200k per instruction, 1.4M max per transaction; exceed it and the transaction fails.
  • Tip = requested limit × price in micro-lamports. It is charged on the limit, so request what you use plus a margin.
  • Priority is contested per account. Read recent fees for the accounts you touch, not a global number.
  • Base fee: half burned, half to the leader. Priority fee: all to the leader.
  • Simulate, set limit and price, resend until it lands or expires. Resending the same signature never double-spends.

Try it