How do Bitcoin fees work?
Hello Reader,
It's time to talk about the elephant in the room, Bitcoin fees.
When Bitcoin first launched, the cost of each transaction fee was negligible and in many cases, you could send transactions with zero fees which would still be processed.
However, I'm afraid that time has long gone and the average cost of a transaction has now crept above a dollar.
So what happened?
There are several factors which have led to the current fee price.
(1) Block Size
When Bitcoin first launched, the size of each block was at the discretion of each miner. However, early on in the life of Bitcoin, a maximum value was placed on the size of each block, known as the block size. This was implemented to prevent early network spam, set at 1MB and enshrined in Bitcoin's code.
The effect of this maximum size is to limit the number of transactions which can be included in each block. As there are only approximately six blocks per hour, this limits the transaction throughput of the bitcoin network.
(2) Supply and Demand
Over the last few years, the number of users and the amount of transactions per user has increased dramatically. However, the throughput of the network has remained static, limited by the unchanging block size.
In my article on mining, we learned that network fees are one of the incentive mechanisms that encourage miners to do their work to secure the network.A few years ago, the number of transactions per second was less than the capacity of the network as defined by the block size. This meant that miners would include nearly all transactions irrespective of the fees paid as it didn't impact their overall reward.
Now however, the number of transactions per second waiting to be processed exceeds the capacity of each block. As a result, it makes sense for miners to prioritise those transactions with the largest fees in order to maximise the miner reward for processing the block.
This creates a fee market whereby users of the Bitcoin network are competing with each other to ensure their transactions are processed.
How do they out compete other users?
They increase the fee they are willing to pay for each transaction, leading to a bidding war amongst users. The price therefore escalates until a ceiling is reached that users are willing to pay. If the number of transactions waiting to be processed increases, then the effect is that the fee is likely to increase and vice versa.
(3) Bitcoin Price
The final piece of the puzzle has been the explosion in the price of each Bitcoin. As the price increases it causes more exposure and therefore increased network usage. Additionally, as the price of each fee is denominated in Bitcoin, it also increases the price of transaction fees.
Fierce Debate
Can't the block size limit be increased to allow greater transaction throughput?
In simple terms, yes. However, this an over simplification to a much more intricate question which has been the subject of an incredible debate amongst the bitcoin community for the last several years. This scaling debate has been dramatic and has effectively split the community in two.
It is the most pressing topic in the world of bitcoin today, so I will be dedicating an article to just this shortly.
How are fees actually calculated?
As the scarce resource of the bitcoin network is space in each block, the price of a transaction is not dependent on the total number of bitcoins being sent, but instead on it's size in bytes.
What determines the size of a transaction?
The size of a bitcoin transaction is determined primarily by the number of transaction inputs and outputs.
An input is a source of bitcoins, akin to a "from" field
An output is a destination for bitcoins, akin to a "to" field
A couple of examples
Let's use an example to illustrate. Let's say that I have an address which has a balance of one bitcoin which I received originally in a single transaction. I want to send this entire bitcoin to my friends address.
This transaction would have a single input (my address) and a single output (my friends address).
Let's consider a slightly more complicated example. This time, I still have one bitcoin in my address, but the balance was built up over five different transactions to that address. I also only want to send 0.5 bitcoins to my friend.
In this case, the transaction will have 5 inputs as even though only one address holds the bitcoin, it is made up of five records. It will also have two outputs, one to send to my friends address and another to return the change to one of my addresses.
The size of an input is 180 bytes and an output is 34 bytes. Each transaction also typically requires 10 bytes for a data element.
So the first example would have a transaction size of 224 bytes (c. 0.2 KB) and the second would have a transaction size of 978 bytes (c. 1 KB).
There is one further complication, the transaction fees themselves. You don't actually specify an address to send a transaction fee to, rather the difference between the balance of inputs and outputs is deemed to be the transaction fee and is collected by the miner.
So my two examples above are examples of transactions which don't include a transaction fee and therefore would be unlikely to be processed by the network.
A more common implementation of my examples would therefore be that a user would send slightly less than the value of their inputs and the difference would be collected as a fee. Transaction fees do not count as an input or output and therefore do not form part of the transaction size calculation.
Price per byte
The last piece of the puzzle is what fee to pay for each byte of the transaction size. This is the element which is driven by market economics and therefore dependent on supply and demand.
There is a really great tool you can use which explains the number of transactions currently in the Bitcoin mempool along with the recommended fee per byte to pay to guarantee a transaction is included within X number of blocks.
The site shows a graph, explaining the number of transactions in the bitcoin mempool at various tranches of fee level. If you take a look at the first of the green tranches, the lower bound indicates the fee per byte required to have your transaction included in the next block.
At the time of writing, a fee of 301 satoshis per byte is the magic number. Using the simple example of a one input & output transaction above with a transaction size of 224 bytes results in a total fee of 67,424 satoshis, (0.00067424) bitcoins which at a price of c. $2,700 per bitcoin is $1.82.Of course, you could choose to pay a lower fee per byte than this, but your transaction would take longer to confirm. If you choose to pay too little, it may never be included in a block by a miner and therefore you will will need to wait for the transaction to drop out of the mempool (or look into replace by fee which is out of scope for this article).
Simple Calculator
Most wallets will do this calculation for you and simplify it by allowing you to choose a transaction speed which is used behind the scenes to determine the fee per byte to use.
However, occasionally you will want finer control and be able to calculate the fee you pay yourself. For those situations, I've created the below simple excel tool to help you out and I'll eventually make this an online tool you can access directly on Xexr.com.
<< Download Bitcoin Fee Calculator for Excel >>
You'll need a recent version of Excel (2013+) and will need to enable data connections when you open the file. The spreadsheet uses two data connections, one to get the latest mempool fee data and another to get the latest bitcoin price. As ever, leave me your feedback and questions in the comments below.
Sayonara folks!
If you’ve enjoyed this article, it would be my honour to have you as a regular reader.
Yours, X
Sources
Content: Xexr.com
Image: Wikimedia
Today's bunny picture gets you double the bang for your buck...
Sadly higher transaction fees and regulation from the major exchanges are taking away the core values of Bitcoin. Anonymity and no/low middleman fees.
It's definitely a little sad to see what has become of Bitcoin. I still think it has the potential to resolve these issues and emerge as a truly low cost payment network for the masses. Fingers crossed!
Thanks for the bitcoin fee calculator tool too! Very cute bunnies!!!
You're welcome and aren't they just :)
It cost way too much. how are you supposed to use bitcoin to buy anything for you local shop when it costs just as much in fee's!
pretty sure ive paid 3$ fees at least before just so my transaction doesnt get stuck in the ether.
You're definitely not wrong. Right now Bitcoin isn't really useable as a mass payment system, it's been relegated to a settlement layer. Still useful, but definitely not as exciting. My next post takes an in depth look at the challenges of scaling Bitcoin. Hopefully a solution is sooner than you think!