Bitcoin mining is completely legal, but be careful because authorities in many countries are still not familiar with the technology.
How does mining work?
People are sending Bitcoin over the network all the time, but unless someone records all these transactions, nobody would be able to keep track of who made which payment. The Bitcoin network resolved this by collecting all of the transactions made during a certain period into a list, called a block. It’s the miners’ job to verify those transactions, and write them into a general ledger called Blockchain.
What is hashing?
Whenever a new block of transactions is made, it is added to the Blockchain, increasing the lengthy list of all the transactions that ever happened on the network.
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? This is where the cryptocurrency miners come in.
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 old hash and 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. The first one to succeed is rewarded. That’s how miners earn their rewards.