Every Bitcoin block contains a few thousand transactions. Miners hand-pick these transactions and insert them into the block. They have the choice to accept or reject a transaction to be inserted in a new block. That leads to a question: if they have a choice, how do they choose which Bitcoin transactions to pick and add to the block? That’s the question we are going to answer in this tutorial of our Blockchain Roadmap for Beginners.
Before we get to how miners pick transactions, we need to understand what a mempool is. A mempool is like a staging area where transactions are stored before they are confirmed. That’s right, a Bitcoin transaction isn’t confirmed the moment you send someone some Bitcoin. The transaction sits in this buffer area called mempool for some time, until it is added to some block by a miner. Only then it is confirmed.
Every miner has a separate mempool associated to them. These mempools contain unconfirmed transactions. When a new transaction gets added to a mempool, the mempool then relays this information to its neighbouring node’s mempool and so on. This ensures all mempools are kept updated with all the latest transaction information.
When a user makes a Bitcoin transaction, they also add a small transaction fee along with that transaction. This transaction fee is payable to the miner. The user making the Bitcoin transaction is free to pay any amount of transaction fees they want to, even zero fees! Most Bitcoin wallets suggest an estimated transaction fee the user should pay for their transaction to go through. The transaction and the transaction fee that the user is willing to pay both move to mempool, waiting to be added to a block.
How do miners pick Bitcoin transactions?
A mempool at a time contains many Bitcoin transactions along with their transaction fees. The miners then pick transactions willing to pay the highest transaction fees and add them to the block. Since the transaction fees is to be paid to the miner, higher the transaction fees, more likely the miner is to pick your transaction and add it to the next block he will mine.
Each miner could pick the same transactions and try to mine the block, that is indeed possible. But ultimately, only one miner will successfully mine a block at a time and so the transaction will go through only once.
Can you pay zero transaction fees?
Yes, you can totally pay zero transaction fees for a Bitcoin transaction. But there is a strong chance of your transaction getting rejected in that case. Miners pick transactions with maximum incentive for them. Zero transaction fees means the miner has absolutely no profit to gain from that transaction. So no miner will pick your transaction to add it to a block.
Note: Unconfirmed transactions sitting in mempools for 72 hours are returned back. So if you decide to pay zero fees for a transaction, it is likely that your transaction will not get picked by a miner. Unpicked transactions are returned after 72 hours.
Post Transaction Mining
Once the transaction is inserted in a block mined successfully, the transaction is deleted from the mempool of the miner who mines that block. This information is then relayed to the neighbouring mempool and so on until all mempools know that the transaction is confirmed. This ensures that the transaction is deleted from all mempools and no miner picks the same transaction again while mining the next block.