How Bitcoin Mining Works: From Verified Transactions to a New Block
Disclaimer: This article is for informational and educational purposes only and simplifies underlying technical concepts for clarity. It is not financial, investment, or security advice.
Imagine a Bitcoin transaction has been broadcast to the Bitcoin network. Before it can be included in the blockchain, Bitcoin nodes verify that:
- The digital signature is valid.
- The sender is authorized to spend the Bitcoin.
- The amount has not already been spent.
- The transaction follows Bitcoin's rules.
Once the transaction passes these checks, it is considered valid. But being valid does not mean it has already been permanently recorded on the blockchain.
The transaction typically enters each node's mempool: a waiting area where valid, unconfirmed transactions remain until they are included in a block.
Which raises the question this article answers: who gets to add these transactions to the blockchain? That's where Bitcoin miners come in.
In This Article, You'll Learn
- ✓ How miners pick transactions from the mempool and build a candidate block
- ✓ What's inside a block header, and why each field matters
- ✓ How the target, the nonce, and hashing combine into Proof of Work
- ✓ How nodes verify a new block, and what happens when two miners find one at once
- ✓ What miners earn, and why Bitcoin needs mining at all
1. Miners Select Transactions from the Mempool
A miner runs specialized Bitcoin mining hardware. It receives valid transactions from the network and selects a group of them.
Miners usually give priority to transactions that pay the highest fee rate, meaning the fee paid per unit of block space. A block has limited space, and the fees become part of the miner's reward, so transactions paying higher fees tend to be included sooner.
In addition to the transactions it selects, the miner places one special transaction at the very beginning of the block: the coinbase transaction. This transaction pays the block reward to the miner.
Conceptually, the journey so far looks like this:
But the miner is not simply choosing transactions and declaring, "This is the next block." Bitcoin needs a mechanism that allows thousands of independent participants to agree on which miner gets to add the next block. That mechanism is Proof of Work. Before we get to Proof of Work, though, you need to understand exactly what the miner is working with.
2. The Miner Creates a Candidate Block
A simplified Bitcoin block can be divided into two major components: the block header and the transactions.
The transactions contain the actual Bitcoin transfers that the miner has selected to include in the block. The block header, on the other hand, contains information that identifies the block, connects it to the previous block, summarizes its transactions, and provides the data used in the Proof of Work process.
This distinction matters because the miner is not trying to solve a puzzle for each individual transaction. The mining competition happens around the block header. The miner repeatedly hashes the header while changing a value called the nonce, searching for a hash that satisfies Bitcoin's current Proof of Work requirement. The hash function Bitcoin uses for this is SHA-256, applied twice (often called double SHA-256).
The real Bitcoin block header contains six fields. The sixth, called Version, indicates which set of block rules the block follows. It is not needed to understand mining, so it is left out of this simplified view. The other five fields are the ones that matter here:
| Field | What It Does |
|---|---|
| Previous Block Hash | Links this block to the block before it |
| Merkle Root | A single fingerprint of every transaction in the block |
| Timestamp | Approximately when the miner created the block |
| Difficulty Target | The threshold the block hash must fall below |
| Nonce | The number the miner keeps changing to get new hashes |
Let's look at each one.
3. Previous Block Hash: Connecting the Blocks
Every block contains the hash of the block that came immediately before it. Imagine the blockchain contains Blocks 100, 101, and 102. Inside Block 102 is the hash of Block 101:
This tells the network that Block 102 is building on top of Block 101. It is what creates the chain in blockchain.
📌 What Is a Hash?
A hash is a fixed-length string of characters produced by running data through a cryptographic hash function. It acts like a digital fingerprint of that data. A cryptographic hash has two important properties:
Even if you know the hashing algorithm and have the hash, you generally cannot simply reverse the process and retrieve the original data. You would have to search through possible inputs and calculate their hashes to find a matching one, which is designed to be computationally infeasible for secure cryptographic hash functions.
This is why a hash acts as a digital fingerprint rather than a way of storing or encrypting the original data. In Bitcoin, hashes are used extensively to connect blocks, represent transactions, and support Proof of Work.
This linking has an important consequence. Suppose someone changes even one transaction inside Block 101:
The altered transaction changes the transaction's hash. This in turn changes the Merkle Root (explained in the next section), which changes Block 101's header and therefore produces a completely different hash for Block 101. But Block 102 still contains the old hash of Block 101, so Block 102 no longer correctly points to it. The change would also affect every subsequent block that depends on it.
This is one of the reasons altering historical blockchain data becomes increasingly difficult as more blocks are added.
4. The Merkle Root: A Fingerprint of the Transactions
The second important field is the Merkle Root. Suppose a miner has selected four transactions: A, B, C, and D. Bitcoin doesn't place all of those transaction details directly into the block header. Instead, the transactions are hashed and organized into a Merkle tree.
First, each transaction is hashed. Then the hashes are combined in pairs (Hash A with Hash B, Hash C with Hash D), and those two results are combined again to produce the Merkle Root:
In Bitcoin, "combining" two hashes means joining them together and hashing the result. If a level of the tree has an odd number of hashes, the last hash is duplicated so that it can still be paired:
The Merkle Root is therefore a single hash that represents the entire set of transactions in the block. This is extremely useful. Imagine that just one transaction, Transaction C, changes:
Hash C changes, which changes Hash CD, which changes the Merkle Root, which changes the block header and therefore the block hash. So a change to even one transaction ultimately changes the block hash and invalidates the Proof of Work that was previously performed for that block. This is where cryptographic hashing and mining connect.
5. Timestamp
The block header also contains a timestamp. It provides an approximate indication of when the miner created the block.
The timestamp does not have to be exact, but it must follow two rules. It must be later than the median timestamp of the previous 11 blocks, and it cannot be more than 2 hours ahead of the time reported by the node's peers:
6. The Difficulty Target: What Is the Miner Trying to Find?
This is the central idea behind Proof of Work. Bitcoin does not tell miners, "Find this particular hash." Instead, Bitcoin gives miners a target value. The miner's job is to find a block hash that is numerically less than or equal to that target.
For example, imagine the target were 0000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF. Every possible hash can be placed somewhere on a line from the smallest possible value to the largest. Only hashes that land at or below the target win:
The miner might produce 00000001234ABC…. Interpreted as a number, this hash is smaller than the target, so it satisfies the requirement. Another result such as 0000001ABCDEF… is too large, while something like 7A93BC… is clearly too large.
The puzzle becomes more difficult by reducing the target. In a simplified example, if the target is 1,000, there are 1,000 possible values below it (0 to 999). If the target is reduced to 100, there are only 100 possible values (0 to 99). Since hash outputs are unpredictable, the smaller the target, the lower the chance that any single hash will satisfy the requirement:
In the block header, the target is stored in a compact form in a field called bits.
The target is not fixed. Bitcoin adjusts it automatically every 2,016 blocks, which is roughly every two weeks. If the previous 2,016 blocks were found faster than one every 10 minutes on average, the target is lowered and mining becomes harder. If they were found more slowly, the target is raised and mining becomes easier. This keeps the average time between blocks close to 10 minutes, no matter how much computing power joins or leaves the network.
So the miner is searching for any hash that falls below the target. But this raises the next question: how does the miner generate different hashes if the transactions in the block are already fixed? The main answer lies in the next variable: the nonce.
7. The Nonce: The Number the Miner Keeps Changing
The nonce is a number contained in the block header that miners can change to generate different block hashes. Each new nonce produces a completely new hash, which the miner checks against the target:
| Nonce | Result | Outcome |
|---|---|---|
| 1 | Hash does not meet the target | ✗ Try again |
| 2 | Hash does not meet the target | ✗ Try again |
| 3 | Hash does not meet the target | ✗ Try again |
| … | And so on, millions or billions of times | |
| 9,847,231 | Hash ≤ Target | ✓ Success |
At that point, the miner has found a valid Proof of Work.
In practice, the nonce is a 32-bit number, so it can only take about 4.29 billion different values. Modern mining machines can try all of them in a fraction of a second, which means the nonce alone is usually not enough.
When a miner runs out of nonce values, it changes other data and starts again. The most common method is to change a value called the extranonce, which sits inside the coinbase transaction. Changing it changes the coinbase transaction's hash, which changes the Merkle Root, which gives the miner a completely new block header to work with. Miners can also adjust the timestamp and certain bits of the Version field.
8. Why Can't the Miner Just Calculate the Correct Nonce?
At this point, you might wonder: if the miner knows the target and can change the nonce, why doesn't it simply calculate which nonce will produce a valid hash?
The answer lies in the way cryptographic hash functions work. A cryptographic hash function produces an output that is effectively unpredictable from its input:
| Nonce | Resulting Hash |
|---|---|
| 1 | 8F72A91B… |
| 2 | 31C8F42D… |
| 3 | A72B19C4… |
There is no pattern that allows the miner to predict, "If I change the nonce from 3 to 4, the hash will become smaller." So even though the miner knows the target, it cannot work backwards to calculate a nonce that produces a hash below it. Instead, it has to try different nonce values and calculate the resulting hash each time:
Calculating one hash is easy. The difficulty comes from the fact that only a very small fraction of all possible hashes fall below Bitcoin's target. Therefore, the miner may need to perform an enormous number of attempts before finding one that qualifies. This is the fundamental idea behind Proof of Work:
The miner is therefore not solving a mathematical equation with a predictable answer. It is repeatedly searching for a hash that happens to satisfy the target.
9. The Miner Finds a Valid Block
Eventually, one miner finds a nonce that produces a hash below the current target. The miner has now found a valid Proof of Work for its candidate block, and it broadcasts the block to the rest of the Bitcoin network:
But the process is not finished.
10. Nodes Verify the Block
This is one of the most important distinctions to understand:
The same operator can run both a miner and a node, but the functions are conceptually different. When a miner broadcasts a newly mined block, other nodes can independently check whether it is valid. They don't need to repeat the enormous amount of computation the miner performed; they can verify the result relatively quickly. Each node works through four groups of checks:
First: Is the Proof of Work valid? The nodes hash the block header and check whether the hash is below the target. If it is, the Proof of Work is valid.
Second: Is the previous block correct? The block contains the Previous Block Hash.
Third: Are the transactions valid? Nodes validate the transactions contained within the block. They check things such as:
- Are the signatures valid?
- Are the inputs valid?
- Is there a double spend?
- Do the transactions follow Bitcoin's rules?
Fourth: Is the block itself valid? Nodes also check block-level rules, including things such as:
- Block size and weight rules
- Transaction structure
- The coinbase transaction
- Block reward rules
- Consensus rules
If everything checks out, the nodes accept the block.
11. The New Block Becomes Part of the Blockchain
Once the block is accepted, it becomes part of the blockchain. And remember: each block contains the hash of the previous block, which is what creates the chain.
12. What If Two Miners Find a Valid Block at the Same Time?
So far, we have followed the normal process:
But what happens if two different miners find a valid block at almost exactly the same time? This can happen because thousands of miners are competing simultaneously, and it takes some time for a newly mined block to travel across the Bitcoin network.
Both blocks can be perfectly valid. Both miners selected valid transactions, built a valid block, found a hash below the target, and produced a valid Proof of Work. So which block should the network accept?
A Temporary Fork
For a short period, different nodes may have different views of the blockchain. Each block propagates through the network independently, and different nodes may receive the two blocks at slightly different times:
This creates a temporary fork: two competing versions of what the next block should be. Importantly, this does not mean Bitcoin has broken. Bitcoin has a mechanism for resolving this situation.
What Happens Next?
Miners generally continue mining on top of the block they received and accepted first. Suppose another miner subsequently finds the next block on top of Block A:
The chain containing Block 850,001 now has more accumulated Proof of Work than the competing chain. As more Proof of Work accumulates on one chain, that chain becomes the one the network follows, while the competing chain becomes increasingly unlikely to become the accepted chain. In this example, Block 850,000 A remains on the main chain, while Block 850,000 B becomes a stale block.
What Happens to the Transactions in the Stale Block?
The transactions in the stale block do not automatically disappear. If a transaction from Block 850,000 B:
- is valid,
- is not already included in the accepted chain, and
- remains eligible for inclusion,
it can return to the mempool. Another miner can then select it and include it in a future block.
When a transaction is included in a block, that block is its first confirmation. As additional blocks are added on top of it, the transaction gains more confirmations, making it increasingly difficult to replace the chain containing that transaction:
13. What Does the Miner Receive?
The miner whose block is accepted by the network receives an economic reward. The reward has two components:
1. Block Subsidy: new Bitcoin created according to Bitcoin's issuance rules. The subsidy started at 50 BTC in 2009 and is cut in half every 210,000 blocks, roughly every four years. This event is known as the halving. Since the April 2024 halving, the subsidy has been 3.125 BTC per block.
| Starting Block | Year | Block Subsidy |
|---|---|---|
| 0 | 2009 | 50 BTC |
| 210,000 | 2012 | 25 BTC |
| 420,000 | 2016 | 12.5 BTC |
| 630,000 | 2020 | 6.25 BTC |
| 840,000 | 2024 | 3.125 BTC |
2. Transaction Fees: fees paid by users whose transactions are included in the block.
The miner collects this reward through the coinbase transaction it placed at the start of its block. Two conditions apply. First, the newly created coins cannot be spent until 100 more blocks have been added on top, a rule known as coinbase maturity. Second, if the block later becomes stale, the reward is lost along with it.
So mining is not simply a process for creating new Bitcoin. It is also the mechanism through which Bitcoin selects who gets to propose the next block and establishes agreement about the ordering of transactions.
14. Why Does Bitcoin Need Mining at All?
At this point, you might reasonably ask: why make miners perform all this computation? Why not simply let the nodes decide which block comes next? This question goes to the heart of Bitcoin.
Bitcoin is a decentralized network. There is no central authority deciding which transactions are valid, which block should come next, or which version of the blockchain everyone should follow. The network therefore needs a way for independent participants to reach agreement. Proof of Work provides that mechanism.
Miners compete to produce the next block by investing real-world resources: computing power and electricity. The chain with the most accumulated Proof of Work becomes the chain that the network follows. This gives Bitcoin an objective way to establish which version of the blockchain should be accepted, even when participants do not know or trust one another.
And that is why mining is much more than simply "creating new Bitcoin."
15. Bitcoin Mining: Putting It All Together
Here is the complete journey of a Bitcoin transaction, from being verified to becoming part of the blockchain. The whole process falls into four stages:
| Step | What Happens |
|---|---|
| 1. Transaction is created | A user creates a Bitcoin transaction and broadcasts it to the Bitcoin network. |
| 2. Nodes verify the transaction | Nodes check the digital signature, inputs, available Bitcoin, double spending, and other Bitcoin rules. |
| 3. Valid transaction enters the mempool | The transaction is valid but has not yet been included in a block. |
| 4. Miner selects transactions | A miner selects transactions from the mempool, usually favoring higher fees, adds its coinbase transaction, and creates a candidate block. |
| 5. Miner builds the block header | Previous Block Hash, Merkle Root, Timestamp, Difficulty Target, and Nonce. |
| 6. Miner starts Proof of Work | The miner must find a block hash that is less than or equal to the current target. |
| 7. Miner changes the nonce | The miner changes the nonce and hashes the header. When the nonce runs out, it changes the extranonce and starts again. |
| 8. Hash is compared with the target | If the hash is too large, the miner tries another nonce. It keeps trying until a valid hash is found. |
| 9. Miner finds a valid block | The miner broadcasts the block to the Bitcoin network. |
| 10. Nodes verify the block | Is the Proof of Work valid? Does the block use the correct target? Does the Previous Block Hash point to the correct previous block? Are all transactions valid? Does the block follow the consensus rules? |
| 11. Block is accepted | If valid, the block becomes part of the node's current best valid chain. |
| 12. Block becomes part of the blockchain | The new block is linked to the previous block through its Previous Block Hash. |
| 13. More blocks are built on top | Each new block adds another confirmation to earlier transactions, making them increasingly difficult to replace. |
| 14. Miner receives the reward | Block Subsidy + Transaction Fees, spendable after 100 more blocks. |
The Big Picture
This is what allows Bitcoin to maintain a shared history of transactions without a central authority deciding which transactions and blocks should be accepted.
Key Takeaways
- Valid transactions wait in the mempool until a miner includes them in a block, usually prioritizing those that pay the highest fee rate.
- Mining happens on the block header, which links to the previous block and summarizes every transaction through the Merkle Root.
- Proof of Work means finding a header hash at or below the target. Because hashes are unpredictable, the only way is to keep changing the nonce (and extranonce) and try again.
- The target adjusts every 2,016 blocks to keep blocks arriving about every 10 minutes on average.
- Miners propose blocks, but nodes verify them. When two valid blocks compete, the network follows the chain with the most accumulated Proof of Work.
- The winning miner earns the block subsidy plus transaction fees, paid through the coinbase transaction and spendable after 100 more blocks.





