Mining on blockchain networks
On the Bitcoin network, miners need to not just generate the hash for the data about the transactions that they want to include in a block of the blockchain, but they need to find a hash that corresponds to the difficulty parameter.
As stated earlier, a set of data can only have one hash, which is why miners add a number to the data about transactions. Then, they generate a hash for the set of data about transactions and the number added to it. This number is also known as nonce, which is an abbreviation for “number used once.” A nonce is a number that miners pick randomly and it does not have any other meaning or goal than to guess a hash.
If the combination of transaction data and nonce results in a winning hash, the miner seals the block with the hash and the nonce also becomes a part of the block. You can see nonces for the blocks of the Bitcoin blockchain on the pages of individual blocks in the tables that summarize the basic information about the block. For example, the nonce for the block #527175 is 1581548992 and the winning hash has been 00000000000000000037422fb6fe5187019cbcac1d753868c35f914415f5ab65. With the Bitcoin blockchain, difficulty translates into the requirement of hashes starting with a certain number of zeros.
Coming up with a hash for a set of data is easy. Coming up with a hash that starts with over ten zeros is not. This is the reason why hardware manufacturers have created special hardware called ASIC (the word “ASIC” is an abbreviation for “application-specific integrated circuit”). ASIC cards are similar to sports cars in that they are expensive and there is just one thing that they do really good. Sport cars have a lot of power and the thing that they do really good is drive fast, typically at the expense of interior space and space for luggage. While today even Porsche has created an SUV, a small coupe with the same engine will still go faster. Similarly to that, the job of an ASIC card is to generate hashes as quickly as possible in order to try and come up with a winning hash.
In essence, this means that miners on the Bitcoin network are playing a lottery. In the lottery, people try to guess a combination of numbers and possibly a Power Ball. If they win, they get the payout amount. On the Bitcoin network, miners buy expensive hardware that guesses hashes and if they win, they get to create a block of the Bitcoin blockchain and get a reward from the Bitcoin network for doing so.
The difference between what the miners are doing and playing a lottery is that chances of winning when mining Bitcoin are much higher compared to a regular lottery.
For example, the chance of winning in Power Ball is about one in three hundred million, which is less than the chance of a lighting striking a person during the lifetime or dying from asteroid strike. Most people look at the numbers available in the lottery and think that chances of getting 6 out of seventy are roughly equal to seventy divided by six. What they do not realize is that mathematically speaking, winning in a lottery requires picking correctly a subset of m numbers from the set of n numbers and the number of subset combinations includes multiplication, not just division. This is where one in three hundred million comes from.
With mining, chances are similar to a few thousand people playing a lottery with a few thousand numbers on a regular basis. If you keep playing, you will win. This is why there are all types of calculators available online that show how long it would take for a mining rig to be profitable and how much profit it will bring depending on the cost of electricity.