getRecentPrioritizationFees
Explore getRecentPrioritizationFees: Use Cases, Code Examples, Parameters, Response Format, and Pro Tips
The getRecentPrioritizationFees
RPC method surfaces fee data from the last ~150 blocks, showing the extra “priority” fee paid (in micro‑lamports per compute unit) by transactions that gained early inclusion. By analyzing recent fee levels, you can choose competitive priority fees to improve your transaction’s chances of rapid processing during congestion.
✅ Common Use Cases
Dynamic Fee Estimation Determine a target priority fee by observing what fees succeeded in recent blocks.
Network Congestion Analysis Gauge current load by tracking the distribution of paid prioritization fees.
Wallet Fee Suggestions Power wallet UIs to recommend realistic priority fees based on live network conditions.
Time‑Sensitive Operations For arbitrage bots or auction sniping, set an optimal fee to beat competing transactions.
🛠 Request Parameters
{
"lockedWritableAccounts": [
"<base58Pubkey1>",
"<base58Pubkey2>",
…
] // Optional, max 128 entries
}
lockedWritableAccounts If provided, returns fees from transactions that locked all specified accounts. Omit or pass
[]
to get a global view of recent prioritization fees.
📦 Response Structure
An array of objects (most recent first), each with:
[
{ "slot": 12345678, "prioritizationFee": 5000 },
{ "slot": 12345677, "prioritizationFee": 0 },
…
]
Code Examples
const fetch = require('node-fetch');
async function getRecentPrioritizationFees(rpcUrl) {
try {
const response = await fetch(rpcUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'getRecentPrioritizationFees',
"params": [[
"Vote111111111111111111111111111111111111111",
"Stake11111111111111111111111111111111111111"
]]
}),
});
const data = await response.json();
// Print the exact full response
console.log('Full RPC Response:');
console.log(JSON.stringify(data, null, 2));
return data;
} catch (error) {
console.error('Error getting health:', error.message);
return null;
}
}
// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';
getRecentPrioritizationFees(RPC_URL);
Example Response
{
"jsonrpc": "2.0",
"result": [
{
"prioritizationFee": 0,
"slot": 355373923
},
{
"prioritizationFee": 0,
"slot": 355374059
},
{
"prioritizationFee": 0,
"slot": 355374071
},
{
"prioritizationFee": 0,
"slot": 355374072
}
],
"id": 1
}
💡 Developer Tips
Units Matter Fees are in micro‑lamports (0.000 001 lamports) per compute unit (CU). Multiply by your CU usage to get total priority fee.
Short Cache Window Most nodes cache this data for ~150 blocks (~1–2 minutes). Use it for very recent fee trends only.
Zero Fees ≠ No Demand A
prioritizationFee
of0
can simply mean no matching transactions paid extra fees, not that the network was free.Statistical Selection Rather than picking the single highest fee, consider the median or 75th percentile of non‑zero fees to avoid overpaying.
Combine with Compute Budget Ensure you set both
ComputeBudgetProgram.setComputeUnitLimit
and.setComputeUnitPrice
to apply your chosen priority fee effectively.
By leveraging getRecentPrioritizationFees
, you can fine‑tune transaction fees to current network conditions and enhance your transaction confirmation success.
Last updated