IFCCI

Bitcoin Mining

How Bitcoin Mining Works

2 min readLesson 12 of 12
100%

Learning Objectives

  1. 1Understand the anatomy of a candidate block including the block header and block body
  2. 2Explain how the nonce is used in the mining process to find a valid block hash
  3. 3Describe Proof-of-Work (PoW) as a trial-and-error process rather than complex problem solving
  4. 4Understand how mining difficulty adjusts automatically to maintain a 10-minute block interval

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:

  1. Timestamp – Marks when the block was created.
  2. Previous Block Hash – A unique identifier (hash) of the last block in the blockchain.
  3. 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.

Key Takeaways

  1. 1A candidate block consists of a block header (timestamp, previous block hash, Merkle Root) and a block body (list of transactions)
  2. 2Miners repeatedly hash the block header with different nonce values, searching for a block hash that starts with the required number of zeros (mining difficulty)
  3. 3Mining is essentially trial and error (Proof-of-Work), and the first miner to find a valid hash wins the right to add the block and earn the block reward
  4. 4The blockchain is extremely secure because altering any past transaction would require redoing Proof-of-Work for that block and every block after it
  5. 5Bitcoin automatically adjusts mining difficulty every approximately two weeks to maintain a target of one new block every 10 minutes

Knowledge Check

1. What is the 'nonce' in the Bitcoin mining process?