In our previous article, we discussed the general principles of how blockchain works. You came to understand that without decentralization and immutability, you can’t have an effective blockchain, or at least not a public one.
In this article, we are going to expand on why miners and cryptocurrency are essential byproducts of blockchain technology. After reading this article, you should have a better understanding of what the miners do, why they are necessary, and, perhaps of greatest interest to you, why the virtual cryptocurrency created in the mining process has instant real-world monetary value.
We will assume in this article that you already have a basic understanding of the hashing and Merkle tree concepts that are necessary to achieve immutability in blockchains. If you do not, we recommend that you go back and read our article on that subject matter now.
Hacking the Hash
Let’s say that I wanted to hack the Bitcoin blockchain and set my balance to the equivalent of millions of dollars and then go on a shopping spree. I would need to do three things:
- Find out which block in the chain contains my most recent account balance and change that value. Let’s say that block is 25 blocks behind the most recent block on the chain.
- Next, I would need to recalculate the hash values of all 25 successive blocks in the chain until I reach the final block, the hash value of which will match with the fraudulent change I made.
- Finally, I need to repeat this process on at least 51% of all nodes participating in the Bitcoin blockchain so that when next queried, they all reach a consensus that I have millions of dollars worth of Bitcoin in my account.
Given that in reality, the block you need to change could be millions of blocks back in the chain and that the nodes you need to hack would number in the thousands or tens of thousands, the odds of being able to successfully handle that much hashing in a lifetime are practically non-existent. It would take a supercomputer of immense power to even stand a chance. Now consider that this would have to be done inside a window of a few seconds to a few minutes before a new block is added to the chain (disrupting your calculations) and you will understand why it is practically impossible to hack a blockchain in this manner.
Even so, the code contributors and founders of popular blockchains like Bitcoin and Ethereum weren’t satisfied with even those odds, and therefore they have mandated that before a new block can be added to a chain, its final hashed value must be even more difficult to calculate than the hashed value of a block’s data plus its predecessor’s hash. They manage this by setting a difficulty target that basically demands that the hashed value of a block plus a value called a nonce must result in a string of characters beginning with a predetermined number of zeros.
For example, an SHA-1 hash of “Polyrific” looks like this:
If you wanted to guess the word that was hashed into the value above, you would have to run a brute-force algorithm to hash different combinations of letters through the SHA-1 protocol until you had the same hash as above. In relative terms, this wouldn’t take too long.
The difficulty rule, however, dictates that the hashed value of “Polyrific” plus a nonce value must equal a hash that is led by a certain number of zeros like this:
The more leading zeros, the more difficult it is to create a nonce value that, when hashed with the original block value, will produce the correct answer. Moreover, there is no known mathematical way to arrive at the correct nonce value–you have to try millions and millions of different combinations until it produces the correct outcome. This is the process of mining, and it makes the alteration of any block in the chain without changing the value of the chain’s most recent block computationally impossible.
Multiple transactions from multiple, unrelated participants go into a single block. It’s not feasible to request that people simply trying to send money to someone else do so by coordinating with other people making transactions at the same time and together running calculations to guess a nonce value. That’s where the miners come in.
Miners do the hard work of finding the correct nonce of each block to the benefit of everyone with pending transactions which must be bundled in a block and added to the chain before they are complete. Without the work that the miners do, blockchains would be less secure because it would become computationally possible (though not easy) for a hacker to alter the interlaced hash values of a chain. Because there are so many miners out there, new blocks can be added to the chain within a few seconds, though Bitcoin manipulates the difficulty of the work so that blocks are added roughly every ten minutes.
A miner can be anyone from an individual running open-source mining software on their home PC, to large warehouses of specialized mining equipment where hundreds or thousands of machines toil away at producing blocks to be used in the chain.
For every nonce guessed by a miner, a block is produced that can be added to the chain. Its label is that hash value we have discussed that contains DNA from the block that came before it as well as the hashed value of its own contents plus the nonce value, all producing a hash value with the correct number of leading zeros that will, in turn, be hashed-in with the next block on the chain.
The amount of Bitcoin that will ever be minted is limited to ฿21,000,000 and, over time, the difficulty in finding a correct nonce value will increase thereby making blocks harder to create and Bitcoin more scarce. This is the origin of the mining analogy–as time progresses, precious metals and stones are increasingly difficult to find.
The blockchain rewards cryptographic tokens, or cryptocurrency, to the miners for each block that is added to the chain in this manner.
Understanding the concept of cryptocurrency, how it is valued, the need for its existence, and how it is created in the first place can for some of us be the most confounding subject on your way to understanding the blockchain. Let’s demystify the subject then by starting with a simple set of premises I am sure you can accept:
- Work has to be done to build each block (see Mining section above).
- Transactions need to be packed in a block in order to be added to a chain.
- Miners are paid by the blockchain itself to do the work necessary to build these blocks so that transactions can be added to the chain. Payment is in the form of cryptocurrency.
Huh? How can the blockchain itself pay the miners? You can’t just invent a phony currency, hand it to people, and expect it to have value, right? Actually, yes you can. Here’s how:
If I wanted to send you $10,000 US dollars and I didn’t want to do so by going through a bank or any other conventional services, I might elect to do convert my US dollars to Bitcoin (BTC) and then transfer them over to you through the blockchain where you would then use an exchange such as Coinbase to convert the Bitcoin back to US dollars.
Making this transaction requires that I first use an exchange such as Coinbase to make a real-life transaction where I buy $10,000 worth of Bitcoin (which converts to roughly ฿3.62 at the time of this writing). So who am I buying the Bitcoin from? They come from the miners that were awarded newly minted Bitcoin for adding a block to the chain.
So I purchase $10,000 on an exchange like Coinbase and now a miner has $10,000 real US dollars and I now have ฿3.62 Bitcoin. In reality, it doesn’t need to be a miner that I am directly buying from as Bitcoin has changed hands so often now that the Bitcoin you buy may not be newly minted, but that is beside the point. In our example, the miner just went and made a down payment on a house with those cold-hard US dollars.
I transfer the ฿3.62 Bitcoin to you via the blockchain and you now convert it back to US dollars, also through an exchange like Coinbase. Who bought them back from you? Possibly the next person in the line that needed Bitcoin to make a transfer on the blockchain, or perhaps it was an investor speculating that the value of Bitcoin would rise over time (it has, dramatically).
You see, blockchains harbor their own micro-economies with the value of their currency rising and falling over time just like it does with the fiat currencies we use every day. You may think that you would only send money over the Bitcoin blockchain for nefarious reasons. While it is true that many participants do indeed have nefarious motives, there are many cases in which the use of the Bitcoin or Ethereum blockchains makes perfect sense. It is, after all, much faster and much less expensive than using traditional 3rd party wire transfer services and there is an inherently higher degree of trust as well since it is cryptographically infeasible (if not impossible) to fake a transaction–if you say you sent me ฿3.62 ($10,000), I just need to go take a look at the Bitcoin ledger–any of them–to confirm.
We hope that this article has helped you better understand how mining and cryptocurrency works. You probably still have questions and we are here to help. Please contact us so that we can help you integrate blockchain technology into your enterprise.