We have already seen blocks contain data or transactions. But, is it all? No, lets get inside a block.
A block comprises of two parts:- Block header and Transactions list
Block header contains vital info of block such as hash, merkle root etc. This is what an actual block header looks like
We shall see what some of these terms are:-
- Hash- A unique number which acts as an identity for each block. It is generated by combining merkle root and previous block’s hash.
- Timestamp- Time when block was added in blockchain.
- Height- It is 645373 which means there are 1 less i.e 645372 number of blocks in blockchain. Had it been 1, it would have been the very first block in blockchain and would be called as genesis block.
- Number of Transactions- How many transactions does this block have.
- Difficulty- Blocks need to be added one after another which would eventually form a chain. It is the job of a miner in a process called as mining. In order to make you understand this alien concept, let me give you a small example: Consider a worker A is mowing a big lawn consisting of 8 smaller lawns. His per day pay is to be decided on the basis of how many smaller lawns he mowed. But here is a condition, height of 2 feet tall grass should not be more than 1 feet after getting mowed. If it is more than 1 feet, he will have to redo work until height of grass meets minimum requirements. Suppose, he mowed down 1st smaller part meeting all criteria, it will be registered in his log book and he will be paid at end of day. If in some portion of 2nd smaller part, height of grass is more than 1 feet, it wont be registered in his log book and he wont be paid. He will have to redo work until he meets min requirement.
Here 1 feet is difficulty level and worker is miner. Lets sum it up, if miner wants to add block to blockchain and get paid, there is a minimum requirement of hash that has to be met otherwise miner can’t add block into blockchain.
6. Merkle root:- There are a ton of transactions inside a block. For example, this block has 2074 transactions and we need one hash per block. Since each transaction will produce one hash, there will be 2074 hashes in this case. How these many number of hashes will produce one single hash? Hashes of two transactions will be hashed together to form a new hash. Next two hashes of two transactions will be hashed together to form another new hash. Those two new hashes will be hashed together until we are left with one supreme hash.
This is what merkle tree looks like with merkle root at the top.
7. Nonce:- If worker A is not getting desired minimum height of grass in spite of running machine over grass again and again, what he should do? Change blades may be? And keep changing blades until 2 feet reduces to 1.
Similarly, nonce(appended after merkle root) is a numberwhich is hashed together with merkle root resulting in desired minimum hash. If it doesn’t meet minimum hash requirement, it keeps on changing itself until it meets hash requirement.
Name itself speaks. It consist of all transactions, remember that 2074 number?
This was an overview of what an actual block in bitcoin blockchain is.
Comments, questions and inputs are welcome.