Now, the nodes that form new blocks will try to add them to the main blockchain and make it a permanent part of it. But if every node had the ability to simply add a new block to the blockchain, it would disrupt it and might even be a big security threat. To avoid this, there is a concept of proof-of-work which ensures that a valid block is securely attached to the blockchain.
Proof-of-work is a block verification protocol also referred to as mining in technical terms as the ones who do proof-of-work successfully get a reward in the form of bitcoins. Hence, we call them “miners”. Proof-of-work is a process of solving a system-generated mathematical puzzle that creates a hash code for that block as a result. This unique block hash is what we need to add a new block successfully on the blockchain.
In proof-of-work, the system assigns a target value (hash value) to a node according to which it must come up with a hash for the new block. The server assigns the target value according to a Difficulty level. This difficulty level changes with the addition of every 2016 new blocks in a blockchain.
Also, the level of difficulty measure is set according to the nodes present in a blockchain network and their computing power.
The node has to calculate a hash value for the new block so that it is less than the target value. In other words, the calculated hash value should fulfill the condition set in the difficulty target and should be less than the target threshold.
To calculate the required hash value, a node needs the hash value of the previous block and nonce value. Nonce is an integer value which is short for “Number only used once”. It is a random integer number that you need to get the desired hash value for the block. The target value is formed by hashing the correct combination of the nonce and the previous block’s hash value.
We can keep changing the nonce value until we find the correct value for the hash. The main thing here is to find a combination of the nonce and previous block hash so that the preceding zeros in the block hash meet the target condition. When the correct nonce along with the hash value of the previous block is found, they are hashed using the SHA-256 hashing algorithm. This makes the final block hash of the new block.
A block is approved and added into the blockchain if the miners do proof-of-work correctly. In a typical scenario, a node can add a new block in average of 10 minutes times to the blockchain. Also, when a node carries out a successful proof-of-work, it is rewarded by bitcoins and sometimes even with transaction fees.
This concept is associated with Mining and so we call the nodes “Miners” as they mine for bitcoins by doing proof-of-work. This is the only way of generating bitcoins. In mining, miners compete with each other by trying to guess the correct nonce to make the correct block hash as fast as possible.
Leave a Reply