> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Solana Priority Fee API: Smart Transaction Fee Estimation

> Estimate optimal priority fees for Solana transactions. Real-time fee analysis with six priority levels to ensure fast confirmation and cost efficiency.

> [!NOTE]
>
> **Save money, improve performance**: Get precise priority fee estimates based on real-time network conditions. Pay only what you need for the speed you want.

## What Are Priority Fees?

On Solana, priority fees allow your transactions to jump ahead in the validator queue during network congestion. Think of them as express lanes for your transactions.

> [card] Base Fees vs Priority Fees
>
> **Base fees** are fixed costs for transaction processing
>
> **Priority fees** are optional payments for faster processing

> [card] How They Work
>
> You set a price per compute unit - higher prices get processed first during network congestion

## Why Use Priority Fees

Priority fees are now a standard part of Solana transactions, helping ensure reliable confirmation times and optimal network performance.

> [card] Reliable Confirmation
>
> Ensure your transactions confirm quickly and reliably, even during varying network conditions

> [card] Competitive Edge
>
> Stay competitive in time-sensitive operations like trading, minting, and DeFi interactions

> [card] User Experience
>
> Provide consistent, fast transaction processing for better user experience

> [card] Network Efficiency
>
> Help optimize network resource allocation and overall performance

## Priority Levels Explained

Our API provides six priority levels based on recent network activity:

> [accordion] Min
>
> **Lowest observed fee** - Based on minimum fees seen in recent slots
>
> **Best for**: Non-urgent transactions when cost optimization is priority
>
> **Note**: May result in slower confirmation times

> [accordion] Low
>
> **25th percentile** - Budget-friendly option with reasonable confirmation times
>
> **Best for**: Standard operations where speed isn't critical
>
> **Note**: Good balance of cost and reliability

> [accordion] Medium (Recommended)
>
> **50th percentile** - Median fee providing reliable confirmation times
>
> **Best for**: Most applications and general use cases
>
> **Note**: Recommended starting point for most developers

> [accordion] High
>
> **75th percentile** - Higher fees for faster processing
>
> **Best for**: Time-sensitive operations and competitive scenarios
>
> **Note**: Prioritized processing during network activity

> [accordion] VeryHigh
>
> **Upper tail, with headroom** - Premium fees for maximum speed
>
> **Best for**: Critical operations, MEV strategies, urgent transactions
>
> **Note**: Sits above the 95th percentile of observed fees and is not outlier-trimmed. Treat it as a landing target, not as a measure of what the network is paying

> [accordion] UnsafeMax
>
> **Maximum observed** - Highest fee seen in recent slots, with no outlier filtering
>
> **Best for**: Emergency situations only
>
> **Warning**: A single extreme bid anywhere in the lookback window sets this value. It regularly reaches billions of micro-lamports per compute unit - use with caution

## How Estimates Are Calculated

Estimates are derived from fees paid in recent slots (up to 150, controlled by `lookbackSlots`). Two details matter when you compare these numbers against your own on-chain measurements:

* **Non-vote transactions that set no compute unit price count as zero.** A large share of non-vote transactions in a typical slot include no `SetComputeUnitPrice` instruction at all. They enter the distribution as zero-fee samples, which is why `min` and `low` frequently return `0`. If you compute percentiles over priced transactions only, your numbers will be higher than ours at every level.
* **`veryHigh` and `unsafeMax` are not outlier-trimmed.** A handful of transactions bidding extreme amounts within the lookback window can raise both levels substantially, and `veryHigh` carries additional headroom above the 95th percentile so that it stays a viable landing target.

> [!WARNING]
>
> **Do not use `veryHigh` or `unsafeMax` as network fee statistics.** Both are deliberately tail-weighted and sit above what most transactions actually pay.

> [!WARNING]
>
> **Cost Calculation**: Total priority fee = Price per compute unit × Compute units consumed
>
> A typical transaction uses 200,000-400,000 compute units. At current Medium level (\~40,000 microlamports per unit), that's 0.000008-0.000016 SOL in priority fees. Always check current network conditions for accurate estimates.

## Scope: Global vs Account-Specific Estimates

What you pass determines what the API measures.

* **Pass a serialized `transaction`** - the estimate is scoped to the writable accounts your transaction locks. This is the recommended method when you are setting a fee to send with.
* **Pass `accountKeys`** - the estimate is scoped to those accounts. Include the **writable** accounts your transaction will lock, since those are the accounts you compete for.
* **Pass neither** - you get a **global estimate** across all recent network activity, not a fee tailored to your transaction.

> [!WARNING]
>
> **A global estimate is not a fee to pay.** With no `transaction` or `accountKeys`, the response describes network-wide conditions, including congestion on accounts your transaction never touches.
>
> Solana prices priority fees per writable account, so paying a global `veryHigh` usually means overpaying by a wide margin without improving your landing rate. Always pass a `transaction` or the writable `accountKeys` when the estimate will set a fee on a transaction you are about to send.

## Implementation Methods

> [card] [Serialized Transaction (Recommended)](https://www.helius.dev/docs/priority-fee/estimating-fees-using-serialized-transaction.md)
>
> **Primary Method** - Analyzes your exact transaction for maximum accuracy
>
> **Best for**: Most applications and production use cases
>
> **Benefits**:
>
> * Instruction-specific analysis
> * Highest accuracy
> * Production-ready
> * Considers transaction complexity

> [card] [Account Keys (Advanced)](https://www.helius.dev/docs/priority-fee/estimating-fees-using-account-keys.md)
>
> **Specialized Use Cases** - Estimates based on account patterns
>
> **Best for**: Pre-transaction analysis, batch operations, specialized architectures
>
> **Benefits**:
>
> * Account-level pattern analysis
> * Useful for planning and research
> * Batch account analysis

## Quick Start Example

```javascript JavaScript theme={"system"}
import { Transaction, SystemProgram, ComputeBudgetProgram } from "@solana/web3.js";
import bs58 from "bs58";

// 1. Build your transaction (without priority fee)
const transaction = new Transaction();
const transferIx = SystemProgram.transfer({
  fromPubkey: senderKeypair.publicKey,
  toPubkey: recipientPublicKey,
  lamports: 1000000, // 0.001 SOL
});
transaction.add(transferIx);

// 2. Set required fields and serialize
transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
transaction.feePayer = senderKeypair.publicKey;
const serializedTx = bs58.encode(transaction.serialize());

// 3. Get priority fee estimate
const response = await fetch("https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: "1",
    method: "getPriorityFeeEstimate",
    params: [{
      transaction: serializedTx,
      options: { 
        priorityLevel: "Medium",
        recommended: true 
      }
    }]
  })
});

const result = await response.json();
const priorityFee = result.result.priorityFeeEstimate;

// 4. Add priority fee and send
transaction.instructions = []; // Reset
transaction.add(ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priorityFee }));
transaction.add(transferIx);
transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
transaction.sign(senderKeypair);
```

```python Python theme={"system"}
import requests
import base58
from solana.transaction import Transaction
from solana.system_program import transfer, TransferParams

# 1. Build and serialize your transaction
# (transaction building code here)
serialized_tx = base58.b58encode(transaction.serialize()).decode('utf-8')

# 2. Get priority fee estimate
response = requests.post(
    "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY",
    json={
        "jsonrpc": "2.0",
        "id": "1",
        "method": "getPriorityFeeEstimate",
        "params": [{
            "transaction": serialized_tx,
            "options": {
                "priorityLevel": "Medium",
                "recommended": True
            }
        }]
    }
)

result = response.json()
priority_fee = result["result"]["priorityFeeEstimate"]
print(f"Recommended priority fee: {priority_fee} micro-lamports")

# 3. Rebuild transaction with priority fee and send
```

```curl cURL theme={"system"}
curl -X POST "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "getPriorityFeeEstimate",
    "params": [{
      "transaction": "SERIALIZED_TRANSACTION_BASE58",
      "options": {
        "priorityLevel": "Medium",
        "recommended": true
      }
    }]
  }'
```

## API Reference

> [card] [getPriorityFeeEstimate](https://www.helius.dev/docs/api-reference/priority-fee/getpriorityfeeestimate.md)
>
> Complete API documentation with all parameters and response formats

## Real-Time Network Monitoring

> [!TIP]
>
> **Pro tip**: Monitor network conditions to optimize your priority fee strategy. During normal conditions, use lower priority levels. During congestion, consider higher levels for time-sensitive operations.
>
> You can check current network conditions using Solana explorers or the `getRecentPerformanceSamples` RPC method.

## Support & Resources

> [card] [Discord Community](https://discord.com/invite/6GXdee3gBj)
>
> Get help from the community and Helius team

> [card] [Direct Support](https://www.helius.dev/docs/support)
>
> Priority fee questions and optimization assistance


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.