How does bitcoin mining actually work?

TL;DR

Bitcoin miners gather transactions into candidate blocks and compete for the right to add the next block to the blockchain. They do this by repeatedly hashing block data, changing part of that data each time, until they find a hash that meets the network’s current difficulty target. The first miner to find a valid result can broadcast its candidate block to the network. Nodes independently verify the block and accept it only if it follows Bitcoin’s rules.

If the block is valid, the miner can claim the block reward: newly issued bitcoin plus the transaction fees included in that block.

In short:

Build → Hash → Try Again → Find → Broadcast → Verify → Reward


First, what is a miner?

A Bitcoin miner is a specialized computer participating in the process of producing new blocks. Miners collect valid, unconfirmed transactions and assemble them into a candidate block. Their job is then to find a valid proof of work for that block. That’s the part we call mining.

What is proof of work?

Before a miner can propose its block to the network, it has to perform an enormous amount of computational work. The miner takes information from its candidate block and runs it through Bitcoin’s hash function.

A hash function takes data and produces a fixed length output that looks something like this:

00000000000000000001a3f…

Change even a tiny piece of the input, and the resulting hash changes completely.

The miner is looking for a hash that falls below a specific target set by the Bitcoin network. There’s no shortcut for finding one. So the miner tries over and over again until it finds it.

are miners solving complicated math problems?

Not exactly. You’ll often hear Bitcoin mining described as computers “solving complex mathematical equations.” That makes it sound like miners are working through a difficult equation until they figure out the answer. What they’re really doing is closer to guessing.

The miner hashes its block data and gets a result. Not low enough? It changes some data and hashes it again. Still not low enough? It tries again. This happens incredibly quickly, over and over, until somebody finds a hash that satisfies the target.

What happens when a miner finds a valid hash?

The miner now has a candidate block with valid proof of work. It broadcasts that block to the Bitcoin network, but the block isn’t valid until nodes check it.

Nodes verify things like whether the transactions follow Bitcoin’s rules, whether the block follows the consensus rules, and whether the proof of work is valid. If the block breaks the rules, nodes reject it. If it passes, nodes can accept the block and update their copy of the blockchain.

Miners propose blocks. Nodes verify them.

Why do miners do all this work?

A miner that successfully produces a valid block can include a special transaction that pays itself the block reward.

That reward has two parts:

  1. The block subsidy
    -New bitcoin issued according to Bitcoin’s predetermined supply schedule.

  2. Transaction fees
    -The fees attached to the transactions included in the block.

The block subsidy decreases over time through an event called the halving, which happens every 210,000 blocks. Eventually, new bitcoin issuance will become extremely small and ultimately end. Transaction fees will remain as the incentive for miners to continue producing blocks.

Why does Bitcoin make mining so difficult?

Bitcoin needs a way to decide which block gets added next without putting a person, company, or central authority in charge of making that decision. Proof of work provides that mechanism by making it difficult to produce a valid block. Miners have to commit real computing power and energy as they search for a hash that meets Bitcoin’s target. Finding one requires a tremendous amount of work, but once a miner succeeds, the rest of the network can quickly verify that the work was done.

The difficulty of that search isn’t fixed. As more computing power joins or leaves the network, Bitcoin periodically adjusts the target to compensate. More computing power makes the search for a hash harder, while less computing power makes it easier. This adjustment helps keep new blocks arriving at an average rate of roughly one every ten minutes, even as the amount of mining power on the network changes over time.

In other words, Bitcoin makes producing the next block intentionally difficult, while keeping that block relatively easy for everyone else to verify.

What does mining actually accomplish?

Mining issues more bitcoin, but not indefinitely. There is a fixed supply cap of 21 million bitcoin. So eventually, there won’t be any new bitcoin entering the system. Mining will remain critically important to Bitcoin though, as it provides the mechanism Bitcoin uses to produce new blocks and order transactions over time.

Bitcoin Mining, in plain English

Bitcoin mining isn’t a computer slowly solving one incredibly difficult equation. It’s millions of specialized machines making enormous numbers of guesses. Each miner is trying to find a valid proof of work for its candidate block before somebody else does. Eventually, one succeeds, and the block is broadcasted. Nodes verify it, and if it follows the rules, the block becomes part of Bitcoin’s blockchain. This process repeats with a new block of transactions, and about ten minutes later, on average, another block joins the chain.


Learn Bitcoin. Find your people.

Bitcoin Party KC brings together Bitcoiners and the Bitcoin curious across Kansas City through local events, education, and a growing community. Members receive The Sovereign Review, exclusive event access, discounts, and more.

Become a member →

Next
Next

What is the Mempool?