# BSV Blocks and SHA-256

<figure><img src="https://hub.bsvblockchain.org/~gitbook/image?url=https%3A%2F%2F2147185133-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FWtK4ab0ntyPZBmGoKq4t%252Fuploads%252Fgit-blob-65c6a6297bf1ab48f4551e8ed4e280f3d4c1b4e0%252FBSVA-HashFunctions_Ch3L3_DA1.gif%3Falt%3Dmedia&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=a63cd3ad&#x26;sv=2" alt=""><figcaption></figcaption></figure>

#### What is a BSV Block?

A **BSV block** is a **time-stamped package** containing all transactions accumulated between two **proof-of-work solutions**.

* Like TXIDs, **Block IDs** are generated by applying **double SHA-256 (HASH-256)** to the serialized block header.
* The system adjusts difficulty to ensure a new block is discovered roughly **every 10 minutes**.

Each block contains:

* **All validated transactions** collected by the winning node.
* Any **data payloads** attached to those transactions.
* A **block header**, which includes:
  * **Version field** (4 bytes, little endian)
  * **Previous block hash** (32 bytes, little endian)
  * **Merkle Root Hash** (32 bytes, little endian)
  * **Time field** (4 bytes, big endian, Unix epoch)
  * **nBits** (4 bytes, little endian, defines current difficulty target)
  * **Nonce** (4 bytes, little endian, value miners adjust to find proof-of-work solution)

***

#### Example Block (Deserialized JSON)

```
{ 
    "tx": [ 
        "63fde109a6f22a611fe80847eb43f34b1cef0ec095273c3cbf12b0164295796b", 
        "d94f1db2079b1a3f4c4936e0f47434e09ab7eef7a1d35d2fc6af5dd9e87b4f84" 
    ], 
    "hash": "0be14bde7beb17c481b5bc78496ef129c25e16401d78419e789f9629db6057e4", 
    "confirmations": 155, 
    "size": 406, 
    "height": 284, 
    "version": 536870912, 
    "versionHex": "20000000", 
    "merkleroot": "f15b44eebcf7a3c3009cc6acd3bd1dd74f256448936c88ad72f39b55981ddffd", 
    "num_tx": 2, 
    "time": 1647415283, 
    "mediantime": 1647412906, 
    "nonce": 0, 
    "bits": "207fffff", 
    "difficulty": "4.656542373906925e-10", 
    "chainwork": "000000000000000000000000000000000000000000000000000000000000023a", 
    "previousblockhash": "74f52bbca1a9a4f7f13f85cdcd24c7f49650cd1d463421373eb3bcb683868712", 
    "nextblockhash": "7e976012ba0a1cd9eeba8fb57ba41c982b914cffcd17fe46b84c0a0333db79eb", 
    "coinbaseTx": { 
        "txid": "63fde109a6f22a611fe80847eb43f34b1cef0ec095273c3cbf12b0164295796b", 
        "hash": "63fde109a6f22a611fe80847eb43f34b1cef0ec095273c3cbf12b0164295796b", 
        "version": 2, 
        "size": 100, 
        "locktime": 0, 
        "vin": [ 
            { 
                "coinbase": "021c010101", 
                "sequence": 4294967295 
            } 
        ], 
        "vout": [ 
            { 
                "value": 25.00000113, 
                "n": 0, 

                "scriptPubKey": { 

                    "asm": "03642fd43b260aab1f0241535c9fabec5445bdc42591a5be9d555a6e33c96a09d8 OP_CHECKSIG", 
                    "hex": "2103642fd43b260aab1f0241535c9fabec5445bdc42591a5be9d555a6e33c96a09d8ac", 
                    "reqSigs": 1, 
                    "type": "pubkey", 
                    "addresses": [ 
                        "mjvmz3xW4nTbjtKsmbfhsXB9gtm9GBddJg" 
                    ] 
                } 
            } 
        ], 
        "blockhash": "0be14bde7beb17c481b5bc78496ef129c25e16401d78419e789f9629db6057e4", 
        "confirmations": 155, 
        "time": 1647415283, 
        "blocktime": 1647415283, 
        "blockheight": 284, 
        "hex": "02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff05021c010101ffffffff0171f9029500000000232103642fd43b260aab1f0241535c9fabec5445bdc42591a5be9d555a6e33c96a09d8ac00000000" 
    }, 
    "totalFees": "-24.99999887", 
    "miner": "\u0002\u001c\u0001\u0001\u0001", 
    "txCount": 2 
```

&#x20; The below table breaks down the block header for the above block:&#x20;

<figure><img src="/files/GbNFXl3L7zU7N7U3UfzF" alt=""><figcaption></figcaption></figure>

👉 **Key takeaway:** The **block header** ties the block to its predecessor, ensures data integrity via the **Merkle Root**, and encodes the difficulty/nonce for proof-of-work.&#x20;

#### UTXO Sets and Mempools

* All **unspent outputs (UTXOs)** are tracked in a node’s **UTXO set**.
* **New transactions** are validated and held temporarily in the node’s **mempool**.
* A **Merkle Tree** is constructed from these transactions, with the root placed into the **block header**.
* Once a UTXO is consumed as an input, it is **removed** (often pruned) from the UTXO set.

***

#### How is a BSV Block Created?

1. **Transactions are broadcast** to the network.
2. Nodes validate transactions against **consensus rules** and **local policies**.
3. Valid transactions are added to the **Merkle Tree**.
4. Nodes create **block header templates** and send them to miners.
5. Miners iterate through **nonce values**, hashing headers with SHA-256 twice, searching for a valid **proof-of-work solution**.
6. When a valid solution is found:
   * A **new block ID** is finalized.
   * The block is **broadcast** to the network.
   * Other nodes **accept the block** by building on top of it.
7. After **99 additional blocks** confirm it, the block’s **coinbase reward** becomes **spendable**.

***

✅ **Summary:** BSV blocks are **containers of transactions**, secured with **double SHA-256**, and validated through **proof-of-work**. Each block links back to the previous one, forming a tamper-proof, time-stamped chain of records.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/bitcoin-primitives-hash-functions/sha256/bsv-blocks-and-sha-256.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
