How to Set Priority Fee on Solana
Adding a priority fee to a Solana transaction requires two instructions from the Compute Budget Program: one to set the compute unit limit and one to set the compute unit price. Both must be added before any other instructions in your transaction.
Setting compute unit price is the single most impactful thing you can do to improve transaction landing rates during congestion.
Using ComputeBudgetProgram
With the @solana/web3.js library, you use ComputeBudgetProgram.setComputeUnitPrice() to specify the microlamports per compute unit you are willing to pay. This value directly determines your transaction's priority in the validator's queue.
You should also call ComputeBudgetProgram.setComputeUnitLimit() to specify the exact compute budget your transaction needs. Setting this accurately (rather than using the default 200,000 CUs) reduces the fee you pay and signals good intent to validators.
Dynamic Fee Estimation
For production applications, hard-coding a fixed microlamport value is not ideal. Instead, use the getRecentPrioritizationFees RPC method to query recent fee levels for the accounts your transaction touches. This method returns the minimum fee needed to be included in recent blocks, giving you a data-driven baseline.
Alternatively, providers like Helius offer a Priority Fee API that returns percentile-based estimates (low, medium, high, very high) calculated from real-time network data. Using the 50th-percentile estimate is a good starting point for most applications.
Best Practices
Always add compute budget instructions as the first instructions in your transaction. Monitor confirmation rates and adjust your fee tier based on observed landing success. During periods of low congestion, even a minimal fee of 1,000–5,000 microlamports is often sufficient to achieve fast confirmation.



