Anatomy of a Candidate Block
Think of a candidate block as having two main parts:
- Block Header (summary of the block)
- Block Body (list of transactions)
What's Inside the Block Header?
The block header includes several key pieces of data:
- Timestamp – Marks when the block was created.
- Previous Block Hash – A unique identifier (hash) of the last block in the blockchain.
- Transaction Summary Hash – A hash (called the Merkle Root) that acts as a digital fingerprint for all transactions in the block.
Generating the Block Hash
To add a block to the blockchain, the miner takes the block header and runs it through a hash function. This produces a unique output called the block hash.
The block hash must begin with a certain number of zeros—a requirement known as the mining difficulty.
Enter the Nonce
Since the block header is mostly fixed, miners use a special field called the nonce to modify the input and try again. Each time adjusted, the hash output changes. The goal is finding a nonce producing a block hash starting with the required zeros.
Mining Is Just Guesswork
Mining doesn't involve solving complex problems—it's trial and error. This process is known as Proof-of-Work (PoW).
Winning the Race
The first miner to find a valid block hash gets to add the block to the blockchain, broadcasts it, and receives a block reward including newly created bitcoins and transaction fees.
Why the Blockchain Is So Secure
Every block contains the hash of the preceding block. Altering an old transaction requires redoing Proof-of-Work for that block and all subsequent blocks—requiring enormous computing power.
Difficulty Adjustment
Bitcoin's software automatically adjusts mining difficulty every ~2 weeks to maintain approximately one block mined every 10 minutes.
Summary: How Mining Works
- Miners collect transactions into a candidate block.
- They hash the block header using a random nonce.
- If the hash lacks sufficient zeros, they try a new nonce.
- When a valid hash is found, the block is added to the blockchain.
- That miner earns bitcoin as reward.
- The network resets for the next block.
