services
Get a key

library / How to use Solana / Priority fees and compute / HS0059

Block fee reward breakdown

One TypeScript file reads a recent finalized block, sums its transaction fees, splits them into base and priority parts, and sets the expected leader reward beside the Fee reward the block reports. It only reads.

By Carbium · Priority fees and compute · HS0059 · updated 2026-11-22

01

Where the fee lamports go

The Fee row in the getBlock rewards array is the block producer's income for that slot, paid in lamports to the leader's identity account. It comes from the fees of the transactions in the block, and it is smaller than their total. Each transaction's meta.fee is a base fee plus a priority fee. The base fee is 5,000 lamports for every signature on the transaction, plus 5,000 for every signature that an Ed25519, Secp256k1 or Secp256r1 precompile instruction verifies. The priority fee is the requested compute-unit limit times the compute-unit price, rounded up to a whole lamport.

Half of every base fee is burned. The leader keeps the other half and receives the whole priority fee. The reward for a block is therefore half the base fees plus all the priority fees. Base fees are multiples of 5,000, so the halving never leaves a fraction.

$A transaction that lands and fails still pays its fee, so the reward counts every transaction in the block whatever its result.
02

The code

Install @solana/kit at 8.6.0, export CARBIUM_KEY and run the file with Node 24, which strips the types on load. It takes no argument. It asks getSlot for the finalized slot (a cheap cached read at 1 cell), steps back five slots and reads that block with getBlock.

main.ts
// HS0059 · Block fee reward breakdown// https://carbium.sh/library/howsolana/block-fee-reward-breakdown// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";const apiKey = process.env.CARBIUM_KEY;if (!apiKey) {  console.error("CARBIUM_KEY is not set.");  process.exit(1);}const node = createSolanaRpcFromTransport(  createDefaultRpcTransport({    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",    headers: { "x-api-key": apiKey },  }),);const BASE_LAMPORTS = BigInt(5000);const TWO = BigInt(2);// Walk forward from `first` until a slot yields a block; skipped slots throw or return null.async function firstReadableBlock(first: bigint) {  for (let step = 0; step < 6; step++) {    const slot = first + BigInt(step);    try {      const block = await node        .getBlock(slot, { commitment: "finalized", maxSupportedTransactionVersion: 1, rewards: true, transactionDetails: "accounts" })        .send();      if (block) return { slot, block };      console.log(`slot ${slot} returned null, trying the next`);    } catch (e) {      console.log(`slot ${slot} failed: ${e instanceof Error ? e.message : String(e)}`);    }  }  return undefined;}// Burned half of the base fee never reaches the leader; the priority part is whatever is left of the total.function leaderShare(signatureCount: number, feeTotal: bigint) {  const base = BigInt(signatureCount) * BASE_LAMPORTS;  const priority = feeTotal - base;  return { base, priority, expected: base / TWO + priority };}const tip = await node.getSlot({ commitment: "finalized" }).send();const found = await firstReadableBlock(tip - BigInt(5));if (!found) {  console.error("No block could be read.");  process.exit(1);}const { slot, block } = found;const sums = block.transactions.reduce(  (acc, tx) => ({    sigs: acc.sigs + tx.transaction.signatures.length,    fee: acc.fee + (tx.meta?.fee ?? BigInt(0)),  }),  { sigs: 0, fee: BigInt(0) },);const { base, priority, expected } = leaderShare(sums.sigs, sums.fee);let reported = BigInt(0);let leader = "no Fee row";for (const row of block.rewards ?? []) {  if (String(row.rewardType).toLowerCase() !== "fee") continue;  reported += BigInt(row.lamports);  leader = row.pubkey;}console.log(`slot             ${slot}`);console.log(`transactions     ${block.transactions.length}`);console.log(`base fees        ${base} lamports (${sums.sigs} signatures x 5000)`);console.log(`priority fees    ${priority} lamports`);console.log(`expected reward  ${expected} lamports (half the base fees + all priority fees)`);console.log(`Fee reward       ${reported} lamports to ${leader}`);console.log(`difference       ${expected - reported} lamports`);

run: node main.ts

transactionDetails: "accounts" trims each transaction to its account list, signatures and meta, which is all the reconciliation needs: meta.fee and the signature count. rewards: true keeps the rewards array in the answer. maxSupportedTransactionVersion: 1 lets a block that holds a v1 transaction come back as data; without it, or with 0, the call answers -32015 for such a block.

Mainnet blocks carry no vote transactions since the Alpenglow switch, so the sum covers everything in the block. Each call names finalized because the transactions and rewards of a finalized block no longer change, so the sums and the reported figure come from the same settled data. A slot whose leader produced nothing makes getBlock throw. The block pick catches that, prints the reason and tries the next slot, up to six slots in all, so one skipped slot never ends the run.

The sums use bigint from start to finish. One reduce over the transactions adds up signatures and fees. The base fee is the signature count times 5,000. The priority fee is the fee total minus that base. The expected reward is half the base plus the priority fee. The reported figure adds up every rewards row whose type is Fee. The type is compared in lower case so the check holds whichever spelling the typed client hands back.

03

Reading the reconciliation

A run prints one line per value, all in lamports.

LineWhere it comes fromMeaning
transactionslength of block.transactionsHow many transactions the block holds.
base feessignatures times 5,000The fixed part, before the burn.
priority feessum of meta.fee minus base feesWhat senders paid to be ordered ahead.
expected rewardhalf the base fees plus all priority feesWhat the leader should have received.
Fee rewardsum of rewards rows of type FeeWhat the block reports, with the leader address.
differenceexpected minus reportedZero when every billed signature is a transaction signature.

An illustration with round numbers: a block holds transactions with 1,000 signatures in all and fees of 6,200,000 lamports. The base fees are 5,000,000 and the priority fees are 1,200,000. Half the base is 2,500,000, so the expected reward is 3,700,000 lamports, and the block should report a Fee row of 3,700,000.

The rewards array can hold rows of other types as well, and blocks near the start of an epoch often do. The filter on the type keeps all of them out of the reported total, so only Fee rows are summed. A block with no fees at all has no Fee row, and the file prints a reported reward of 0 and no address.

04

Why the totals can differ

A block with no precompile signatures gives a zero difference. A multiple of 2,500 shows precompile signatures. Any other gap comes from the read or from the rewards array.

  • A precompile instruction verified signatures. Each one pays the 5,000 base fee like a transaction signature does. The trimmed block holds no instructions, so the file counts only the transaction signatures. It books the extra 5,000 as priority fee and halves too little of it. The expected reward then sits above the reported one by 2,500 lamports per precompile signature, so the difference is a multiple of 2,500.
  • A difference that is not a multiple of 2,500 points at the read itself. Check that the sums cover the whole block and that no row of another type slipped into the reported total.
  • A reported reward of 0 beside a positive expected one means the rewards array came back without a Fee row. In the config that happens when rewards: false is set, since rewards defaults to true. On chain it happens when the fee deposit to the leader's identity account fails: the whole fee is burned and no Fee row is written.

To see which transactions carry a precompile instruction, read the same block with full details and decode the instructions as in Transaction fee breakdown. That read is larger than the trimmed one, so run it only on a block whose difference needs explaining.

05

Where it ends

The Fee row is one number per block for the leader's identity account. It cannot be split back into transactions, and it says nothing about the other reward rows or what the leader later does with the lamports.

The burned half appears in no rewards row. The file derives it from the signature count, so a block with a precompile instruction shows the gap described above until the instructions are read.

A skipped slot has no block, and a read of it fails with -32007. The file steps forward from there. Across many blocks, for an hourly or per-epoch total, the same read runs once per slot. For the movement of fees over time, Network fee trend chart builds on this kind of per-block figure.

Lamports are the unit throughout. Turning them into dollars needs a SOL price from you, and the file does not fetch one.

06

When it goes wrong

what goes wrongwhat to do
Error -32015 on getBlock.The block holds a v1 transaction and the call left out maxSupportedTransactionVersion or set it to 0. Pass maxSupportedTransactionVersion: 1 with the block config.
Slot failed with -32007, slot was skipped or missing.No block exists at that slot. The block pick moves to the next slot on its own; if you pick a slot yourself, take the following one.
The difference is a positive multiple of 2,500 lamports.Some transaction in the block had a precompile instruction that verified signatures. Read the block with full transaction details and count them from the instructions, as the fee breakdown entry does.
Fee reward prints 0 while the expected reward is positive.The answer carried no Fee row. Check that the config does not set rewards: false. If it does not, a failed deposit to the leader's identity account burned the whole fee for that block and left no Fee row.
The reported reward is far above the expected one.Rows of other types were added into the total. Keep only rows whose type is Fee, as the file does.
CARBIUM_KEY is not set.Export CARBIUM_KEY in the shell that runs node main.ts.
07

Questions

Why does the leader get only half of the base fee?

The other half is burned and leaves circulation. The leader keeps the remaining half of every base fee and all of each priority fee.

Is the Fee reward the same as the sum of meta.fee?

No. The sum of meta.fee is what senders paid. The reward is that sum minus the burned half of the base fees, so it comes out lower whenever the block holds any signature.

Do failed transactions add to the Fee reward?

Yes. The fee is charged once a transaction lands, whatever its instructions do, so failed transactions count in the sums and in the reward.

Why read the block with transactionDetails set to accounts?

The reconciliation needs only each transaction's fee and signature count. The trimmed form leaves out instructions and logs, which keeps the answer small.