How to Set Priority Fees on Solana | Step-by-Step Guide
Introduction
Setting priority fees on Solana requires adding a ComputeBudgetProgram instruction to your transaction. You define the compute unit price in micro-lamports — the higher you set it, the more likely validators are to prioritize your transaction during congestion.
Using web3.js
Use ComputeBudgetProgram.setComputeUnitPrice({ microLamports: X }) to attach a priority fee. For production apps, calculate fees dynamically using getRecentPrioritizationFees() or a dedicated Priority Fee API to stay competitive with current market conditions.
Dynamic Fee Strategy
For most applications, use the 50th percentile fee level as a starting point. Time-sensitive operations like NFT mints or DeFi swaps benefit from the 75th–95th percentile. Monitor network load in real-time and adjust your microLamport price accordingly.
To set a priority fee using @solana/web3.js:
const priorityFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 50000
});
transaction.add(priorityFeeIx);
Set microLamports to your desired price per compute unit. Higher values increase transaction priority. For production, fetch the current market rate using getRecentPrioritizationFees() or a dedicated Priority Fee API.
Also consider setting the compute unit limit explicitly to avoid overpaying:
const cuLimitIx = ComputeBudgetProgram.setComputeUnitLimit({
units: 200000
});








