A transaction fee is the remainder of a bitcoin transaction.
Math Using the example above:
transaction fee = (sum of inputs) - (sum of outputs) transaction fee = (0.8) - (0.6 + 0.15) transaction fee = 0.8 - 0.75 transaction fee = 0.05
Transaction fees are claimed through the coinbase transaction.
Why use a transaction fee? A transaction fee acts as an incentive for a miner to include your transaction in their candidate block.
So if there are a lot of bitcoin transactions floating around the memory pool and not all of them can fit in to a block, a transaction fee can be used as a way to "buy space" in a block.
- Bitcoin blocks are limited to 1MB (1,000,000 bytes) in size.
- Transaction data takes up space in a block (roughly 250 bytes for a typical small one).
So when a miner fills up a block with transactions, they will want to maximize the amount of money they can collect in fees. They do this by selecting transactions that give them the most money in fees for the space they take up in the block.
So when you're working out your transaction fee size, the important metric is the fee-per-byte.
|TXID||Fee (BTC)||Size (bytes)||Fee-per-Byte|
The remainder of any bitcoin transaction is the transaction fee. All of it.