Synopsis: Crypto mining is something that confuses many newcomers to cryptocurrency. It’s best thought of as competitive bookkeeping! This article explains exactly what’s going on with the miners who are maintaining the network. Read it now to gain confidence in crypto mining.
There are three ways to acquire crypto:
1. Earning it through supporting the network (crypto mining)
2. Buying it from someone else, in exchange for ordinary cash
3. Getting paid with it, in exchange for goods and services
This article concerns the first method – crypto mining. The word “mining” comes from an analogy of digging for gold: expending effort to try and get something valuable. Proof-of-work miners support the network and get rewarded for their efforts.
A Competitive Game Of Chance
Proof-of-work crypto mining is like playing a game of chance, with other competitors playing at the same time. Let’s gain a better comprehension of how crypto mining works by first taking a trip to the circus.
Imagine a game where there are several upside-down cups, one of which conceals a ball. It costs a dollar to turn over a cup, so playing the game is costly. If the player correctly guesses which cup contains the ball, they win a prize. If there is no ball under the cup turned over, the player gets nothing. But if the prize is big enough – let’s say, a golden nugget – the player will be happy to play this game repeatedly because their uncommon big wins will outweigh their frequent small losses.
Now, let’s imagine this cup-and-ball game on a massive scale, with a million cups concealing a thousand balls. This extended version also has an extra feature: there are lots of other players participating at the same time, and only the first player to find a ball wins the prize. The extra players means that it has become a competitive game of chance. Readers can probably already see that the optimal strategy for finding a ball before anybody else does (and thus winning the prize) is to become as fast as possible at turning over cups.
Everyone else playing the game knows this too. So, all the players are furiously turning over cups as quickly as they can, trying desperately to find the proverbial needle in a haystack. Some will be faster at turning over cups than others. The fast players have a better chance of winning the game than the slow ones, but the slowest cup-turner could still get lucky.
Eventually, after much frantic searching, someone will find a cup with a ball. Once they do, they yell out loudly and hold their precious quarry aloft for all to see. “I’ve found it! I’ve found a ball!”. Although annoyed, all the other participants must acknowledge that yes, a ball has been found and the finder is to be awarded the prize. Once the first ball is found, all the cups and balls are shuffled and the game starts again with whoever wants to keep playing.
There’s one more thing to add to make the analogy with proof-of-work crypto mining complete: the circus ringmaster doesn’t want to be giving out too many prizes, so he regulates the game. Every so often, the ringmaster times how fast the game is being won. If the players are winning too quickly, he reduces the number of balls in play. For example, he could drop the total number of balls from 1,000 down to 500 while keeping the number of cups at 1 million, thereby increasing the difficulty. Or if it’s already too difficult and players are losing interest, the ringmaster can distribute more balls into the cups and make the game easier.
What Does This Have To Do With Crypto Mining?
Armed with this conceptual groundwork of the cup-and-ball game, we can now get into the nitty-gritty of what actually happens in crypto mining.
We have already described crypto as being a shared, decentralized ledger. This ledger needs to be updated over time as people transact. In the traditional financial system, this is the banker’s job. But there is no banker in crypto, so the software protocol gets the miners to play a competitive game of chance to win the privilege to effectively ‘be the banker’.
Miners must earn this privilege anew every block (remember, “blocks” are those regular collections of all the transactions throughout the network – in Bitcoin’s case, a block happens about every 10 minutes). Just as only the first one to find a ball under a cup gets the ringmaster’s prize, only the first crypto miner to win the competitive game of chance gets to update the ledger, and receive the reward that comes with it.
The block reward is what the miners stand to receive if they win the competitive game of chance – equivalent to the golden nugget in the cup-and-ball game. The block reward varies between the different crypto tokens. As of 2018, the Bitcoin protocol gives out a block reward of 12.5 Bitcoin every block.
To repeat, only the first winner of the competitive game of chance gets this reward. The winning miner takes all, and the losing miners take nothing. But because the game is played repeatedly every time a new block is created (about every 10 minutes, in Bitcoin’s case), losers have a chance to try and win next time.
The reason the protocol forces this guessing game upon the miners is to give crypto scarcity. Crypto needs to be costly to earn, like gold, which is difficult to dig out of the ground. If gold were everywhere, and anyone could pick up as much of it as they liked, gold wouldn’t hold much value as it wouldn’t be scarce. Scarcity is one of the defining characteristics for anything to have monetary value.
What “Game” Are The Miners Really Playing?
Now it’s time to get technical. To get to the bottom of what is really going on in the crypto mining game requires an understanding of hashing and hexadecimal. This is admittedly one of the trickier parts of the article – but we will try and take it slowly.
Let’s start with hashing. This is a cryptographic process that turns any length of data into a hexadecimal number of a fixed length. Hexadecimal is base 16. Humans are most familiar with base 10, with the digits 0 through to 9. Hexadecimal adds 6 more digits, represented by letters: A = 10 B = 11 C = 12 D = 13 E = 14 F = 15
A Bitcoin hash of letters and numbers is really a very big number. For example, the hexadecimal number 7DE81 is exactly equivalent to 515713 in base 10. Readers can try it out for themselves at https://www.binaryhexconverter.com/decimal-to-hex-converter.
Bitcoin uses a hashing algorithm called SHA256 to turn text inputs into hexadecimal hash outputs. Readers can try it out for themselves at https://passwordsgenerator.net/sha256-hash-generator. Here are a few examples of inputs and their hashed outputs:
Input: “The quick brown fox jumped over the lazy dog”
Hash Hexadecimal Output: 7D38B5CD25A2BAF85AD3BB5B9311383E671A8A142EB302B324D4A5FBA8748C69
Input: “I pay you 1 Bitcoin”
Hash Hexadecimal Output: 894084441302098FDF9CF1B775706297F28C4AEBF2EC9BBA77A764E461D905C6
Input: “I pay you 2 Bitcoin”
Hash Hexadecimal Output: A7546DB1064CAD5DACF70C93E88B75349920F76995E844B5210C09DACAEF4D41
There are a few things to note about hash hexadecimal outputs.
- The input can be as short, or as long as desired, but the length of the output remains the same. It is possible to translate a word, or an entire book – regardless, the SHA256 output will still be 64 characters long.
- Changing even a single digit in the input (e.g. changing the number from “1” to “2” in the last two examples), creates a completely different output. The hash hexadecimal outputs of the last two examples are not at all similar, even though the inputs were only one character different.
- Hashing is a one-way process. It is easy to take a given input and find its hash output, but it is computationally infeasible to go the other direction and take the hash and try and decode the message. When it comes to hashing, “you can’t unbake a cake”.
- It is also computationally infeasible to create a hash with given characteristics. Before putting the input through the hashing algorithm, there is no way to tell anything about what will come out the other end as output.
Now, back to the crypto miners playing the competitive game of chance. In each block, the network protocol sets a maximum threshold number. It then asks the miners to take the transaction data of everyone transacting within the network, and use this as input to create a hash hexadecimal output (which, remember, is also a number). Then, the miners need to check whether the hash hexadecimal output number they have found is below the network’s maximum threshold number. If the miner’s output number is below the threshold number, they have effectively ‘found a ball’ and can claim their prize (the block reward). If not, they have essentially ‘found a cup with no ball in it’ and have to keep trying.
Let’s put it another way, using an explanation with some more-familiar base-10 decimal numbers (which are completely equivalent to hexadecimal). The Bitcoin network is saying to the miners “you need to turn all the transactions over the last 10 minutes into a hash output, which must be less than a certain maximum threshold number which I decide”.
If 50 million is the maximum threshold number, then if a Bitcoin miner successfully finds a hash output with all the transactions of less than 50 million – congratulations – they get to update the ledger by winning the privilege of creating the next block in the blockchain, and collect the 12.5 Bitcoin block reward. If their hash output is above 50 million – sorry – try again. (This number “50 million” has been made up – purely for illustrative purposes.)
This is what the miners are doing. Miners gather up all the transaction data across the whole network over the last 10 minutes and then turns it into a hexadecimal hash output number. So the whole network’s collective messages – all those “I pay you 1 Bitcoin” and “I pay you 2 Bitcoin” transactions taking place all over the world – are aggregated together, hashed and checked against the threshold number, to try and find a winner.
The miners keep adjusting the input using something called a nonce, which is a single number unrelated to any transaction. The addition of this nonce will, however, will change the entire hash output (as we saw before – changing a single digit of the input completely changes the hashed output).
There is no way for the miners to find a hash output number which is below the network’s threshold number except through pure trial and error, just like the cup and ball game. The faster the computer processor can generate hashes, the more guesses they can make – but it’s still a guessing game. It is computationally infeasible for a computer to bypass the need to play the guessing game.
So the miners keep hashing, millions and millions of times, searching for a hashed output which is below the maximum threshold number that the protocol is asking for – akin to looking for balls under the cups. If a miner’s guesswork finds a solution, that miner broadcasts their solution to the whole network – effectively, like holding a ball aloft and shouting “I won!”. The winning miner then collects their block reward, the ledger is updated, and the game begins anew.
Then, every so often, the crypto network protocol adjusts the threshold number up or down to make the guessing game easier or harder for the miners. This ensures that the game isn’t being won too quickly or too slowly – just as the circus ringmaster adds or removes balls from the game to regulate the difficulty. Bitcoin tries to set the threshold number so that a block is created about once every 10 minutes.
As more miners join the network, finding a winning hash output becomes harder. Crypto mining is a zero-sum game: no matter how many miners try to mine for Bitcoin, there is only a certain, fixed block reward on offer each block. When a new miner joins, it stiffens the competition for everyone else.