We certainly hear about immutability of blockchain and the fact that nobody can tamper with transactions stored on the ledger. And there is plenty of over-enthusiasm as to how our healthcare records, insurance policies etc., in the future will be on the blockchain. Is it really true? I will explore that question in a later post. Today, let’s see what exactly is stored on the blockchain.
As a reminder, every node on the network has a full record of the entire chain.
As I wrote in my previous post, blockchain has a chain of chronologically ordered blocks. What is stored on each block, depends on the blockchain. For example, Bitcoin and Ethereum do it differently.
In today’s post I will focus on Bitcoin blockchain.
While one can store any data (property deeds, product inventories etc) on the blockchain, Bitcoin was designed to store the history of all bitcoin payments1.
Every block in the Bitcoin blockchain has:
Header
Transaction Count
List of all the transactions
Image credit: Wikimedia
Block Header:
Block headers are serialized in a 80-byte format.
Block Version - 4 bytes - versions have a set of block validation rules to follow.
Previous block header hash - 32 bytes - this ensures no previous block can be changed without also changing this block’s header.
Merkle root hash - 32 bytes - derived from the hashes of all transactions included in the block.
Time - 4 bytes - the block time is a Unix epoch time when the miner started hashing the header (according to the miner).
nBits - 4 bytes - (more in a later post)
Nonce - 4 bytes - (more in a later post)
Number of transactions - transaction count:
The total number of transactions in this block, including the coinbase transaction2.
Raw transactions:
Every transaction in this block, one after another, in raw transaction format.
Transaction was defined by Satoshi Nakamoto in Bitcoin white paper as
“We define an electronic coin as a chain of digital signatures. Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership.”
Image credit: Bitcoin white paper
Sample Complex Raw Transaction (breaking down each line is beyond the scope of this post - maybe some day):
[
{
"txid" : "263c018582731ff54dc72c7d67e858c002ae298835501d\
80200f05753de0edf0",
"vout" : 0,
"address" : "muhtvdmsnbQEPFuEmxcChX58fGvXaaUoVt",
"scriptPubKey" : "76a9149ba386253ea698158b6d34802bb9b550\
f5ce36dd88ac",
"amount" : 40.00000000,
"confirmations" : 2,
"spendable" : true,
"solvable" : true
},
{
"txid" : "263c018582731ff54dc72c7d67e858c002ae298835501d\
80200f05753de0edf0",
"vout" : 1,
"address" : "mvbnrCX3bg1cDRUu8pkecrvP6vQkSLDSou",
"account" : "",
"scriptPubKey" : "76a914a57414e5ffae9ef5074bacbe10a320bb\
2614e1f388ac",
"amount" : 10.00000000,
"confirmations" : 2,
"spendable" : true,
"solvable" : true
},
{
"txid" : "78203a8f6b529693759e1917a1b9f05670d036fbb12911\
0ed26be6a36de827f3",
"vout" : 0,
"address" : "n2KprMQm4z2vmZnPMENfbp2P1LLdAEFRjS",
"scriptPubKey" : "210229688a74abd0d5ad3b06ddff36fa9cd8ed\
d181d97b9489a6adc40431fb56e1d8ac",
"amount" : 50.00000000,
"confirmations" : 101,
"spendable" : true,
"solvable" : true
},
{
"txid" : "c7736a0a0046d5a8cc61c8c3c2821d4d7517f5de2bc66a\
966011aaa79965ffba",
"vout" : 0,
"address" : "mz6KvC4aoUeo6wSxtiVQTo7FDwPnkp6URG",
"account" : "",
"scriptPubKey" : "76a914cbc20a7664f2f69e5355aa427045bc15\
e7c6c77288ac",
"amount" : 49.99990000,
"confirmations" : 1,
"spendable" : true,
"solvable" : true
}
]
Upper case usage of Bitcoin refers to the blockchain, whereas lower case usage of bitcoin refers to the monetary coin.
A coinbase transaction is the first transaction in a block.