Deep dive into Bitcoin fees
If you're new to Bitcoin, cryptocurrencies, and blockchain you can check out my "Introduction to crypto world"
Yesterday my colleague asked to send him 40$ in Bitcoin equivalent. I had some coins in one of exchange wallets on my phone and I sent them to him. Right after that I went to blockchain.info to check status and this is what I saw:
I was unpleasantly surprised to see that I just paid almost half of transaction in fees. FYI, exchange wallets don't have the option to choose fee and take an average fee in the network.
For all zealous bitcoin fans - this is more than I've paid in fees for Ethereum transaction for the last year (and there was at least 50). And still, I had to wait for 30 minutes to get first confirmation.
I understand that Bitcoin network now suffers from spam attack but there should be some mechanics to prevent those attacks. I decided to take look into how Bitcoin ecosystem reacts to such attacks and how fees are calculated.
I found this nice infographic about mining difficulty that killed the purpose of writing long explanation:
Why mining is difficult
In simple terms: the hash of a block must start with a certain number of zeros. The probability of calculating a hash that starts with many zeros is very low, therefore many attempts must be made. In order to generate a new hash each round, a nonce is incremented. This is based on the hashcash function, which requires dedicated article to explain.
The Bitcoin Network Difficulty Metric
The Bitcoin network difficulty is the measure of how difficult it is to find a new block compared to the easiest it can ever be. It is recalculated every 2016 blocks to a value such that the previous 2016 blocks would have been generated in exactly two weeks had everyone been mining at this difficulty. This will yield, on average, one block every ten minutes.
As more miners join, the rate of block creation will go up. As the rate of block generation goes up, the difficulty rises to compensate which will push the rate of block creation back down. Any blocks released by malicious miners that do not meet the required difficulty target will simply be rejected by everyone on the network and thus will be worthless.
The Block Reward
When a block is discovered, the miner gets a certain number of bitcoins, which is agreed-upon by everyone in the network. Currently, this number is 12.5 bitcoins; this value will halve every 210,000 blocks (~4 years). You can check out next halving date here - http://www.bitcoinblockhalf.com.
Additionally, the miner is awarded the fees paid by users sending transactions. The fee is an incentive for the miner to include the transaction in their block. Today fees are an important part of miner income and it will only be increasing.
Fees
Recently Bitcoin broke his highs not only in price but also in fees. Comparing with Ethereum (and any other coin), it's huge:
If you think that reason for fees is that Bitcoin handles more transaction - it's not true:
Also note that Bitcoin Cash, which claims that they have much lower fees and scalability already has bigger fees than Ethereum but much, much, much lower transaction rate.
Only miners win from such high fees, but only in short term. Recently the value of transaction fees paid to miners has reached an all-time high of $2.3 million. That is ridiculously many:
Regular users can't anymore use bitcoin for a small transaction (I'm not even talking about microtransactions) because they'll have to either pay a huge percentage from their transaction either wait for at least few hours. I personally know that many people now use Ethereum as their main transfer coin.
How fees are calculated
If you receive a payment of 1.5 BTC and another of 2 BTC, you'll have 2 new amounts in your wallet, of 1.5 BTC and 2 BTC. They don't become a single 3.5 BTC coin. Over time you'll build up a collection of differently sized amounts in your wallet, and the client needs to decide which ones make the best fit for the amount you're trying to spend.
These amounts are known as the "inputs" of your new transaction, and the amounts you are sending (including any change that gets sent back to your own wallet) are known as the "outputs".
If any of the outputs, including change of your transaction, are less than 0.01 BTC, then a fee of 0.0001 BTC is required. The algorithm is careful to avoid selecting coins that result in a change amount of less than 0.01 BTC if at all possible. For example, if you're paying 0.35 BTC and you have in wallet 0.3505 BTC and 0.4 BTC - the algorithm most likely choose the second one. This is one of the spam protection mechanics.
Fees and confirmation time depends on transaction size and Fee per byte value you or your software will decide.
Fee per byte depends mainly on how many transactions are already in mempool and how long you can wait till confirmation. If you'll go to https://bitcoinfees.earn.com, you'll see that fastest transaction fee is currently 540 satoshis/byte which will be most likely included in next block.
For example, you want to make a transaction with 511 satoshi/byte price that weight 554 bytes. To calculate fees:
554 ( size) * 511 (satoshi/byte) / 100 000 000 (satoshis in bitcoin) = 0.00283094
Which is exactly $20 I paid yesterday
Solving scalability issue
Of course, Bitcoin developers and whole community agree that it's not ok to have such high fees. Also, more and more people are getting in Bitcoin, so price, as well as the size of mempool, will increase.
One way to scale is to increase block size from 1mb to 2-4mb, but it's a temporary solution and BCash has already gone this way.
Block size can be set to unlimited size but this is a move to centralization as the bigger block size, fewer people can run bitcoin node.
Another way is to clear space for more transactions by moving some heavy protocol stuff out from the block - it's called SegWit and it already works in Bitcoin. Problem is, most clients still don't support SegWit and most transactions aren't using it:
The most promising way is off chain transactions. Lightning Network is the most popular implementation. It works by moving transactions to the side chain while the funds are linked to bitcoin funds. I want to write a whole article about off chain transactions, side chains, and state channels. For now, you can read more here: https://bitcointalk.org/index.php?topic=1764396.0 and here https://lightning.network/
`
P.S. You can send zero fees transaction and wait for a long time to have it confirmed (often more than 24 hours). If mempool will clear your transaction will go through. If not you'll get back your BTC in a few days.
If you liked an article you can subscribe to my telegram channel where I publish best articles, news, and videos about cryptocurrencies
https://t.me/hippo_money
Sources:
https://bitinfocharts.com/
https://blockchain.info/
https://bitcoinfees.earn.com/
https://jochen-hoenicke.de/queue/#30d
http://bitcoinfees.com/
https://www.bitcoinmining.com/what-is-bitcoin-mining-difficulty/
Congratulations @tmaniac! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @tmaniac! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!