A Bitcoin block is a fundamental component of the Bitcoin blockchain. It is a data structure that contains a collection of transactions that have been verified and grouped together by miners.
Each block contains a block header and a block body.
The block header is an 80-byte segment at the beginning of each block. It contains essential information about the block, including: (We’ll take block number 795,633 as our reference)
0x20018000
in hexadecimal.SHA256(SHA256())
hash of the previous block’s header. It links the block to its parent block, forming a chain of blocks.SHA256
? There are two times SHA256 because it is a way to make the hash function more secure and resistant to certain types of attacks.SHA256
, which is denoted as SHA256(SHA256())
. It does this for various reasons, such as making the proof-of-work algorithm more secure, ensuring the integrity of the transactions and blocks, and preventing length-extension attacks on the block headers.00000000000000000001d6fa5edbea6a697167f478be6a97d4f22c274d5c2fb3
The Merkle root is derived from the hashes of all transactions included in this block, ensuring that none of those transactions can be modified without modifying the header. I won’t go in-depth here because I have already published two detailed articles on it. I’ll provide the link for your reference.
Merkle root for (795,633): 8ac3cfc68465375943e1c625e3a1c6c02d4f7d2fd66cd91b68165fcc152d9f6f
The timestamp of when the block was mined. Block 795,633 was mined on Jun 24, 2023, 12:02 AM UTC.
A value representing the mining difficulty level at which the block was mined. It was 52,350,439,455,487.47 for Block 785,633.
A random value that miners change in order to find a valid block hash. It was 3,492,054,801 for our Block in reference.
The block body is the part of the block that has all the transactions. Transactions are the records of who sent and received bitcoins. In other words, transactions represent the movement of Bitcoins from one address to another. Each transaction contains the following elements:
Transaction Hash ID: A unique identifier for the transaction derived from hashing the transaction data.
Inputs: The sources of Bitcoins for the transaction, specifying the transaction outputs from previous transactions that are being spent.
Outputs: The destinations for the Bitcoins being sent in the transaction, specifying the amounts and the receiving addresses.
Transaction Fees: The difference between the total value of the transaction inputs and the total value of the transaction outputs. It serves as an incentive for miners to include the transaction in a block.
Let’s take an example from our reference block 795,644
. You can view all the transactions present in this block by going to any Bitcoin blockchain explorer and pasting the transaction hash. Let’s take an example of a transaction with hash: 76060e5f6947dd875ab84f41a8ee87d9b9344f25a6737b9502d42bc9c90fba20
Hash ID: 76060e5f6947dd875ab84f41a8ee87d9b9344f25a6737b9502d42bc9c90fba20
Inputs: 1 (1Kr6QSydW9bFQG1mXiPNNu6WpJGmUa9i1g
)
Outputs: 2 (1AWYVZvfQvGGsaTNePKKWAxPQkWuC6ZvdY
, 1Kr6QSydW9bFQG1mXiPNNu6WpJGmUa9i1g
)
Transaction Fees: 0.00058200
BTC
Here’s a JSON
{
"txid": "76060e5f6947dd875ab84f41a8ee87d9b9344f25a6737b9502d42bc9c90fba20",
"size": 225,
"version": 2,
"locktime": 0,
"fee": 58200,
"inputs": [
{
"coinbase": false,
"txid": "3a204a0a1e34dccda0f1a528b88e0aa462d36becc1396da04149c77d40ea0922",
"output": 1,
"sigscript": "47304402206bb01734130b7d75d5dfbe39b3f9f8f388cfb12d897fb1bcaf5ca17d0caa19ca02202e7e50ca859d592d137b08cf1359cf9dda39e268760ba63702c71ab18115f973012103786af4b32017ec640dba2d2a7e1fd5aa4a231a658e4cbc114d51c031576e19bc",
"sequence": 4294967293,
"pkscript": "76a914cebb2851a9c7cfe2582c12ecaf7f3ff4383d1dc088ac",
"value": 44202007434,
"address": "1Kr6QSydW9bFQG1mXiPNNu6WpJGmUa9i1g",
"witness": []
}
],
"outputs": [
{
"address": "1AWYVZvfQvGGsaTNePKKWAxPQkWuC6ZvdY",
"pkscript": "76a914684f7bcd2d8da9d5ea582b27661e744bd0a7c22888ac",
"value": 5800100,
"spent": true,
"spender": {
"txid": "4a11ff43c023fda8b18382aa4e12776f8ade15c36890306aaf6655b8c0d45600",
"input": 50
}
},
{
"address": "1Kr6QSydW9bFQG1mXiPNNu6WpJGmUa9i1g",
"pkscript": "76a914cebb2851a9c7cfe2582c12ecaf7f3ff4383d1dc088ac",
"value": 44196149134,
"spent": true,
"spender": {
"txid": "504a0abfbd68e09421bca12239853c35b680592c8a39190e8df634a069ac27db",
"input": 0
}
}
],
"block": {
"height": 795633,
"position": 5
},
"deleted": false,
"time": 1687564195,
"rbf": false,
"weight": 900
}
There is some additional information, such as the position, which gives us information regarding the index of the transaction in the block.
The block body also has a special transaction that gives bitcoins to the miner who found the block. It is called the Coinbase transaction, which is the first transaction (position: 1) in the block. It has no inputs but has one or more outputs, which specify the reward for the miner who found the block solution.
The miner gets some bitcoins as a reward for finding the block and some bitcoins as fees for including the transactions in the block. In the case of our reference block, the transaction id for that special transaction is: a2acdd6473c049a7cf1ca38ce91e6cb0a9e6099a90e0749f2a183e320478fe6f
You can copy this transaction id and search for it in any Bitcoin Explorer for additional details.
Bitcoin blocks are created by miners, who are responsible for verifying transactions and adding them to the blockchain. Miners use powerful computers to solve complex mathematical problems, and the first miner to solve the problem and validate the transactions in a block is rewarded with newly created bitcoins. Once a block is created, it is broadcast to the network, and other nodes on the network validate the block before adding it to their own copy of the blockchain. I have written a detailed article explaining how this works. Please refer to the following article.
In summary, Bitcoin blocks are a fundamental building block of the blockchain and are responsible for ensuring the security and immutability of the Bitcoin network. Without blocks, the blockchain would not exist, and the entire Bitcoin ecosystem would be compromised. Understanding how blocks work is essential for anyone looking to learn more about Bitcoin and the wider world of cryptocurrencies.
Also published here.