Solana Priority Fees: How to Set Them Correctly
Priority fees let you pay validators extra to include your transaction sooner. During congestion, transactions with higher priority fees land first. The fee is calculated as computeUnitPrice × computeUnitsConsumed / 1,000,000 lamports.
How priority fees work
Every Solana transaction has two fee components:
- Base fee: 5,000 lamports per signature (fixed).
- Priority fee: variable, based on the compute unit price you set.
The priority fee formula:
priorityFee = computeUnitPrice (microLamports) × computeUnitsConsumed / 1,000,000
For example: a transaction consuming 200,000 CUs with a price of 50,000 microLamports pays 50,000 × 200,000 / 1,000,000 = 10,000 lamports (0.00001 SOL) as priority fee.
Setting priority fees
Add two instructions to every transaction:
import {
getSetComputeUnitLimitInstruction,
getSetComputeUnitPriceInstruction,
} from "@solana-program/compute-budget";
// 1. Set the compute unit limit (from simulation + margin)
const setLimitIx = getSetComputeUnitLimitInstruction({ units: 200_000 });
// 2. Set the compute unit price (microLamports per CU)
const setPriceIx = getSetComputeUnitPriceInstruction({ microLamports: 50_000n });
Place these instructions first in the transaction.
Estimating the right price
Use getRecentPrioritizationFees to see what recent transactions paid:
import { createSolanaRpc } from "@solana/kit";
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const fees = await rpc.getRecentPrioritizationFees().send();
// Sort by fee to find the median
const sorted = fees
.map((f) => f.prioritizationFee)
.sort((a, b) => Number(a) - Number(b));
const median = sorted[Math.floor(sorted.length / 2)];
console.log(`Median recent fee: ${median} microLamports/CU`);
Fee guidelines
| Scenario | Typical price (microLamports/CU) |
|---|---|
| Low congestion | 1,000 - 10,000 |
| Normal traffic | 10,000 - 100,000 |
| High congestion | 100,000 - 1,000,000 |
| Competitive (MEV, snipe) | 1,000,000+ |
Optimizing costs
- Set accurate compute unit limits. Simulate first, then set the limit to actual usage + 10-20%. A lower limit means a lower total priority fee for the same price.
- Use per-account fee data.
getRecentPrioritizationFeesaccepts account addresses — pass the accounts your transaction touches to get more relevant fee estimates. - Adjust dynamically. Check recent fees before each transaction rather than using a hardcoded value.
FAQ
Do I always need priority fees? During low congestion, transactions land with zero priority fee. But adding even a small fee provides insurance against sudden congestion spikes.
What happens if my fee is too low? The transaction may be deprioritized and dropped when the blockhash expires. You will need to rebuild and resend.
Are priority fees refunded if the transaction fails? The priority fee is charged proportional to the compute units consumed before the failure. The base fee is always charged.
How do priority fees interact with Jito tips? Jito tips are separate from priority fees. Tips go to the Jito block engine operator; priority fees go to the validator. For maximum landing rate during congestion, use both.
Updated: