We all know when you make a bitcoin transaction, you're kind of competing for a limited amount of space in the next block and based on mining incentives we have to pay a fee to get it confirmed and the size of this fee isn't based on the amount of BTC you're sending but on the size and UTXO count of your transaction and how busy the network is. This is where the concepts of transaction weight and mempool depth come into play.
Transaction weight A transaction's weight is basically just a measure of its size but it's not a simple byte count. The concept of weight was actually introduced with the SegWit upgrade which significantly changed to how transaction data is treated.
A Bitcoin transaction is made up of two main parts;
- The core transaction data, which includes the list of inputs and outputs.
- The witness data which contains digital signatures that prove you have the right to spend the bitcoins.
To get more transactions into a block SEGWIT was used to introduce a system that gives the witness data a discount. The total size of a block is limited to 4 million weight units (WU). Legacy transaction data is heavy counting for 4 WU per byte but the witness data is actually lighter counting for around 1 WU per byte. This system incentivizes wallets to use SegWit enabled transactions which actually allows more of them to fit into a block and helping to scale the network. Your final fee is calculated by multiplying your transaction's total weight by your chosen fee rate (sats/vB)
and not actually (sat/bytes) most people make that mistake.Mempool DepthA transaction doesn't go directly into a block. First it gets broadcast to the network and sits in a waiting area which we know as the mempool. Every full node has its own mempool and they relay unconfirmed transactions to each other. So what miners do is that they look at the transactions in their mempool to decide which ones to include in the next block and because they are motivated by profit they will prioritize the transactions with the highest fee rates not fee.
Now, the depth of the mempool is a measure of this waiting room's congestion. It's not actually a technical property of a single transaction but more like a dynamic state of the entire network.
Imagine the mempool as a long queue with different lanes for different fee rates. The highest paying transactions are at the front and the lowest are at the back. Now when we talk about mempool depth, we are referring to how many transactions are waiting in each of those lanes.When the network is congested the depth of the mempool kinda increases which actually means you may have to pay a higher fee rate to get to the front of the line. However if the network is less congested and the mempool is shallow a small fee has a very high chance of getting you a quick confirmation. This is why Bitcoin transaction fees are not fixed.
Congestion also explains why sometimes the depth you see at the time of broadcasting your transaction may not be the depth the transaction will be confirmed at.