X

How to Set Priority Fees

Step-by-step implementation guide for developers

How to Set Priority Fees on Solana | Step-by-Step Guide

Introduction

Setting priority fees on Solana requires adding a ComputeBudgetProgram instruction to your transaction. You define the compute unit price in micro-lamports — the higher you set it, the more likely validators are to prioritize your transaction during congestion.

Using web3.js

Use ComputeBudgetProgram.setComputeUnitPrice({ microLamports: X }) to attach a priority fee. For production apps, calculate fees dynamically using getRecentPrioritizationFees() or a dedicated Priority Fee API to stay competitive with current market conditions.

Dynamic Fee Strategy

For most applications, use the 50th percentile fee level as a starting point. Time-sensitive operations like NFT mints or DeFi swaps benefit from the 75th–95th percentile. Monitor network load in real-time and adjust your microLamport price accordingly.

To set a priority fee using @solana/web3.js:

const priorityFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
  microLamports: 50000
});
transaction.add(priorityFeeIx);

Set microLamports to your desired price per compute unit. Higher values increase transaction priority. For production, fetch the current market rate using getRecentPrioritizationFees() or a dedicated Priority Fee API.

Also consider setting the compute unit limit explicitly to avoid overpaying:

const cuLimitIx = ComputeBudgetProgram.setComputeUnitLimit({
  units: 200000
});

Related Resources

implementation

01
Install @solana/web3.js
02
Create ComputeBudgetInstruction
03
Set Compute Unit Price
04
Broadcast Transaction
Step-by-Step Implementation
2
Instructions to Add
6
Priority Levels Available
<0.01
USD Typical Cost

user feedback

Priority Fees Solana

Marcus T.

Solana user

The step-by-step guide made it trivial to implement priority fees in our dApp. Transaction success rate went from 78% to over 96%.

Priority Fees Solana

Yuki S.

Solana user

Dynamic fee calculation using the Priority Fee API is a game changer. Our users never overpay and always land their transactions.