Setting Priority Fees
Set dynamic priority fees using recent network percentiles and SetComputeUnitPrice so transactions compete during congestion.
Search across all documentation pages
Set dynamic priority fees using recent network percentiles and SetComputeUnitPrice so transactions compete during congestion.
Quick-reference recipe card - copy-paste ready.
const fees = await rpc.getRecentPrioritizationFees([]).send();
fees.sort((a, b) => a.prioritizationFee - b.prioritizationFee);
const p75 = fees[Math.floor(fees.length * 0.75)]?.prioritizationFee ?? 1000;
// microLamports per CU in compute budget instruction
const microLamports = Math.min(p75 * 1.2, MAX_CAP);When to reach for this:
import { createSolanaRpc } from "@solana/kit";
const rpc = createSolanaRpc(process.env.RPC_URL!);
const MAX_MICRO_LAMPORTS = 500_000;
async function suggestPriorityFee(lockedAccounts: string[] = []) {
const fees = await rpc
.getRecentPrioritizationFees(
lockedAccounts.map((a) => ({ account: a }))
)
.send();
const samples = fees
.map((f) => f.prioritizationFee)
.filter((n) => n > 0)
.sort((a, b) => a - b);
if (samples.length === 0) return 1_000;
const p75 = samples[Math.floor(samples.length * 0.75)];
return Math.min(Math.ceil(p75 * 1.2), MAX_MICRO_LAMPORTS);
}
const microLamports = await suggestPriorityFee();
console.log("compute unit price:", microLamports);What this demonstrates:
getRecentPrioritizationFees samples landed transaction fees.microLamports * compute_units_requested (capped by limit instruction).priorityFeeEstimate with percentile stats.| Profile | Percentile | Use case |
|---|---|---|
| Economy | p50 | Low urgency |
| Standard | p75 | Most UX |
| Aggressive | p90 | Mints, arb |
| Capped | min(p90, cap) | Cost guardrails |
// Total priority lamports ≈ (microLamports * computeUnitLimit) / 1_000_000
// Add base fee separately in UX estimatesMAX_MICRO_LAMPORTS per product policy.| Alternative | Use When | Don't Use When |
|---|---|---|
| Fixed fee | Quiet devnet | Congested mainnet |
| Jito tip | Bundle landing | Simple transfers |
| Private validator deals | Institutional | Consumer wallets |
| User-selected sliders | Transparent UX | Fully automated bots |
1e-6 lamports; price is per compute unit requested in the budget instruction.
Show estimated priority SOL = microLamports * CU limit / 1e9 plus base fee.
Yes - maintain fee profiles per transaction template from simulations.
If included in block but failed program, priority fee still charged; dropped txs pay nothing.
Optional enhancement over raw getRecentPrioritizationFees - abstract behind interface.
Usually unnecessary - focus testing on mainnet small amounts.
Separate payment paths - some apps use both for competitive landing.
Per user send action during congestion; less frequent off-peak.
No on-chain refund if tx lands failed - design caps and simulation carefully.
See Estimating Compute Units - set limit before price.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026