> For the complete documentation index, see [llms.txt](https://hub.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hub.bsvblockchain.org/higher-learning/bsv-academy/bitcoin-primitives-merkle-trees/merkle-trees-and-the-block-header/proof-of-work-in-action.md). Agents can also search and read this documentation through its [MCP server](https://hub.bsvblockchain.org/~gitbook/mcp).

# Proof-of-Work in Action

In this example, we examine **Block 550204**, which contains **two transactions**.\
We’ll walk through how these transactions are hashed, combined into a **Merkle Root**, and finally used in the **block header** for the **Proof-of-work** process.

#### **Step 1: From Transactions to TXIDs**

Each transaction’s **raw data** is first hashed twice using **SHA-256** (Ps. `HASH256` is SHA-256 applied twice in succession), producing its **Transaction ID (TXID)**.

These TXIDs form the **leaf nodes** of a two-layer **Merkle Tree**. The TXIDs are then concatenated and double-hashed again to produce the **Merkle Root**.

> ⚙️ **Endian note:**\
> Hash outputs are displayed in **Little Endian** format.\
> When comparing to **Block Explorer** data (usually shown in **Big Endian**), you must **reverse the byte order** of each hexadecimal pair to match.
>
> Similarly, if building a Merkle Tree from block explorer TXIDs, reverse each to **Little Endian** before concatenating them.

<figure><img src="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2FGRWCHthAOdIJ4pKsmREC%2Fsteps%201.png?alt=media&amp;token=3de37949-259a-447a-8c45-4f9a5ab80688" alt=""><figcaption></figcaption></figure>

#### **Step 2: The Merkle Root and Block Header**

The resulting **Merkle Root** is inserted into the **block header** as one of its six data fields.

To create the full **80-byte header string**, several conversions are required:

* Convert all **decimal fields** to **hexadecimal**.
* Reverse each field’s **byte order** (from Big to Little Endian).
* **Concatenate** all elements in the correct sequence.

Although confusing for humans, **Little Endian encoding** is **faster for hardware** to process — a small optimization that matters when the system scales to **millions of transactions per second**.

<figure><img src="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2FKWkWoYmZBTWYKv25sqvs%2Ffield.png?alt=media&amp;token=8439e7e9-291a-4991-9bfe-dfb4d724b39e" alt=""><figcaption></figcaption></figure>

#### **Step 3: Evaluating the Hash Puzzle**

To check if a block solves the **Proof-of-work puzzle**, the **HASH256** of the entire block header must be **lower than the difficulty target** calculated from the **nBits** field.

This target is derived from the formula:

> **Target = coefficient × 2⁸ × (index − 3)**

For Block 550204,

* nBits = `0x180202F3`
* Index = `0x18` → 24 (decimal)
* Coefficient = `0x0202F3` → 131,827 (decimal)

Plugging these in:

> **Target = 131,827 × 2⁸ × (24−3) = 4.93 × 10⁵⁵**

#### **Step 4: First Attempt – Invalid Hash**

In the miner’s first attempt:

* The **double-hashed block header** produced a value of approximately `1.96 × 10⁷⁶`.
* The **target** was only `4.93 × 10⁵⁵`.

Since the result is **much higher than the target**, the attempt **fails**.

To try again, the **nonce** is incremented by 1 — producing a new header string that differs by only **one hexadecimal character**.

<figure><img src="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2F8NAE79JJPlaUzoQnT7Lv%2Fsteps%204.png?alt=media&amp;token=554bd396-65c4-43cf-b50c-c7498b92f44a" alt=""><figcaption></figcaption></figure>

#### **Step 5: Second Attempt – Valid Hash**

After incrementing the nonce:

* The new **block hash** becomes `3.28 × 10⁵⁵`,
* Which is **lower than the target** (`4.93 × 10⁵⁵`).

This means the miner has found a **valid Proof-of-work solution**.

The block can now be **submitted to the network** for verification by other nodes.

<figure><img src="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2F7YUpzPC0F8hQzpj1c4dK%2FStep5.png?alt=media&amp;token=9b1947f0-9b5b-4bf1-894b-24af79d2022e" alt=""><figcaption></figcaption></figure>

#### **Key Takeaway**

The **Proof-of-work** process involves continuously changing a small part of the block header (the **nonce**) and hashing it until the resulting value is **below the target threshold**.

This demonstrates Bitcoin’s **computational fairness** — only through genuine work can a miner earn the right to add a new block to the chain.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/bitcoin-primitives-merkle-trees/merkle-trees-and-the-block-header/proof-of-work-in-action.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
