solanasetpriorityfee.com

The complete guide to Solana priority fees

How to Set a Priority Fee on Solana: Step-by-Step Guide

Setting a priority fee on Solana requires adding two Compute Budget Program instructions to your transaction: setComputeUnitPrice and (optionally) setComputeUnitLimit. This guide walks you through the complete process using the @solana/web3.js library in TypeScript.

Prerequisites

  • Node.js v18+ installed
  • @solana/web3.js package installed (npm install @solana/web3.js)
  • Basic familiarity with Solana transactions

Step 1 – Import ComputeBudgetProgram

The ComputeBudgetProgram class from @solana/web3.js provides two key static methods:

import { ComputeBudgetProgram, Transaction, Connection, Keypair } from '@solana/web3.js';

Step 2 – Set the Compute Unit Price

The setComputeUnitPrice instruction defines how many micro-lamports you pay per compute unit. A higher value means higher priority:

const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({
  microLamports: 100000, // 0.1 lamports per CU
});

Step 3 – (Optional) Set the Compute Unit Limit

If your transaction's compute requirements are known, set an explicit CU limit to avoid paying for unused units. The default is 200,000 CUs per non-builtin instruction:

const computeLimitInstruction = ComputeBudgetProgram.setComputeUnitLimit({
  units: 300000, // adjust to your transaction's needs
});

Step 4 – Add Instructions to Your Transaction

Add both instructions at the beginning of your transaction, before your main program instructions:

const transaction = new Transaction();

// Add compute budget instructions FIRST
transaction.add(priorityFeeInstruction);
transaction.add(computeLimitInstruction);

// Then add your main instructions
// transaction.add(yourMainInstruction);

Best Fee Levels by Use Case

  • Non-urgent transfers: 1,000–5,000 microlamports
  • Standard dApp transactions: 10,000–50,000 microlamports
  • NFT minting events: 100,000–500,000 microlamports
  • MEV / time-critical: 1,000,000+ microlamports

Common Mistakes to Avoid

  • Setting CU limit too low — transaction will fail mid-execution.
  • Hardcoding a fee — network conditions change, use dynamic estimation.
  • Not adding priority instructions before other instructions.
  • Using priority fees without also optimizing CU consumption.

Most transactions today use priority fees. Ignoring them can result in your transaction being dropped during periods of high network activity.

— QuickNode Solana Developer Guide, 2025
  1. The Common category includes then following block: Paragraph, image, heading, latest gallery, quote, audio, cover, video. The paragraphs block is the default block type. This is should not to have any alignment of any kind.

  • The Common category includes then following block: Paragraph, image, heading, latest gallery, quote, audio, cover, video. The paragraphs block is the default block type. This is should not have any there alignment of any kind. Category and then there are many things too following blocks and many more.

  • Leave A Comment

    All fields marked with an asterisk (*) are required