X

Solana Priority Fee API

getRecentPrioritizationFees & Developer Integration

Solana Priority Fee API

Solana Priority Fee API

The Solana Priority Fee API provides developers with real-time fee data to optimize transaction costs dynamically. Rather than hardcoding a static fee, using the API allows your application to adapt to current network conditions — paying only what's necessary for the speed you need.

Use getRecentPrioritizationFees to retrieve fee data from the past 150 blocks and estimate the optimal compute unit price for your transaction.

getRecentPrioritizationFees RPC Method

Solana's standard RPC includes the getRecentPrioritizationFees method, which returns an array of prioritization fee data from recent blocks. The response includes the slot number and the minimum fee that was paid for transactions included in that block. This data helps developers gauge the current fee market and set competitive fees.

One limitation of getRecentPrioritizationFees is that it returns a list of minimum fee values across the past 150 blocks, which makes it useful for understanding the floor but less precise for estimating the optimal fee for guaranteed fast inclusion. For production applications, fees are localized by program and can vary substantially depending on which accounts your transaction writes to.

Advanced Priority Fee APIs

Several providers offer enhanced priority fee APIs that simplify fee estimation. The Helius Priority Fee API introduces a getPriorityFeeEstimate method that returns a single recommended fee value at six priority levels: Min, Low, Medium, High, Very High, and Unsafe Max. This approach accounts for both global network conditions and local fee markets specific to the accounts and programs your transaction interacts with.

To integrate dynamic priority fees in your application using web3.js: first fetch the recommended fee using the API, then construct a ComputeBudgetProgram.setComputeUnitPrice() instruction with the returned value, and add it as the first instruction in your transaction. Combine this with setComputeUnitLimit() set to a tight estimate of your actual compute usage to minimize unnecessary fee payments.