How does mining work?
Bitcoins are getting transacted over the network all the time. The Bitcoin network reconciles the transactions into a block and publishes them on the public ledger every ten minutes. This is where the miners come in. They provide computational input that assists in verifying transactions.
What is hashing?
Every ten minutes, a new block of transaction gets added into the Blockchain, and it will be so for a long time. But a Blockchain has to be trusted, and all this data is held digitally. How can we be certain that the Blockchain wasn’t tampered with?
When a block of transactions is made, miners take the information in the block, and apply a public mathematical formula to it, turning it into a set of short letters and numbers. That far shorter, seemingly random sequence of letters and figures is known as a hash. The hash is stored together with the block, at the end of the Blockchain at that point in time.
Miners don’t only utilize the transactions in a block to create a hash. Some other pieces of information are used too. One of those pieces is the hash of the last block saved in the Blockchain.
Because the hash of each block is produced with the hash of the block saved before it, it becomes a digital type of a wax seal. It confirms that that block – and every block after it – is legitimate because if anyone tampered with it, everyone in the network would know.
Competing for rewards
Miners compete with each other using software written especially for block mining. Every time someone successfully creates a hash, they receive a reward of 12.5 bitcoins, the Blockchain is updated, and everyone on the network is informed about it. That’s the incentive to keep the mining going and keep the transactions working.
The catch is that it’s too easy to produce a hash from a pile of data. Computers are great at this. The network has to make it harder to achieve; otherwise, everyone would be hashing hundreds of transaction blocks every second, and all of the Bitcoins would be mined in a couple of minutes. The Bitcoin protocol deliberately makes it harder, by introducing so-called ‘proof of work.’
The protocol is designed not to accept any old hash. It demands certain things from a block’s hash. There’s no way of knowing what a hash is going to look like before you create it, and as soon as you add a new piece of data in the mix, the hash becomes entirely different.
It can take a significant number of attempts to create a block’s hash that works and all the miners in the Bitcoin network are trying to do this at the same time. First, one to succeed is rewarded. That’s how miners earn their rewards.