Live model · Bitcoin mining
How Bitcoin Mining Actually Works
Bitcoin miners are guessing. Each one hashes an 80-byte block header with SHA-256, twice, changing a number called the nonce each time, until the hash falls at or below a target: it starts with a long run of zero bits. Nobody can aim for that; the only way is to try. The winner adds the block and collects the reward.
Mining one block, nonce by nonce
How to read the stage
The table is the header: the previous block's hash, the merkle root of three transactions, the time, the target and the nonce. The cells are the first 12 hex digits of the hash, each over its 4 bits. This target needs 12 zero bits, 1 hash in 4,096. The best hash climbs from 4 zero bits to 11, and nonce 3,955 wins on try 3,956. The bars count every try by its zero bits.
Why zeros mean work
SHA-256 has no shortcut: change the nonce by one and the whole hash scrambles, so every try is a fresh lottery ticket. Each zero bit the target asks for halves the odds and doubles the average work, while checking a winner takes one hash. Bitcoin moves the target every 2,016 blocks to keep blocks about 10 minutes apart. At the difficulty of October 21, 2026, a hash needed about 79 zero bits, not 12.
Block 0, hashed for real
The same code hashes Bitcoin's first block, mined on January 3, 2009, from the six fields in Bitcoin Core's source. Out comes the hash Bitcoin Core checks block 0 against, 000000000019d668… ending 8ce26f: 43 zero bits, where its target asked for at least 32. Move the nonce by one and the hash lands nowhere near.
Bitcoin's block 0, hashed from its fields
Why nobody can edit an old block
Each header holds the previous block's hash, and its merkle root commits to every transaction. Turn block 2's 3 BTC into 30 and its hash changes, misses the target, and block 3's link to it breaks. The forger has to re-mine block 2 and every block after it, 437 more tries here, while honest miners keep extending the real chain. As the whitepaper puts it, the forger must catch up with and surpass them.
Forging a payment in block 2
- CH1 forged payment
What the model leaves out
Real transactions are signed inputs and outputs, not lines of text; the model hashes text through the same merkle tree. The target here is 1 in 4,096 so a re-run takes milliseconds, and the model stops at 20,000 tries, where a miner runs through all 4.29 billion nonces and then changes the time or the coinbase. Real nodes also check far more than the hash.
Questions
- What are Bitcoin miners actually computing?
- SHA-256 of SHA-256 of an 80-byte block header, over and over, with a different nonce each time, looking for a hash at or below the target the header's nBits field encodes. Nothing else is calculated: the winning hash is the proof that the work was done.
- How long does it take to mine a block?
- About 10 minutes on average, for the whole network together. Every 2,016 blocks, Bitcoin compares how long they took with two weeks and adjusts the target, so blocks stay near 10 minutes as miners join and leave.
- What do miners get for a block?
- The block subsidy, 3.125 BTC since the halving at block 840,000 in April 2024, plus the fees of the transactions they include. The subsidy halves every 210,000 blocks; the next halving comes at block 1,050,000.
- Why do Bitcoin block hashes start with zeros?
- A valid hash must be at or below the target, and a small number written as 64 hex digits starts with zeros. The hash is also shown with its bytes reversed, so the zeros SHA-256 left at the end of the digest appear at the front.
- What is the nonce?
- A 4-byte number in the header that the miner is free to change. It holds about 4.29 billion values. Once they're all tried, Bitcoin's developer reference says the time can be updated or the coinbase transaction changed, which changes the merkle root, and the nonces start again.