Compute and Fees
Manage compute budget and fees for reliable landing. Results appear in the same fence: same-line // comments when short, multiline // blocks below the sample when not.
Search across all documentation pages
Manage compute budget and fees for reliable landing. Results appear in the same fence: same-line // comments when short, multiline // blocks below the sample when not.
Set max compute units for the tx.
// ComputeBudgetInstruction::set_compute_unit_limit(300_000)Micro-lamports per CU for priority.
// ComputeBudgetInstruction::set_compute_unit_price(50_000)Request larger heap for heavy programs.
// ComputeBudgetInstruction::request_heap_frame(256 * 1024)sol_log_compute_units for debugging.
// sol_log_compute_units();Base fee + prioritization from fee payer.
// fee payer must have enough lamportsDefault CU limit if unset - set explicitly for heavy txs.
// prefer explicit set_compute_unit_limitUse simulation units_consumed as guide.
// sim.value.unitsConsumedSignature count affects base fee.
// minimize required signaturesLookup tables reduce message size/fees for many accounts.
// v0 + ALTWritable account count impacts cost dimensions.
// mark readonly when possibleCPI consumes CU for callee too.
// budget for nested workHigher CU price competes for block space.
// sample getRecentPrioritizationFeesBudget ix can request loaded accounts data size limit.
// set_loaded_accounts_data_size_limitExceeding CU fails whole transaction.
// Computational budget exceededLocal validators may use different defaults - still set CU in tests.
// set limit in test txsStack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, Rust 1.91.1, and @solana/kit 7.0.0.
Reviewed by Chris St. John·Last updated Jul 18, 2026