Block Structure
Block structure, Merkle Trees and transaction format
“Miners build blocks, but nodes decide which blocks to follow.” — Fundamental principle of Bitcoin
1. Introduction
Bitcoin is a distributed network whose operation depends on two central structures:
blocks
transactions
Both are chained cryptographically using Merkle trees and protected by Proof of Work (PoW). Understanding their design is essential to understand:
how information is organized
how incentives work
how immutability is guaranteed
how consensus is reached without a central authority
2. The blockchain: general structure
A Bitcoin block is composed of two main parts:
┌────────────────────┐ │ Header (80B) │ ← Block hash └────────────────────┘ ┌────────────────────┐ │ Body: transactions │ └────────────────────┘
2.1. Header fields
The block header is exactly 80 bytes, structured as follows:
version
4 bytes
Indicates validation rules
prev_block_hash
32 bytes
Previous block hash
merkle_root
32 bytes
Merkle tree root
timestamp
4 bytes
Approximate time
bits
4 bytes
Difficulty target
nonce
4 bytes
Counter for PoW
Final block hash:
3. Block body: transactions
A block contains:
1 coinbase transaction (the first)
N normal transactions
Conceptual representation:
Block ├─ Coinbase TX ├─ TX1 ├─ TX2 ├─ ... └─ TXn
The current limit is a maximum weight of:
after the activation of SegWit (BIP141).
4. Merkle trees in Bitcoin
Merkle trees allow:
to prove inclusion of transactions
to reduce the amount of information required for SPV clients
to protect against modifications
4.1. Step-by-step construction
Take the hash of each transaction:
Group pairs and hash them again:
Repeat until reaching the root.
4.2. Representation
4.3. Inclusion proofs (Merkle Proof)
An SPV client can prove that:
with a proof of size .
5. Bitcoin transactions: technical structure
A transaction consists of:
inputs (inputs)
outputs (outputs)
The inputs consume previous UTXOs. The outputs create new UTXOs.
5.1. General format
Transaction ├─ Version (4 bytes) ├─ TX_IN_COUNT ├─ [Inputs] ├─ TX_OUT_COUNT ├─ [Outputs] └─ locktime
5.2. UTXO: Bitcoin's accounting model
Bitcoin does not use accounts. It uses a global set of unspent outputs (Unspent Transaction Outputs).
Advantages:
parallelization
easy verifiability
protection against double spending
simplicity in validation
Formalization:
6. Inputs: consuming previous transactions
An input contains:
prev_txid
hash of the previous transaction
prev_index
index of the consumed output
scriptSig
signature + unlocking data
sequence
used in locktime
The input proves that the user owns the private key associated with the UTXO.
6.1. scriptSig (classic)
Example:
<ECDSA signature> <public key>
With SegWit, the signature goes in a different field (witness).
7. Outputs: creating new UTXOs
An output contains:
value
amount in satoshis
scriptPubKey
spending conditions
7.1. Most common scriptPubKey (P2PKH)
OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG
7.2. P2SH
Type introduced by BIP16:
OP_HASH160 <script_hash> OP_EQUAL
7.3. P2WPKH (SegWit)
Witness format:
0 <20-byte-key-hash>
Benefits:
lower signature weight
eliminates malleability
reduces fees
8. Signatures in transactions
Bitcoin uses ECDSA over the curve secp256k1.
To sign a transaction a message is constructed:
Then:
8.1. Sighash types
Bitcoin allows different signing modes:
SIGHASH_ALL
Signs inputs and outputs
SIGHASH_NONE
Signs inputs, outputs are free
SIGHASH_SINGLE
Signs the corresponding input
ANYONECANPAY
Modifies allowed inputs
9. The coinbase transaction
It is the first transaction in each block.
9.1. Features:
it has no valid inputs
it creates new bitcoins
includes the reward (subsidy + fees)
contains an arbitrary script with optional messages
Classic example: the genesis block's message.
9.2. Subsidy
where
= number of halvings that have occurred
10. How transactions are verified
A node verifies:
Correct format
Valid signatures
UTXOs exist
No double spending
Outputs do not exceed inputs
Valid sighash
Script executed without error
10.1. Script evaluation
Bitcoin Script is a simple, non-Turing-complete language.
Evaluation example P2PKH:
scriptSig: <signature> <pubKey>
scriptPub: OP_DUP OP_HASH160 <hash> OP_EQUALVERIFY OP_CHECKSIG
11. Block validation
To accept a block:
Block hash < Target
All transactions valid
Correct size
Correct reward
Prev_block_hash matches
The Merkle Root matches
Reasonable timestamp
12. Mathematical representation of the chaining
If:
= Block i
= Hash of block i header
then:
which produces:
Security depends on:
13. Chapter conclusion
In this chapter we have seen:
how a block is structured
how transactions are organized and verified
what role the Merkle tree plays
how the integrity of the chain is ensured
why the UTXO system is superior to an account-based model
All these elements are the basis of Bitcoin's fundamental layer.
If you understand a block, you understand Bitcoin. If you understand the Merkle tree, you understand why it is immutable.
Last updated
Was this helpful?

