CHAPTER 5Mining

“Mining is the process of hashing the block header repeatedly, changing one parameter, until the resulting hash matches a specific target.”

—Andreas M. Antonopoulos, Mastering Bitcoin: Unlocking Digital Cryptocurrencies

In Chapter 1, “What Is a Cryptocurrency?,” you learned about the tribespeople of Yap and their huge stone coins called Rai coins that are mined on islands hundreds of miles away across the Pacific. The work involved to obtain a stone coin has always been a significant undertaking, so the expense and work involved gives a Rai coin its accepted value.

When we played with our NickCoin spreadsheet, we used the simple Python script to take the hash of a number of transactions and then, by adding incrementing values and hashing them with SHA256, we would search for a value starting with a certain number of zeros. When a solution was found, this could be used to close the block. Finding the solution required a significant amount of processing power, so the solution is a proof of an investment of work—in fact, not just work, but real time and money. When we played with the NickCoin spreadsheet, the winner of the hashing game won a few NickCoin. This is exactly the same as the real world: when a miner finds the solution to a block, he or she currently receives 12.5 bitcoin and the transaction fees that were taken for each transaction in the block.

The process is not dissimilar to trying to unlock a padlock that uses a combination. You need to try every ...

Get Investigating Cryptocurrencies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.