Skip to content

How Bitcoin Mining Works

davidotero edited this page Jan 1, 2026 · 1 revision

How Bitcoin Mining Works

A technical overview of Bitcoin mining for curious nerds.


The Basics

Bitcoin mining is the process of:

  1. Collecting transactions into a block
  2. Finding a special number (nonce) that makes the block's hash meet a difficulty target
  3. Broadcasting the valid block to the network
  4. Receiving the block reward (currently 3.125 BTC + fees)

The Block Header

Every Bitcoin block has an 80-byte header:

Field Size Description
Version 4 bytes Block version number
Previous Block Hash 32 bytes Hash of the previous block
Merkle Root 32 bytes Hash of all transactions in the block
Timestamp 4 bytes Unix timestamp
Difficulty Target 4 bytes Compact difficulty representation
Nonce 4 bytes The number miners iterate
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Block Header (80 bytes)                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Version  β”‚ Prev Block Hash β”‚  Merkle Root    β”‚Timestamp β”‚ Bits    β”‚ Nonce β”‚
β”‚ 4 bytes  β”‚    32 bytes     β”‚   32 bytes      β”‚ 4 bytes  β”‚ 4 bytes β”‚4 bytesβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜

The Mining Process

Step 1: Get Work

The miner receives a block template from the pool (or Bitcoin Core):

  • Previous block hash
  • Transactions to include
  • Coinbase transaction (where reward goes)
  • Current difficulty target

Step 2: Build Header

The miner constructs the 80-byte header with:

  • All fixed fields from the template
  • A starting nonce (usually 0)

Step 3: Hash and Check

1. Compute SHA256(SHA256(header)) = hash
2. Check if hash < target
3. If yes β†’ Found a block! Submit it.
4. If no β†’ Increment nonce, go to step 1

Step 4: Submit Valid Block

When a valid hash is found:

  1. Submit to pool or Bitcoin Core
  2. Block propagates to network
  3. Other nodes verify and accept
  4. Miner receives reward

SHA256d (Double SHA256)

Bitcoin uses double SHA256 for security:

hash = SHA256(SHA256(block_header))

Why Double?

  1. Prevents length extension attacks
  2. Defense in depth - if SHA256 is partially broken, double hashing helps
  3. Satoshi's design choice

Example

Block 125552 header:

0100000081cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000
e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122bc7f5d74d
f2b9441a42a14695

SHA256d hash:

00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d

Notice all the leading zeros - that's what makes it a valid block!


Difficulty

What is Difficulty?

Difficulty is a measure of how hard it is to find a valid block. It adjusts every 2016 blocks (~2 weeks) to maintain ~10 minute block times.

The Target

The target is a 256-bit number. A valid block hash must be less than the target.

Difficulty 1 target:

0x00000000FFFF0000000000000000000000000000000000000000000000000000

This has ~32 leading zero bits.

Current Difficulty

As of 2025:

  • Difficulty: ~148 trillion
  • Required leading zeros: ~67-68 bits
  • Target: astronomically small

Difficulty Adjustment

new_difficulty = old_difficulty * (2016 blocks actual time / 2 weeks)

If blocks were found too fast, difficulty increases. If blocks were found too slow, difficulty decreases.


The Nonce

The nonce is a 32-bit number (0 to 4,294,967,295) that miners iterate.

The Problem

At 350 MH/s, you exhaust all 4 billion nonces in ~12 seconds. But blocks take 10 minutes on average!

The Solution: Extranonce

Pools provide an extranonce field in the coinbase transaction. When you exhaust the nonce space:

  1. Increment extranonce
  2. Recalculate merkle root
  3. Start nonce from 0 again

This gives effectively unlimited search space.


Pool Mining vs Solo Mining

Pool Mining

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”     shares     β”Œβ”€β”€β”€β”€β”€β”€β”     block     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Miner  β”‚ ─────────────> β”‚ Pool β”‚ ────────────> β”‚ Network β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β””β”€β”€β”€β”€β”€β”€β”˜               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β”‚ proportional reward
                              β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚  Miner  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Submit shares (low-difficulty proofs of work)
  • Pool submits blocks to network
  • Reward split among all miners proportionally
  • Steady, predictable income

Solo Mining

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”              block                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Miner  β”‚ ─────────────────────────────────>β”‚ Network β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β”‚ full reward (if found)
                              β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚  Miner  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Submit directly to network (via pool or Bitcoin Core)
  • You keep the entire block reward
  • Extremely unlikely to find a block
  • Lottery-style mining

The Math of Solo Mining

At 350 MH/s vs Network (~700 EH/s):

Your hashrate:     350,000,000 H/s
Network hashrate:  700,000,000,000,000,000,000 H/s

Your share: 0.0000000000005%

Probability Per Day:

Hashes per day: 350 MH/s Γ— 86,400 seconds = 30.24 trillion
Probability: 30.24T / (network_difficulty Γ— 2^32) β‰ˆ 1 in 13 trillion

Expected Time to Find Block:

1 / (probability per day) β‰ˆ 37,000 years

Why Mine Solo?

Despite the odds:

  1. The Dream - One lucky hash = ~$300,000+
  2. No Pool Fees - Keep 100% of the reward
  3. Decentralization - Support the network
  4. Learning - Understand Bitcoin deeply
  5. Fun - It's a lottery ticket that does useful work

See Also

Clone this wiki locally