How to see the priority fee a Solana transaction paid
A Solana transaction's fee is one number, meta.fee, with the priority fee hidden inside it. The price per compute unit sits in a base58 instruction the RPC does not decode. Here is how to split the fee, read what the sender asked for, and check the two agree.
The formula
- Base fee = 5,000 lamports × number of signatures.
- Priority fee =
meta.fee− base fee. - What the sender asked for = ceil(compute-unit price × compute-unit limit ÷ 1,000,000). The price is in micro-lamports per compute unit and comes from
SetComputeUnitPrice; the limit comes fromSetComputeUnitLimit.
Note the limit, not the units used. You pay for the compute you reserve.
The Compute Budget instructions
They are instructions to ComputeBudget111111111111111111111111111111. The first byte of the data says which one; the rest is a little-endian integer:
| First byte | Instruction | Value |
|---|---|---|
| 2 | SetComputeUnitLimit | u32, compute units |
| 3 | SetComputeUnitPrice | u64, micro-lamports per compute unit |
| 1 | RequestHeapFrame | u32, bytes |
| 4 | SetLoadedAccountsDataSizeLimit | u32, bytes |
With no SetComputeUnitLimit, the runtime uses a default: 200,000 compute units per top-level instruction, 3,000 for builtin programs such as System and Compute Budget, capped at 1,400,000.
Working code, zero dependencies
Save as priority-fee.mjs and run node priority-fee.mjs [signature]. Node 20+, the free public mainnet RPC unless you set SOLANA_RPC_URL.
// priority-fee.mjs: node priority-fee.mjs [signature]. Node 20+, no dependencies
const RPC = process.env.SOLANA_RPC_URL || "https://api.mainnet-beta.solana.com";
const signature = process.argv[2] ?? "x2nTgvSFFneAKW5W5mHcfMYhzen5o7Lfb1pBmepDQQDJZ4ud2Z7QpDxdYVVTVMDqG2e5TJ1qAA8zGDPAxdpudKR";
const COMPUTE_BUDGET = "ComputeBudget111111111111111111111111111111";
// Instruction data is base58. A few lines decode it.
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
function base58(s) {
let n = 0n;
for (const c of s) n = n * 58n + BigInt(ALPHABET.indexOf(c));
const out = [];
while (n > 0n) { out.unshift(Number(n & 255n)); n >>= 8n; }
for (const c of s) { if (c !== "1") break; out.unshift(0); }
return Uint8Array.from(out);
}
const readLE = (b, at, len) => { let v = 0n; for (let i = len - 1; i >= 0; i--) v = (v << 8n) | BigInt(b[at + i]); return v; };
const res = await fetch(RPC, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "getTransaction",
params: [signature, { encoding: "jsonParsed", maxSupportedTransactionVersion: 0 }] }),
});
const { result: tx } = await res.json();
// 1. What it paid: total fee minus 5,000 lamports per signature
const fee = tx.meta.fee;
const base = 5000 * tx.transaction.signatures.length;
console.log(`fee ${fee} = base ${base} + priority ${fee - base} lamports`);
// 2. What it asked for: the Compute Budget instructions
const ixs = tx.transaction.message.instructions;
let limit = null, price = 0n;
for (const ix of ixs) {
if (ix.programId !== COMPUTE_BUDGET) continue;
const b = base58(ix.data);
if (b[0] === 2) limit = Number(readLE(b, 1, 4)); // SetComputeUnitLimit(u32)
if (b[0] === 3) price = readLE(b, 1, 8); // SetComputeUnitPrice(u64, micro-lamports per CU)
}
// No SetComputeUnitLimit: 200,000 CU per top-level instruction, 3,000 for builtins like Compute Budget and System
const BUILTINS = new Set([COMPUTE_BUDGET, "11111111111111111111111111111111"]);
limit ??= Math.min(1_400_000, ixs.reduce((s, ix) => s + (BUILTINS.has(ix.programId) ? 3000 : 200000), 0));
const declared = (price * BigInt(limit) + 999_999n) / 1_000_000n; // round up
console.log(`price ${price} micro-lamports/CU x limit ${limit} CU = ${declared} lamports`);
console.log(`used ${tx.meta.computeUnitsConsumed} CU`);
Two real mainnet transactions:
$ node priority-fee.mjs
fee 106500 = base 5000 + priority 101500 lamports
price 500000 micro-lamports/CU x limit 203000 CU = 101500 lamports
used 255 CU
$ node priority-fee.mjs 2axWwMEc9F41wpeitiAzxfqaByUEQSfX1ghp4AcdFmUXsa69jEYSgRqhhhoUgtMCBGv6sutdAZ6yAfKwKoLXBP1d
fee 8750 = base 5000 + priority 3750 lamports
price 25000 micro-lamports/CU x limit 150000 CU = 3750 lamports
used 83261 CU
In both, what the transaction paid matches what it asked for to the lamport.
Why the first one paid for 800 times the compute it used
The first transaction is a plain USDC transfer. It set a price of 500,000 micro-lamports per compute unit but no limit, so it was charged for the default 203,000 units (one token instruction at 200,000 plus the Compute Budget instruction at 3,000). It used 255. A SetComputeUnitLimit of, say, 1,000 would have cut the priority fee from 101,500 lamports to 500.
The second, a pump.fun buy, did it properly: a limit of 150,000 for 83,261 used, at a low price.
If you write a wallet or a bot: always set the limit, from a simulation plus a margin. If you analyse transactions: meta.computeUnitsConsumed against the limit is how you spot this.
v1 transactions are different
Version 1 transactions carry no Compute Budget instructions. Their budget is in message.transactionConfig, and the priority fee there is a total in lamports, not a per-unit price. Ask for them with maxSupportedTransactionVersion: 1; with 0 the RPC refuses with error -32015.
The same thing, finished
solana-tx-parse does all of the above for legacy, v0 and v1 transactions, including the builtin list, the v1 transactionConfig and the version retry, with no dependencies:
npm install github:blixvip/solana-tx-parse
import { parseTransaction } from "solana-tx-parse";
const tx = await parseTransaction("x2nTgvSFFneAKW5W5mHcfMYhzen5o7Lfb1pBmepDQQDJZ4ud2Z7QpDxdYVVTVMDqG2e5TJ1qAA8zGDPAxdpudKR");
console.log(tx.fee);
console.log(tx.computeUnits);
{
lamports: 106500,
sol: 0.0001065,
baseLamports: 5000,
priorityLamports: 101500,
priorityLamportsDeclared: 101500,
signatures: 1
}
{
consumed: 255,
limit: 203000,
limitSource: 'default',
priceMicroLamports: 500000
}
Or from a terminal: npx github:blixvip/solana-tx-parse <signature> prints a Fee and a Compute line.
Limits to know
- Precompile signatures. Signatures verified by the Ed25519 or secp256k1 precompile programs also pay the base fee. The simple formula does not count them, so for those transactions part of the base fee shows up as priority.
- Old transactions. The default-limit rule above is today's. A transaction from before it may not match;
meta.feeminus the base is always the real priority figure. - To decide what to bid next, look at recent fees instead:
getRecentPrioritizationFees.