# getRecentPrioritizationFees

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

```json
{
  "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:

```json
[
  { "slot": 12345678, "prioritizationFee": 5000 },
  { "slot": 12345677, "prioritizationFee": 0    },
  …
]
```

***

**Code Examples**

{% tabs %}
{% tab title="Nodejs" %}

```javascript
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);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def get_recent_prioritization_fees(rpc_url):
    try:
        response = requests.post(
            rpc_url,
            headers={
                'Content-Type': 'application/json',
            },
            json={
                'jsonrpc': '2.0',
                'id': 1,
                'method': 'getRecentPrioritizationFees',
                'params': [[
                    'Vote111111111111111111111111111111111111111',
                    'Stake11111111111111111111111111111111111111'
                ]]
            }
        )
        
        data = response.json()
        
        # Print the exact full response
        print('Full RPC Response:')
        print(json.dumps(data, indent=2))
        
        return data
        
    except Exception as error:
        print(f'Error getting health: {error}')
        return None

# Example usage
RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key'
get_recent_prioritization_fees(RPC_URL)
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "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` of `0` 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coinvera.io/integration/solana/rpc/getrecentprioritizationfees.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
