Why do we mine bitcoin? ⛏️
Mining bitcoin fulfills multiple functions within the bitcoin network. As we saw last week, mining is necessary to confirm transactions so that the bitcoin network participants can transact with one another. Furthermore, bitcoin mining enables a fair issuance scheme for newly created bitcoin.
At a predetermined rate (embedded in the bitcoin source code), every new block contains some new bitcoin for the miner who finds the block. When Satoshi Nakamoto created bitcoin, the issuance rate was 50 bitcoin per block, halved every four years. This so-called "halving" occurs approximately every four years until all the 21 million bitcoin are issued.
However, the main reason why we need mining in bitcoin is to keep the network secure. Since the bitcoin network does not have a centralized power to show everyone who owns what, we need a decentralized network of computers that maintain this ledger. By design, bitcoin is only secure as long as at least 51% of the bitcoin miners behave honestly. Therefore, the more computers that mine bitcoin, the harder it becomes for anyone to cheat.
What are computers doing when they "mine"? 💻
Mainstream media occasionally refer to bitcoin mining as computers executing complex computations and make it sound more complicated than it is. The mining process closer resembles solving a Sudoku puzzle than any advanced calculation. Let's explore why!
Every computer that mines bitcoin delivers a certain amount of computational power. According to the network's overall computational network, miners calculate a number known as the "difficulty" every two weeks. This number ensures that a new block is created roughly every ten minutes despite miners joining and leaving the network.
Miners collect unconfirmed transactions from bitcoiners worldwide and create a summary of all these transactions (more commonly known as a "hash", check out this online tool to play around with the algorithm used in bitcoin). Together with some generic transaction data (metadata) and a random number (also known as "nonce"), they again hash these three data points.
The miners then compare this to the target number they calculate based on the previously mentioned "difficulty", also known as the "target". If the calculated hash is smaller than the target, the block is valid, and the miner broadcasts it to the rest of the miners. Once this happened, every miner checks if the block is valid, and every miner starts from scratch to mine a new block. If the calculated hash is bigger than the target, the miner changes the "nonce", creates a new hash, and again compares it to the target.
Currently, billions of attempts (of random numbers) and rehashing the data points are necessary to find a new valid block. Since bitcoin mining requires a lot of (computational) work, this concept is also known as "Proof-of-Work" (PoW). On the other hand, verifying whether a block is valid doesn't require a lot of energy at all. A miner inputs the three data points into the hashing function and checks if they get the same result as the miner who found the block.
Doesn't this sound similar to a Sudoku puzzle? They are also hard to solve but very easy to check if the provided solution is correct. As more miners join the bitcoin network, finding a valid block becomes harder (as the "difficulty" rises). You may compare this to an ever-growing Sudoku puzzle with more and more squares!
If you look at the transaction hashes of a few recent blocks, you'd probably see a similarity:
Exactly! They all start with a lot of zeros. Miners found these blocks after making billions of attempts of finding a hash lower than the target (the more trailing zeros, the better). They all tried to solve the "Sudoku" puzzle and show the rest of the miners their correct solution first.
Although this was a more technical blog post, we hope you've enjoyed reading about the bitcoin mining process. If you have further questions, don't hesitate to reach out to us!
More Bitcoin 101
We hope you’ve enjoyed our sixth blog post in the series “Bitcoin 101 - What is bitcoin?”. If you want to know more about the bitcoin mining process, stay tuned for the next blog post! We’ll be publishing one blog post every week answering many of the questions we’ve heard from our Stekking users who are new to bitcoin:
- What is bitcoin?
- How and where can I buy bitcoin?
- How and where can I use bitcoin?
- Where should I keep my bitcoin stored safely?
- How does a bitcoin transaction work?
- How does bitcoin mining work?
- What are the advantages and disadvantages of using bitcoin?
- What is a blockchain and how does it work?
- How does bitcoin compare to other cryptocurrencies?
- Why should I want to have bitcoin?