Proof of work mining
Bitcoin proof of work mining in steps: hash a block header until it falls below the target, broadcast the block, then claim the reward.
By Dimitar Zurnov · Updated 4 Nov 2026
Adapted from Learn Me a Bitcoin by Greg Walker.
Bitcoin mining is proof of work. Miners add new blocks to the blockchain by hashing a block header again and again, changing one number each time, until the hash is low enough. A miner fills the block with pending transactions first. The first miner to get there broadcasts the block. Every node checks the work and adds the block, and the chain grows by one. The winner also claims the block reward.
This page follows that process step by step. The word pages explain the people and the terms: miner, mining pool and hashrate. Here we look at the work itself.
What does a miner do, step by step?
- The miner picks transactions from its memory pool and puts them in a candidate block.
- It writes a coinbase transaction as the first transaction, to claim the block reward.
- It builds the block header, an 80-byte summary of the block.
- It hashes the header with HASH256 and compares the result with the target.
- If the hash is too high, it changes the nonce and tries again.
- If the hash is low enough, it broadcasts the block. Every node checks the work and adds the block to its own chain, then starts on the next one.
What is in the block header?
The header is the only part of the block that gets hashed in the mining loop. It is always 80 bytes, made of six fields. Changing any one of them changes the hash.
The previous block hash says which block this one builds on. The merkle root is a single hash that commits to every transaction in the block, so no transaction can change without changing the header. The time is set by the miner, and the bits field stores the target in compact form. The nonce is the number the miner keeps changing.
How does the hashing loop work?
Mining uses HASH256, which is SHA-256 applied twice: SHA-256(SHA-256(header)). The output is a 256-bit number. Because a hash cannot be predicted, every new nonce gives a completely different result. The miner has no shortcut and must try nonces until one works.
The nonce is 4 bytes, so one header offers 2^32 (about 4.3 billion) tries. When a miner runs out, it changes another part of the block, such as the extra nonce in the coinbase transaction, which changes the merkle root and so the header.
Here is block 100,000 as an example. Its header with nonce 0 hashes to a value far above the target. The header with nonce 274,148,111 hashes to a value below it:
Nonce 0: 5bd0d617b30a972407ad69a845cd74fb201d940cd45acc15fcd4761493bc3ae2
Nonce 274,148,111: 000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506
Target: 000000000004864c000000000000000000000000000000000000000000000000
Two details matter here. The nonce is stored in little-endian byte order, so 274,148,111 appears in the header as 0f2b5710. And a raw HASH256 result looks backwards, because explorers show block hashes with their bytes reversed. The value above is the explorer form, which is why its zeros sit at the front. Check the block itself on our explorer: block 100,000.
At this difficulty, only about one hash in 62 trillion beats the target. The loop below is the whole mining algorithm for one header:
import hashlib, struct
def hash256(data: bytes) -> bytes:
return hashlib.sha256(hashlib.sha256(data).digest()).digest()
def mine(header76: bytes, target: int) -> int:
"""Return the first nonce whose block hash is at or below the target."""
nonce = 0
while True:
header = header76 + struct.pack("<I", nonce) # the nonce is 4 bytes, little-endian
block_hash = hash256(header)[::-1] # display order, as explorers show it
if int.from_bytes(block_hash, "big") <= target:
return nonce
nonce += 1
Running mine on block 100,000 finds nonce 274,148,111, but it takes minutes in Python, because it tries 274 million nonces on the way. Real miners use optimized hardware that tries billions of nonces per second.
Why is it called proof of work?
The mining process is called proof of work because the hash shows that effort was spent. Finding a low hash takes a great deal of computation, but anyone can check the result with a single HASH256. The hash is the proof, and the work behind it cannot be faked. The Bitcoin white paper describes this idea: a block is hard to produce but easy to verify.
Who can mine, and who has the edge?
Any node can try to mine a block. Each hash is a ticket in a lottery, and a miner's chance of winning a block grows with the hashing power it adds. So anyone can mine, but the edge goes to whoever hashes fastest. Specialized mining hardware and cheap electricity give a large advantage. Many miners therefore join a mining pool, which shares the reward among its members.
How do nodes agree on one chain?
Miners work at the same time, so two blocks can be found at almost the same moment. A node accepts the chain with the most accumulated work, which is the longest chain. When a competing branch overtakes it, the node switches, in a chain reorganization.
Mining also settles conflicts between transactions. If two transactions spend the same coins, only the one in the block that wins the race is confirmed. The other one is dropped. A single party that controls most of the mining power could rewrite recent blocks, which is the 51% attack.
How often is a block mined?
The target is adjusted every 2016 blocks, which is about two weeks. The aim is one block every 10 minutes on average. If blocks have come faster, the target falls and mining gets harder. If they have come slower, the target rises. Every node runs the same calculation, so every node arrives at the same target. The details are on the target page.
How are miners paid?
A miner earns the block reward. It has two parts: the new coins created by the block subsidy, and the fees paid by the transactions in the block. The miner claims both in the coinbase transaction. The subsidy halves about every four years, at the halving, so over time fees make up a larger share of the reward.
How can you follow mining on our explorer?
Our node reads every block directly, so you can check mining against the chain itself. The mining page shows live pools and hashrate, and the mining calculator estimates what a given amount of hashing power might earn. The difficulty and hashrate word pages explain the two numbers that drive those estimates.
Bitcoin Core exposes the mining interface through two RPCs. getblocktemplate returns the transactions and header fields for a new candidate block, following BIP 22. submitblock sends a solved block into the network.
Which order should you read this section in?
Read the pages in this order. Each one builds on the ones before it.
- Mempool: where transactions wait, and the limits every node sets on them.
- Candidate block: the set of transactions a miner is trying to add next.
- Coinbase transaction: the first transaction in every block, and how it claims the reward.
- Block reward: the subsidy schedule, the fees, and the halvings.
- Target: the threshold a hash must beat, and how it is adjusted.
In this section
- 1The bitcoin mempoolHow a node runs its bitcoin mempool: the 300 MB default size, the 14-day expiry, the minimum relay fee, eviction and the cluster limits.
- 2Candidate blockIn bitcoin, a candidate block is the next block a miner tries to mine. Learn how it is built, which rules it must follow, and how it reaches the chain.
- 3Coinbase transactionA bitcoin coinbase transaction is the first transaction in every block. It claims the block reward, carries the block height, and commits to SegWit data.
- 4Block rewardThe bitcoin block reward is the subsidy plus fees a miner claims. The subsidy has been 3.125 BTC since block 840,000 and halves every 210,000 blocks.
- 5TargetThe bitcoin difficulty target is the number a block hash must fall below. It is stored as bits, recalculated every 2016 blocks, and capped at fourfold change.
Something look wrong? Tell us