Mining – Why do we need it and how does it work?

Mining is one of the more mysterious aspects of Bitcoin and other cryptocurrencies. It is often described by vague statements such as “miners try to find new coins”, “miners solve puzzles for coin rewards”, “miners verify transactions”, etc… This is coupled with a sentiment among new  Bitcoin-users that mining is *the* way to obtain bitcoins and that obtaining coins through mining is somehow one of the main purposes of a cryptocurrency. In this post, I will delve into the details of the mining process, discuss its purpose and how it works.

Consensus in a decentralized network with untrustworthy agents

That’s quite a mouthful. Lets break it down into more comprehensible parts. As you probably know, Bitcoin is a decentralized system in the sense that there is no central authority that determines who has how many coins and which transactions are valid. Nevertheless, we do need some method to differentiate between valid and invalid transactions and ensure that people don’t cheat the system.

One important way to cheat the system is the so-called “doublespend”, which  means exactly what you think it  does: The offender tries to spend the same coins twice. To prevent this, the network needs to have some way to decide which of the two transactions it accepts. A naive approach is to simply accept the transaction that was broadcast first. However, this approach comes with its own issues, because even with the best of intentions, clocks on different computers are often not synced. Add in the possibility for an attacker to change timestamps and this simple timing-based decision method becomes invalid.

What we need is a system that uniquely determines which transactions are valid and is not reliant on a central authority, synchronized clocks and it should not be affected by the presence of some hostile agents, that try to cheat the system.

Enter the Blockchain

The solution to the problem described above was created by Bitcoin-inventor(s) Satoshi Nakamoto. The idea is to periodically collect new transactions and wrap them into a so-called block. Besides the transactions, each block contains some additional data, most importantly a reference to the previous block, which makes each block a link in a long chain of blocks, the blockchain.

All transactions included in a valid block are considered to be valid. However, this system doesn’t yet solve the problem, it merely moves it. Because who decides  what transactions make it into a block? And how do we ensure that a hostile agent doesn’t transmit his own version of the blockchain, containing his fraudulent transactions?

An elegant approach is to use a voting system. Different agents create and publish their blocks to the network and the network votes on which block is accepted as the next in the chain. This sounds good on the surface, but again raises questions: How do we register the votes? And more importantly: How do we prevent people from voting many times? After all, things like IP addresses are relatively easy to fake and if there is some authority that handles voter registration, then the decentralized nature of the network is lost.

Proof of work

The solution to the voting problem is to not associate votes with individual people or individual computers, but rather with computing power. In addition, instead of a regular voting system, which are deterministic and the majority always wins, we use a system where each vote offers a probability to completely decide the outcome.  Compare this with your national elections: One voter gets randomly picked and can decide which party wins the election.  This is not a very suitable method for elections, but it’s okay for cryptocurrencies.

So what happens in Bitcoin is that many people use their computer to collect transactions into a block and then try to solve a computationally difficult problem. Here both the problem and the solution are unique to the block, so someone trying to create a different block can’t use a solution that I computed.

Once a solution has been found, it is bundled with the block and broadcast to the network. Other nodes in the network now check that all transactions in the block are valid and that the solution is correct for the puzzle that is associated with that block.

Whoever finds the solution first is a matter of chance, but the probability of finding the solution first depends on the amount of available computer power. Since the problem is such that it can only be solved by brute force, the user with the more powerful computer has better odds.

How does this prevent cheating?

People accepting Bitcoin transactions can now choose to wait until a transaction has been included in a block before they consider it final. If someone wanted to change the contents of a block after it has been published to the network, they would have to redo the work to solve the associated puzzle since any change to the contents of a block changes the puzzle and its solution.

But in the meantime, the legitimate users of the network are working to create new blocks to be added to the chain. Therefore, any attacker has to race against the entire network to produce fraudulent blocks. In practice this means that as long as more than half the computing power in the network is controlled by people that don’t have bad intentions, then the network is secure.

So who are the miners then?

The miners are the people and/or computers that work to solve these problems and publish new blocks. If the term ‘miner’ doesn’t make much sense to you in this way, then that’s totally normal. Instead of a miner, it is more accurate to refer to these people as a combination between an accountant and a bank security guard.

So where does the term ‘miner’ come from? It is connected with the reward that the miner receives. Since computer power isn’t free, it is not sufficient to rely on altruistic motives.  As a reward for their efforts, the miner that manages to be the first to publish a new block, may include in this block a transaction that transfers coins to an address of his choosing. These coins have no origin and are considered to be newly created.

This reward, called the ‘block reward’, is the only source of new coins in Bitcoin (and most other cryptocurrencies). By design, this reward becomes smaller with time and in his original paper, Satoshi Nakamoto drew parallels with the mining of gold or other precious metals, where the veins are slowly depleted and gains diminish. This is where the term miner finds its origins.


The process of mining has very little to do with finding new coins. The coins are not hidden and don’t require people to find them. They are simply created out of nothing as a reward for creating and publishing a valid block of transactions.

This transaction-block gives transactions a sort of permanency, making it increasingly difficulty for attackers to undo past transactions. In addition, the publishing of a block serves as a ruling in the case of an attempted double spend of coins as only one transaction is included and the other is dropped.

The actual validation of transactions is not just done by the miners. Every node in the network, whether they’re mining or not, will only pass on transactions that it considers valid.

More on mining and how it works in followup articles.

Leave a Reply

Your email address will not be published. Required fields are marked *