Protocol: Blocks, Mining, Consensus
How transactions enter blocks, what difficulty and nonce mean in mining, how the P2P network agrees — and what a confirmation is really worth.
Chapter 1 explained the building blocks (hashes, signatures, difficulty). This chapter assembles them: How does a block come to be, how does it become immutable, and how does a network of strangers agree on exactly one chain without a boss? Plus: what the number of confirmations says about the security of a payment.
The block and the Merkle tree
A block has a header (80 bytes) and a body (the transactions). The header contains the hash of the previous block — which makes the chain immutable: anyone altering an old block would have to recompute all following ones. The header also holds the Merkle root (a hash tree over all transactions), the timestamp, the difficulty, and the nonce.
The Merkle tree combines transaction hashes in pairs until a single root hash remains. This means the root in the header is enough to prove that a specific transaction is in the block (Merkle proof, logarithmic in count). Light wallets use exactly this: they load only the root and a short path, not the whole block.
The header in detail
| Field | Size | Purpose |
|---|---|---|
| Version | 4 bytes | rule version of the block |
| Previous block hash | 32 bytes | links the predecessor — makes the chain immutable |
| Merkle root | 32 bytes | hash over all transactions in the block |
| Timestamp | 4 bytes | the miner's timestamp |
| Difficulty (bits) | 4 bytes | compact encoding of the target |
| Nonce | 4 bytes | counter for proof-of-work |
Mining: nonce, difficulty, halving
Mining increments the nonce in the header until the block hash is smaller than a target value (target). The target is smaller — hence harder to hit — the higher the difficulty. It is adjusted every 2016 blocks so that a block is created on average every 10 minutes, regardless of how much computing power is in the network. What a nonce is and why 2³² values are not enough is explained in the article What Is a Nonce?.
The coinbase payout — block reward plus fees — is the incentive for miners. The reward starts at 50 BTC and halves every 210,000 blocks (roughly every four years): 50 → 25 → 12.5 → 6.25 → 3.125 BTC. That is why the total supply is capped at 21 million BTC. Long term, fees are meant to replace the reward (the fee market).
Worked difficulty example: Difficulty says how hard the current target is to hit (difficulty = genesis target / current target). If the hashrate rises within an adjustment period, the expected block time drops; at the end of the period the difficulty is raised so that ~10 minutes per block result again. One period is 2016 blocks × 10 minutes = 14 days.
Consensus: who determines the chain
Bitcoin uses Nakamoto consensus: the longest (more precisely, the one with the most cumulative work) valid chain wins. There is no vote — the choice is the computing power that flows into a chain. Valid means: all consensus rules are met (signatures, spends, block limits). Miners with the most resources produce the next blocks, but they cannot break a rule that full nodes check.
Two consequences follow:
- Forks: if enough nodes and miners change the same rule, it is called a hard fork (not backward-compatible, e.g. Bitcoin Cash 2017) or a soft fork (backward-compatible, e.g. SegWit 2017, Taproot 2021).
- Full nodes = rule keepers: a node validates everything but follows irrefutably valid blocks. If you want to verify the rules, you need a full node — it is the only instance that separates "decentralized" from "majority".
P2P network and mempool
Without a central party, gossip protocols distribute blocks and new transactions between nodes. Every node keeps a mempool: the set of not-yet-confirmed transactions. Miners select from it by fee per byte (fee auction). A full mempool drives fees up; an empty one makes transactions nearly free. Details on change and UTXO selection are in the article UTXO vs. Account Model.
What a confirmation is worth
One confirmation means: your transaction is in a block. Six confirmations (~60 minutes) are the rule of thumb — the probability that an attacker with under 51% hashrate rewrites such a deep chain is then negligible. The rule of thumb is not a law of nature: it depends on the amount, the hashrate distribution and your risk profile. For small amounts one confirmation is often enough; for very large ones, several dozen. You can verify transactions yourself with the Transaction Decoder (shows inputs, outputs, fee, confirmations).
Sources
- Nakamoto (2008): Bitcoin whitepaper (sections 4, 5, 8) — bitcoin.org/bitcoin.pdf
- Bitcoin Developer Guide: Block Chain, Mining, P2P — developer.bitcoin.org/devguide
- Articles: What Is a Nonce?, UTXO vs. Account Model
- Tool: Transaction Decoder
Previous chapter: Chapter 1: Basics · Next chapter: Chapter 3: Wallets · Overview: Bitcoin & Web3 Knowledge Atlas. More numbers and formats: cheat sheet.