pull down to refresh

Fee Calculation

Upcoming Topics:

  • Transaction Fees
  • Weight-vsize
  • Fee Rate
  • Fee Bumping (RBF, CPFP)
  • Security Budget Problem.

Fees in Bitcoin are calculated as the difference between inputs and outputs amounts.
Fee = Sum of Inputs - Sum of Outputs
Let's calculate the fee for the following transaction:
Fee = Input - (Output1 + Output2) = 299.99430000 - (0.00140000 + 299.99240000) = 0.00050000 BTC (50,000 sats)
Remember: Sum(Inputs) should always be greater than Sum(Outputs)

Why Do We Need Fees?

The purpose of fees is to incentivize miners to include transactions in the block.
Without fees, miners would have no reason to include transactions in their blocks.
  • But how exactly do miners decide which transactions to include?

How Miners Select Transactions?

Miners receive two types of rewards for securing the network:
  1. Block Reward
  2. Transaction Fees
A miner who mines a block will have revenue as: Revenue = Transaction Fees + Block Subsidy
To maximize their revenue, miners prioritize transactions that pay higher fees. The way they determine which transactions pay more will be covered in the next topic when we discuss fee rates.
For now, understand that:
  • Transactions paying higher fees get priority for inclusion (fast confirmation)
  • Transactions paying lower fees may wait longer in the mempool (or even fail)

Minimum Relay Fee

While miners can choose which transactions to include based on fees, there's actually a minimum threshold that transactions must meet just to be relayed through the network.
206 sats \ 0 replies \ @nullcount 21h
Sometimes miners can maximize revenue by (counterintuitively) including lower-fee txns.
Maybe those txns paid a fee "out of band" (like Mempool.space Accelerator). Or maybe those txns were involved in some MEV (Miner Extractable Value) scheme.
Additionally, not all miners' mempools are the same. Some mining pools run alternative BTC node implementations like Libre Bitcoin or Bitcoin Knots which have different mempool policies and therefore a miner may exclude a high paying tx that isn't in their mempool.
reply
Is there a typo in the last graphic in your post, which shows an arrow going from Tx 2 in the mempool to Tx 3 in the block? And same for arrow going from Tx 3 in mempool to Tx 2 in block.
Also, although you say you will discuss fee rates in the next article, I think it has to be discussed here, at least so long as you are making claims like "To maximize their revenue, miners prioritize transactions that pay higher fees", which is not true, miners prioritize fee rates, not total fees. This is further confused in the last graphic where it shows a 7000 sats fee tx getting prioritized over 5000 sats and 4000 sats transactions. Strictly speaking the miner would be looking at the fee rate and prioritizing accordingly (knapsack problem aside...)
reply
Love this! Keeping it basic, but also short, so that these fundamental topics are easy to digest.
reply