What Bitcoin Mining Entails: a Beginners Guide to Understanding Cryptocurrency
Bitcoin mining is just like gold mining. The only difference is that bitcoin mining occurs in the internet while gold mining occurs in physical mines and quarries. The similarity is that both are energy intensive and costly. For gold you have dig into the ground till you reach the ore containing the rare mineral; the ore has to be blasted and taken to the factory where it will be processed into refined gold.
That requires a lot of energy and money. bitcoins are also mined by bitcoin miners from a valid bitcoin block on the internet. Just like in the gold mining where you have to locate the ore containing the mineral, the process of mining a bitcoin goes beyond mining the bitcoin block.
The bitcoin block mining is often termed as lottery because this process of winning new coins happens based guesses which the miners make. If your guess is wrong then you miss the bitcoins. However, they are not simple random guesses as it happens in gambling and in the lottery. Instead, they are highly informed and constrained guesses which require a lot of energy. For each guess to be even tested, a certain amount of energy needs to be spent, in which most guesses usually fail, wasting a lot of energy from the miner’s pocket.
In spite of all that, every 10 minutes a miner in the world succeeds in guessing it right after a lot of energy spending and is thus allowed to add the block onto the blockchain and receives the lottery amount which is the block reward.
Just like a gambler has to lose many times before getting a huge win, the miner who makes the correct guess for the valid block must have made innumerable attempts before reaching the guess, in turn burning lots of energy. This is proof of work and as a reward for burning their energy, miners get the valid block in the form of bitcoins which they can later sell or HODL at the current market price.
Currently, the reward for finding a valid block on bitcoins network is 12.5 newly created bitcoins. Back in 2009, at the start of the bitcoin network, the block reward was 50 BTC. This reward halves every 4 years to maintain inflation and reach the total supply of 21 million sometime in 2120.
Well, that is a non-technical way of understanding bitcoin mining. Let us now understand it at a technical level.
Bitcoin uses the SHA-256, a mathematical function that takes an input of any size and produces a fixed length output every time. the generated output is referred to as bitcoin hash.
Merkel tree is a tree of hashes and the last hash of that tree is called the Merkel root or root hash. This is a concept of computer science and cryptography on which bitcoin mining is based.
Target and difficulty of bitcoin network are similar things. A target is a 256-bit number (extremely large), obtained by hashing the previous block’s header in a certain way that all bitcoin clients share, while difficulty is a measure of how difficult it is to find a hash below or equal to a given target and is measured in hash rate.
Bitcoin nonce is a particular 32-bit field in the input of SHA-256 hash function whose value needs to set in a way that hashed output contains a specific number of leading zeros which should be similar or less than the target. And this is the field with which miners play to get the required output.
Do not worry if you haven’t understood the vocabulary I have explained above. I will make everything connect till you understand how mining takes place. First I want you to recall my earlier explanation that bitcoin mining is like the lottery , the miners make guesses the valid block while spending a lot of energy.
Let us now see how the miner wins this valid block.
To successfully mine a block, a miner needs to hash the block’s header in a way that is less than or equal to the target. This block header is created by hashing all the transactions in a block, thereby forming a Merkel tree with a Merkel root.
Moreover, this root is combined with a hash of the latest block and a nonce. Now, this raw data of Merkel root+ Previous Hash +Nonce+ Timestamp is put into an SHA-256 function to produce a certain type of hash output which is as per the target.
The target is that the SHA-256 hash of a block’s header must be a 256-bit alphanumeric string and must start with 17 zeros. A while back, the target was to obtain a block hash with 8 zeros. The target changes in tandem with change in difficulty every 2016 blocks.
The miners then arrive at this target by varying a small portion of the block’s headers, which is called a nonce. A nonce always starts with the number zero and is incremented every time for obtaining the required target.
Since the varying of the nonce is hit and miss, the chance of getting this target, which starts with many zeros, is very low. Therefore, many attempts must be made by the miner by varying the nonce and continuous varying of the nonce in an incremental way is called mathematically guessing the proof.
You should know that this requires a huge amount of computational power and hardware resources which proves that a large amount of work of work is carried out before mining any individual block. That is why this is called Proof of work.
And in this way, the miner who obtains the correct bitcoin Hash as per the target first gets the lottery and gets the lottery and gets the block reward of 12.5 BTC. The block and the transactions present in that block get added and updated on the universal ledger of bitcoin called the bitcoin’s blockchain.
Bitcoin mining keeps on getting difficult as more miners join in to maintain the balanced generation of new coins. Over the years, miners with special GPUs and ASIC miners have joined the bitcoin network, thereby raising the difficulty bar so high that it is no longer profitable even possible to use central processing units to mine.