npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

solana-priority-fee

v1.1.0

Published

Priority fee estimation for Solana with caching, monitoring, and success tracking

Downloads

228

Readme

solana-priority-fee

Priority fee estimation for Solana with caching, real-time monitoring, and success tracking.

Install

npm install solana-priority-fee @solana/web3.js

Quick Start

const { Connection } = require('@solana/web3.js');
const { getPriorityFee } = require('solana-priority-fee');

const connection = new Connection('https://api.mainnet-beta.solana.com');

// Get a fee estimate
const fee = await getPriorityFee(connection, 'fast');
console.log(fee); // e.g., 50000 microlamports

Fee Levels

| Level | Percentile | Use Case | |-------|------------|----------| | economy | 25th | Can wait, saving costs | | medium | 50th | Normal transactions | | fast | 75th | Need quick confirmation | | urgent | 95th | Time-critical, willing to pay |

Full API

SolanaFeeEstimator

const { SolanaFeeEstimator } = require('solana-priority-fee');

const estimator = new SolanaFeeEstimator(connection, {
  cacheMs: 5000,        // Cache duration (default: 5s)
  minFee: 1000,         // Minimum fee (default: 1000)
  maxFee: 10_000_000,   // Maximum fee cap (default: 10M)
});

getFee(options)

const fee = await estimator.getFee({
  level: 'fast',           // economy | medium | fast | urgent
  accountKeys: [pubkey],   // Optional: specific accounts for better accuracy
  useCache: true           // Optional: use cached data (default: true)
});

getAllFees(accountKeys?)

const fees = await estimator.getAllFees();
// {
//   economy: 10000,
//   medium: 25000,
//   fast: 50000,
//   urgent: 150000,
//   raw: { min, max, median, samples }
// }

Real-time Monitoring

// Start monitoring (updates each slot)
await estimator.startMonitoring((fees) => {
  console.log(`Slot ${fees.slot}: medium=${fees.medium}`);
});

// Get trend analysis
const trend = estimator.getTrend();
// { trend: 'rising' | 'falling' | 'stable', change: '+15.2%' }

// Stop monitoring
await estimator.stopMonitoring();

Success Tracking

// Record transaction results
estimator.recordResult(50000, 'fast', true);  // landed
estimator.recordResult(50000, 'fast', false); // dropped

// Get success rates per level
const rates = estimator.getSuccessRates();
// { fast: { total: 10, landed: 8, rate: '80.0%' }, ... }

Stats

const stats = estimator.getStats();
// {
//   requests: 100,
//   cacheHits: 85,
//   cacheHitRate: '85.0%',
//   isMonitoring: true,
//   ...
// }

Helper Functions

createPriorityFeeInstruction

const { createPriorityFeeInstruction } = require('solana-priority-fee');

const ix = await createPriorityFeeInstruction(connection, 'fast');

const tx = new Transaction().add(
  ix,
  // ... your other instructions
);

Account-Specific Fees

For more accurate estimates, pass the accounts your transaction writes to:

const fee = await estimator.getFee({
  level: 'fast',
  accountKeys: [poolAddress, userTokenAccount]
});

This uses getRecentPrioritizationFees with lockedWritableAccounts for account-specific data.

Example: Full Transaction

const { Connection, Transaction, SystemProgram } = require('@solana/web3.js');
const { createPriorityFeeInstruction, SolanaFeeEstimator } = require('solana-priority-fee');

const connection = new Connection('https://api.mainnet-beta.solana.com');
const estimator = new SolanaFeeEstimator(connection);

async function sendWithPriorityFee(fromKeypair, toAddress, amount) {
  // Get priority fee instruction
  const priorityFeeIx = await createPriorityFeeInstruction(connection, 'fast', [toAddress]);
  
  // Build transaction
  const tx = new Transaction().add(
    priorityFeeIx,
    SystemProgram.transfer({
      fromPubkey: fromKeypair.publicKey,
      toPubkey: toAddress,
      lamports: amount
    })
  );
  
  // Send and confirm
  const sig = await connection.sendTransaction(tx, [fromKeypair]);
  const result = await connection.confirmTransaction(sig);
  
  // Track result for success rate analysis
  estimator.recordResult(
    priorityFeeIx.data.readBigUInt64LE(1), // fee from instruction
    'fast',
    result.value.err === null
  );
  
  return sig;
}

License

MIT