Canonical: https://solanashreds.xyz/learn/priority-fee-from-a-transaction

# How to work out what a transaction paid in priority fee

Calculate a Solana priority fee from decoded fields: compute unit price times limit, plus the base fee per signature, with a worked example.

To calculate a Solana priority fee for a legacy or v0 transaction, multiply the compute unit price in micro-lamports by the compute unit limit, divide by one million and round up. Add 5,000 lamports per signature, counting signatures that precompile instructions verify, for the total fee. A v1 transaction states its priority fee as a total in lamports instead.

## The base fee

Every transaction pays 5,000 lamports per signature it requires. "Signature" here includes more than the transaction's own: precompile instructions that verify Ed25519, secp256k1 or secp256r1 signatures add their count, which is the first byte of their instruction data. A transaction with one signer and one Ed25519 check pays 10,000 lamports of base fee, not 5,000.

## The priority fee formula

For legacy and v0 transactions, the price comes from a `SetComputeUnitPrice` instruction and the limit from `SetComputeUnitLimit`, both described in [compute budget instructions](https://solanashreds.xyz/learn/compute-budget-instructions):

1. Priority fee = ceiling of (price in micro-lamports × compute unit limit ÷ 1,000,000).
2. If there is no limit instruction, the limit is the default: 200,000 units for each instruction to an ordinary program and 3,000 for each instruction to a builtin such as the System or Compute Budget program, capped at 1,400,000.
3. If there is no price instruction, the priority fee is zero.
4. Total fee = 5,000 × signatures, including precompile ones, + priority fee.

The fee is set by the limit requested, not by the compute actually used.

## Four real transactions, worked through

Each total below equals the fee mainnet charged, as recorded in the block's metadata. They come from slots 470,901,815 and 470,901,816.

| Case | Inputs | Priority fee | Total fee |
| --- | --- | --- | --- |
| Explicit price and limit | 200,248 µlamports × 205,834 units, 1 signature | 41,217.6, rounded up to 41,218 | 46,218 |
| Price, no limit instruction | 5 µlamports; one Compute Budget instruction (3,000) and one Associated Token Account instruction (200,000), so 203,000 units | 1.015, rounded up to 2 | 5,002 |
| v1 configuration mask | priority fee field 6,223 lamports, 1 signature | 6,223 | 11,223 |
| A precompile signature | 1 transaction signature plus 1 Ed25519 verification | 421 | 10,421 |

The first transaction asked for 205,834 units and used 171,530, and still paid for 205,834. The v1 transaction asked for 4,000 units and used 3,047; its fee did not depend on either.

Across the two blocks, this method reproduced the charged fee for 164 legacy and v0 transactions with explicit price and limit, 20 with a price but no limit, and 134 v1 transactions, with no mismatches.

## Reading the same fields from a v1 transaction

[Transaction v1](https://solanashreds.xyz/learn/transaction-v1) carries the priority fee directly: bits 0 and 1 of the configuration mask select an eight-byte value that is the fee in lamports. There is no price to multiply, and Compute Budget instructions inside a v1 transaction are ignored for fees. The compute unit limit is still in the mask, but it plays no part in the fee. Mixing the two models is the usual error: reading a v1 fee as a price per unit, or adding up Compute Budget instructions the runtime ignored.

## What the formula cannot tell you

The formula gives what was charged, given that the transaction landed. It cannot tell you how many compute units the transaction used, whether it succeeded or whether it paid anything else for inclusion, such as a tip sent as an ordinary transfer. Units consumed and the success flag are execution outputs. A failed transaction that landed still paid this fee in full; a transaction that never landed paid nothing.

## Fees from shreds, before anything executes

Every input to the formula is inside the transaction, so a shred decoder can compute the fee a transaction will pay if it lands, as soon as it arrives. That makes fees one of the few money figures available before execution. [Fees and tips in code](https://solanashreds.xyz/docs/programs/fees-and-tips) implements it, and [DEX volume before confirmation](https://solanashreds.xyz/blog/dex-volume-before-confirmation) shows the limits of the other money figures.

## Questions about priority fees

### What is a micro-lamport?

A millionth of a lamport. Compute unit prices are quoted in micro-lamports per compute unit.

### Is the priority fee based on compute units used?

No. It is based on the compute unit limit, either requested or the default.

### Why is my calculated fee 5,000 lamports short?

Most likely a precompile signature: an Ed25519, secp256k1 or secp256r1 verification instruction adds to the signature count.

## Where a computed fee can be wrong

The default-limit rule depends on which programs count as builtins, and that list can change between releases, so check results against `meta.fee` from RPC when you can. Validators can also change fee rules through feature gates. And the fee says nothing about whether the transaction landed, which [reconciliation](https://solanashreds.xyz/docs/pipeline/reconcile) settles; until then it is the fee the transaction would pay.

## Fees in code

The [fees and tips recipe](https://solanashreds.xyz/docs/programs/fees-and-tips) decodes all of this, and [what your decoder cannot see](https://solanashreds.xyz/blog/what-your-decoder-cannot-see) lists what remains out of reach. To compute fees on your own feed, [decode a first transaction from raw shreds](https://solanashreds.xyz/docs/quickstart).
