> ## 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.

<Info>
  **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.
</Info>

## 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.

<CardGroup cols={2}>
  <Card title="Base Fees vs Priority Fees" icon="coins">
    **Base fees** are fixed costs for transaction processing

    **Priority fees** are optional payments for faster processing
  </Card>

  <Card title="How They Work" icon="rocket">
    You set a price per compute unit - higher prices get processed first during network congestion
  </Card>
</CardGroup>

## Why Use Priority Fees

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

<CardGroup cols={2}>
  <Card title="Reliable Confirmation" icon="circle-check">
    Ensure your transactions confirm quickly and reliably, even during varying network conditions
  </Card>

  <Card title="Competitive Edge" icon="trophy">
    Stay competitive in time-sensitive operations like trading, minting, and DeFi interactions
  </Card>

  <Card title="User Experience" icon="heart">
    Provide consistent, fast transaction processing for better user experience
  </Card>

  <Card title="Network Efficiency" icon="gauge">
    Help optimize network resource allocation and overall performance
  </Card>
</CardGroup>

## Priority Levels Explained

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

<AccordionGroup>
  <Accordion title="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>

  <Accordion title="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>

  <Accordion title="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>

  <Accordion title="High">
    **75th percentile** - Higher fees for faster processing

    **Best for**: Time-sensitive operations and competitive scenarios

    **Note**: Prioritized processing during network activity
  </Accordion>

  <Accordion title="VeryHigh">
    **95th percentile** - Premium fees for maximum speed

    **Best for**: Critical operations, MEV strategies, urgent transactions

    **Note**: Fast confirmation even during high network activity
  </Accordion>

  <Accordion title="UnsafeMax">
    **Maximum observed** - Highest fees seen in recent slots

    **Best for**: Emergency situations only

    **Warning**: Often unnecessarily high - use with caution
  </Accordion>
</AccordionGroup>

<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.
</Warning>

## Implementation Methods

<CardGroup cols={2}>
  <Card title="Serialized Transaction (Recommended)" icon="file-code" href="/priority-fee/estimating-fees-using-serialized-transaction">
    **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>

  <Card title="Account Keys (Advanced)" icon="key" href="/priority-fee/estimating-fees-using-account-keys">
    **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
  </Card>
</CardGroup>

## Quick Start Example

<CodeGroup>
  ```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
        }
      }]
    }'
  ```
</CodeGroup>

## API Reference

<Card title="getPriorityFeeEstimate" icon="code" href="/api-reference/priority-fee/getpriorityfeeestimate">
  Complete API documentation with all parameters and response formats
</Card>

## 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.
</Tip>

## Support & Resources

<CardGroup cols={2}>
  <Card title="Discord Community" icon="discord" href="https://discord.com/invite/6GXdee3gBj">
    Get help from the community and Helius team
  </Card>

  <Card title="Direct Support" icon="headset" href="/support">
    Priority fee questions and optimization assistance
  </Card>
</CardGroup>
