Transaction fee for Bitcoin/Litecoin explained.

When you send money to a Bitcoin or Litecoin address (or most other crypto currencies) then you need to pay a transaction fee. In this article I will explain what the transaction fee is, why you need to pay it, why the height of the transaction fee can differ, why the fees are different with Bitcoin and Litecoin and how the size of the transaction fee is calculated.

What is the transaction fee?

When you initiate a crypto payment then you send money from your address to another address. Because it needs to be clear that you actually have received money on your address so you are able to spend it and that the money that you want to spend has not been spend yet, the transaction needs to be verified (or 'confirmed') by a third party. That third party is a computer that does this calculation and is called a 'Miner'. There are millions of miners which sole purpose is to calculate the validity of transactions. Of course these miners need to be rewarded for their efforts and that is done in two ways:

  1. All verified transactions are placed in a so called 'block'. if the miner is the first to create a new block, it receives a number of free coins. the number is different per crypto currency. For Bitcoin that is 12.5 BTC at moment of this writing
  2. The miner receives a small amount from the sender of the bitcoin transaction. And that is the transaction fee.

Why do I need to pay the transaction fee?

Up to about the end of 2015, you did not need to pay the transaction fee and miners would pick the transaction for calculation anyway. It was more like a courtesy to do so. However, since the number of transactions grew, the last transactions a miner would pick to calculate were the transactions without a fee. And these transactions would wait until they were picked up by a miner or simply dropped from the 'mempool', the pool with all unconfirmed transctions. Dropped transactions are returned to the wallet after 2 weeks, so you won't loose your money if payment fails to confirm. But you want it to confirm of course and so it is better to pay the transaction fee. Nowadays, chances that a transaction without a fee is picked up by a miner is zero. it just won't happen because of the number of unconfirmed transactions. So...pay your fee.

Why is the height of the transaction fee different every time I initiate a payment?

If you use a modern wallet like Electrum, Trezor, you can make a choice between low, normal, economic, or high fee. With Coinbase there is no such choice and the fee is calculated automatically. Coinbase always uses the high fee. The height of the transaction fee is simply a matter of market movements. If you want your transaction to confirm instantly (meaning within a few minutes) then you simply pay a high fee so the miners will pick your transaction first. The higher the fee the more they like you. If the number of unconfirmed transactions is low, then a lower fee is sufficient for instant confirmation. If there is a high number of unconfirmed transactions and you choose to pay a low fee, you will have to wait longer for the transaction to be confirmed. If you are interested to see the fluctuations of Bitcoin fees, you can have a look at https://bitcoinfees.earn.com/

Why are the fees of Litecoin and Bitcoin different?

First of all, the price of the bitcoin is much higher then the price of Litecoin. So if you have 1 Bitcoin transaction and 1 Litecoin transaction and for both transactions you pay 0.0001 coin then that means that your Litecoin transaction costs you $0.19 and the Bitcoin transaction costs $11.81 (at time of this publication). So when the price goes up or down, so goes the 'value' of the transaction fee.

Secondly, more and more people are jumping on the Bitcoin train due to its success. So the number of transactions has multiplied many times over the past year, resulting in a huge number of unconfirmed transactions. That is because there is simply not enough computing power to confirm all these transactions instantly. That means that Bircoin miners are in high demand, resulting in the price of fees increasing. Litecoin is not in use as much as Bitcoin and the number of unconfirmed transactions are low. So a lower fee is sufficient and your transaction is confirmed much faster then a Bitcoin transaction.

For a view of the daily average transaction fees of Bitcoin and Litecoin have a look at https://bitinfocharts.com/comparison/transactionfees-btc-ltc.html#3m . The blue line is Bitcoin and the red line is Litecoin...

How is the size of the transaction fee calculated?

We will look at Bitcoin as an example. The bitcoin fee is calculated by the size of the transaction. This does not mean the amount of the transaction but the size of the hexadecimal string that represents the transaction. The average transaction has a size of 226 bytes. when you create the transaction your wallet looks at the fee that was used during the last 4 blocks for transactions that confirm instantly. That is, if you have set your wallet to 'high fee' or if you use Coinbase. This means that if the average fee was 400 satoshi/byte (1 satoshi is the smallest bitcoin amount, 0.00000001 BTC), your wallet does 400 * 226 (the size of the hex) / 100000000 = 0.000904 BTC.

we will use this 400 satoshi/byte later in the example.

If you choose a lower fee, like normal, then it looks for the average fee of maybe the last 25 blocks for confirmations that use 25 blocks. Then the average is not 400 sat/byte but for instance 150 sat/byte and that is used for the calculation.

There is a second parameter that is important and that is the number of 'inputs'. The more inputs the higher the size of the transaction. To understand inputs, I will give an example.

Person A sends 0.02 Bitcoin to your empty bitcoin wallet. After confirmation your wallet's balance is 0.02BTC which you can spend. So you decide to buy some Nirvana Seeds and need to pay 0.018 BTC for your order. After the transaction is done the balance in your wallet is 0.0011 BTC. that is, you paid Nirvana shop 0.018 BTC and you paid 0.0009 BTC transaction fee. The transaction will have 1 input and 2 outputs

The input is the 0.02BTC from your wallet address. The outputs are 0.0011 BTC to your wallet address (the change) and the 0.18 BTC to the Nirvana wallet address.

So your wallet received 1 input with the value of 0.0011 BTC which is also the balance. But hey, it's your birthday so your mom sends you 0.1 BTC and you receive 0.05 BTC from your best friend. this means your wallet contains 3 inputs with balance 0.1511 BTC. You decide to buy a nice watch plus some T-shirts from https://nirvana-goodies.com/ which costs you exactly 0.15 BTC **. You think, more then enough so you try to pay, but your wallet tells you that you don't have enough because the fee is to high. Wait, the fee was 0.0009 BTC just an hour ago! You should have enough, right? Not so, because your transaction needs 2 inputs to cover the sale. For 2 inputs, the fee is higher and so you actually need that 3rd input also but still it is not enough.

How does that work?

A transaction with 1 input and 2 outputs, the average transaction, is about 226 bytes. a transaction with 2 inputs is about 175 bytes extra. so your transaction for 0.15 BTC is 226 + 175 = 401 bytes. this means the fee(with 400sat/byte) is 400 * 401 / 100000000 = 0.001604 BTC and you only have 0.0011 extra. The clue is to set your wallet to a lower fee, but it means you have to wait longer to for the transaction to be confirmed. If it is too low, it will never confirm.

** Unfortunately you cannot pay with Bitcoin on Nirvana Goodies ....