What Are Priority Fees?

On Solana, each transaction has a base fee. Priority fees allow you to pay an additional fee so your transaction is prioritized over others in the validator’s queue. This extra amount helps ensure validators process your transaction before ones offering a lower fee.

In practice, you set a price for each compute unit (CU) your transaction may use. The higher the price, the more likely your transaction will be included first.

Why Priority Fees Matter

When the Solana network is busy, transactions without priority fees can experience delays. Adding a priority fee helps your transaction get confirmed faster. Common use cases include:

  • Minting NFTs during popular launches
  • Swapping tokens during market volatility
  • Making time-sensitive trades
  • Any operation during high network congestion

Priority fees keep your transaction ahead of the crowd by incentivizing validators to process it first.

How Priority Fees Work

Priority fees are implemented using the Solana Compute Budget Program. You add two special instructions to your transaction:

  1. setComputeUnitPrice - Sets the price (in micro-lamports) you’ll pay for each compute unit
  2. setComputeUnitLimit - (Optional) Increases the maximum compute units your transaction can use

These instructions tell validators how much you’re willing to pay to prioritize your transaction.

How Much Should You Pay?

The appropriate priority fee depends on:

  1. Current network conditions
  2. How quickly you need confirmation
  3. What others are paying for similar transactions

Rather than guessing, Helius provides the getPriorityFeeEstimate API to calculate an appropriate fee based on recent transactions. The API offers several priority levels:

  • “Min” (0th percentile)
  • “Low” (25th percentile)
  • “Medium” (50th percentile)
  • “High” (75th percentile)
  • “VeryHigh” (95th percentile)

Basic Implementation Pattern

Here’s the general pattern for adding priority fees to your transactions:

// 1. Create your transaction with regular instructions
const transaction = new Transaction();
transaction.add(
  // Your regular instructions here
);

// 2. Get a priority fee estimate
const feeResponse = await connection.rpcRequest("getPriorityFeeEstimate", [
  {
    transaction: bs58.encode(transaction.serialize()),
    options: { priorityLevel: "Medium" }
  }
]);
const priorityFee = feeResponse.result.priorityFeeEstimate;

// 3. Add the compute budget instruction for the fee
transaction.add(
  ComputeBudgetProgram.setComputeUnitPrice({
    microLamports: priorityFee
  })
);

// 4. Complete and send the transaction
transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
transaction.sign(signer);
const signature = await sendAndConfirmTransaction(connection, transaction, [signer]);

Priority Fees with Staked Connections

When using Helius’ Staked Connections, priority fees play an important role:

  • For Shared Staked Endpoints, your priority fees must meet or exceed the recommended value from the Priority Fee API to access staked connections
  • For Dedicated Staked Endpoints, priority fees still determine your transaction’s position in the validator queue