solanasetpriorityfee.com

The complete guide to Solana priority fees

Solana Priority Fee Best Practices for Developers

Setting Solana priority fees correctly is as much art as science. Pay too little and your transaction gets dropped during congestion. Pay too much and you waste SOL unnecessarily. These best practices help you strike the right balance for production applications.

1. Always Use Dynamic Fee Estimation

Never hardcode a priority fee value. Network conditions on Solana change dramatically — from sub-1,000 microlamports per CU on quiet nights to millions during popular NFT mints. Always fetch real-time fee data before sending transactions:

// Fetch fees, take the 75th percentile, add a buffer
const fees = await connection.getRecentPrioritizationFees();
const p75 = getPercentile(fees.map(f => f.prioritizationFee), 75);
const recommendedFee = Math.ceil(p75 * 1.2); // 20% buffer

2. Optimize Your Compute Unit Usage

Since the priority fee is calculated as CU price × CU limit, reducing your transaction's compute unit consumption directly reduces your fee cost at the same priority level. Use simulateTransaction to measure actual CU consumption and set a tight limit:

// Simulate to get exact CU usage
const simulation = await connection.simulateTransaction(transaction);
const actualCUs = simulation.value.unitsConsumed;

// Set limit slightly above actual usage for safety
const cuLimit = Math.ceil(actualCUs * 1.1); // 10% buffer
transaction.add(ComputeBudgetProgram.setComputeUnitLimit({ units: cuLimit }));

3. Add Budget Instructions First

Always add setComputeUnitPrice and setComputeUnitLimit as the first instructions in your transaction. While Solana technically processes them regardless of position, placing them first is conventional and avoids potential issues with certain programs.

4. Understand Local Fee Markets

Solana has local fee markets per writable account. If your transaction writes to a highly contested account (e.g., a popular DEX pool), the fee market for that account may be much higher than the global fee market. Use account-specific fee estimation when available.

5. Implement Retry Logic with Fee Escalation

If a transaction fails to land, don't just resend it with the same fee. Implement exponential fee escalation:

async function sendWithRetry(transaction, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    const multiplier = Math.pow(2, i); // 1x, 2x, 4x
    const fee = baseFee * multiplier;
    transaction.add(ComputeBudgetProgram.setComputeUnitPrice({
      microLamports: fee
    }));
    try {
      const sig = await connection.sendRawTransaction(transaction.serialize());
      return sig;
    } catch (e) {
      if (i === maxRetries - 1) throw e;
    }
  }
}

6. Monitor Network Conditions

Use getRecentPerformanceSamples to check current TPS and slot times before deciding on a fee strategy. If the network is processing well above 2,000 TPS, congestion is low and you can use minimal fees. Below 1,500 TPS often signals rising congestion.

The single biggest mistake developers make with Solana priority fees is setting a fixed fee value. A fee that works today may be 100x too low tomorrow during a popular token launch.

— Chainstack Solana Developer Guide
  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