Proof-of-Work (PoW)
Operates on the principle that it is expensive to add a block of new transactions to the blockchain. Used by: Bitcoin, Litecoin, Ethereum (2015-2022)
Basic principle
Proof-of-Work operates on the principle that it is expensive to add a block of new transactions to the blockchain. The cost of a block is the work that has to be done: calculation (better known as mining). A node has to calculate the correct hash (signature) for the block in order to secure the block and place it on the blockchain, in turn freeing another (new) block. A correct hash is a hash that fits the (pre-determined) difficulty pattern. In Bitcoin’s case this is a number of leading zeroes.
Hashing (Mining)
This hash has to be calculated using three known values inside the block: the previous block’s hash, the hashes of the transactions contained in the block (the Merkle root) and the block’s creation time. As all three of these values are fixed, hashing them will always produce the same (most likely incorrect) result. To be able to alter the hash outcome, a fourth (unknown) string is added: the so-called ‘nonce’. By continuously randomizing this nonce, the node can find the correct hash that fits the difficuly patern.
Once the right nonce is found, it is placed inside the block, and the calculated hash (signature) is added to the block’s header, securing it and its contents: the signature acts as a sort of lock, locking the block, preventing further changes of the transactions stored inside (as changing just one character inside the block would produce a completely different hash).
Reaching consensus
If the node is the first one to find the nonce, it broadcasts the complete block to all other nodes, who can then verify the work that was done (the nonce can thus be considered as the ‘proof of work’) by hashing the previous hash, transactions hash, creation time and the found nonce themselves. This should then produce the same correct hash (signature). If it does, the node considers the block valid, and adds it to its copy of the blockchain, discarding its own – or any other versions – of the block. If more than 50% of the nodes do this, a state of consensus is reached, and the block is definitely valid. In the course of time, the entire network will have added this block to its blockchain. The node that found the nonce will then receive an award (i.e.. Bitcoins). These rewards provide incentive.
To compensate for increasing hardware speed and varying interest in running nodes over time, the difficulty is determined by a moving average targeting an average number of blocks per hour. In Bitcoin’s case, this makes sure a new block becomes available roughly every 10 minutes. If blocks are generated too fast, the difficulty increases. If they are generated too slow, the difficulty decreases.
If Proof-of-Work consensus where to receive an energy label, it would rate F for very energy inefficient.