Monday, 21 June 2021

Structure of a Block in Blockchain


Structure of a Block in Blockchain, what is a block, Parent Block, Block Header, Properties of a Block, Block Identification Hello guys, hope you are doing good and enjoying your lives. Today, I am going to introduce you to the blocks of a blockchain. I gave you an understanding of blockchain, its characteristics, and some idea about accounts and wallets in my previous tutorials, and today my article is about the structure of a block in the blockchain.

I will first define the block before going into the details about its structure. So let’s start without any further delay.

Block in Blockchain

Structure of a Block in Blockchain, what is a block, Parent Block, Block Header, Properties of a Block, Block Identification

  • A block is actually the building block or the key element of a blockchain.
  • The definition of a blockchain is based on its blocks. As I defined in my previous posts, a blockchain is a chain of multiple blocks.
  • Blocks contain transactions. Each block contains a different number of transactions.
  • These transactions are contained in blocks so that they would be added to the distributed ledger.
  • The number of transactions is limited by the block size and gas limit. Generally, the block contains more than 500 transactions.
  • Other than transactions, a block also consists of some metadata. This metadata is stored in the header of the blockchain.
  • The size of a block header is 80 bytes, the detail of which is given in the upcoming sections of this article.
  • Let’s first define a parent block in the next part.

Parent Block in Blockchain

Structure of a Block in Blockchain, what is a block, Parent Block, Block Header, Properties of a Block, Block Identification

As the blocks are linked together one after the other, they have a parent-child relationship. Each block is the parent of the upcoming block. Each child block contains the hash of the previous block i.e., its parent block. The first block of the blockchain is called Genesis Block and it has no parent.

The block contains different fields which can be roughly categorized as listed below:

  • The block size: The size of this field is 4 bytes and it contains the size of the block.
  • The block header: The size of a block header is 80 bytes. It further contains different fields.
  • The transaction counter: This field contains the number of transactions and the size of it is between 1-9 bytes.
  • The transactions: This field contains transactions of the block and its size is variable.

This was some information regarding the fields of an Ethereum block. Now, we will move towards the next part in which I am going to give you an idea about the block header and its fields.

Block Header in Blockchain

Structure of a Block in Blockchain, what is a block, Parent Block, Block Header, Properties of a Block, Block Identification

The header of an Ethereum block contains different fields of metadata which are listed below.

  • Hash of the previous block: Every block header gives information about the previous or parent block. This field contains the hash value of the previous block and this reference connects all the blocks. The size of this field is 32 bytes.
  • Version: This field stores the version number to show software upgrades. The size of the version field is 4 bytes.
  • Difficulty: The mining difficulty at the time of the block creation is stored in this field. The concept of mining would be explained in the upcoming articles. Its size is 4 bytes.
  • Timestamp: This field contains the time at which the block was created. The size of this field is 4 bytes.
  • Nonce: A nonce is a value used during the mining of the block. This field’s size is also 4 bytes.
  • Merkle tree root: A Merkle tree is a structure obtained from hashing the transactional data of a block. The root of this tree is stored in the block header under this field. 32 bytes is the size of the Merkle tree root field.

This was all about the header of a block. In the next part, I am going to give you an idea about the properties of a block.

Properties of a Block:

Structure of a Block in Blockchain, what is a block, Parent Block, Block Header, Properties of a Block, Block Identification

There are a lot of properties of a block that give us important information about it. I am listing down the properties here.

Difficulty Property:

  • As I mentioned earlier, this property gives the difficulty level of solving the puzzle to mine the block.

totalDifficulty Property:

  • This property of the block tells us the total difficulty of the blockchain.

gasLimit Property:

  • This property tells us the maximum gas allowed by the block which in turn tells us about the number of transactions that the block can accommodate.

gasUsed Property:

  • The gasUsed property gives the amount of gas used by the block for executing all of its transactions.

Number Property:

The number shows the block number in the list of blocks.

Transactions Property:

  • This means all of the transactions contained in the block.

Hash Property:

  • This property shows the hash of the block.

parentHash Property:

  • This property saves the hash of the previous block.

Nonce Property:

  • Nonce property shows the nonce value that I defined earlier. It is a variable used in mining the block.

Miner Property:

  • The miner property gives information about the miner of the block. This gives the account of the block miner.

So guys these were the properties of a block. I will move towards the next part i.e., the identification of a block.

Block Identification:

Structure of a Block in Blockchain, what is a block, Parent Block, Block Header, Properties of a Block, Block Identification

The blocks of a blockchain need an identification to refer them or distinguish them from other blocks. Two parameters are used for this purpose which are given below:

1. Block Hash

Block hash is the main identification parameter of a block. This value is obtained by cryptographic hashing of the header of the block. The hashing operation is performed twice. The header of the block contains metadata of the block and when this data is hashed the result is the block hash, whose size is 32 bytes.

The hash of the block is not stored in the block’s data whether the block is being transmitted to the other nodes or it is stored as part of the blockchain on some node. When a node receives a block from the network, it computes its hash itself.

2. Block Height

The second parameter used for identifying a block is its height. As we already know that the blocks are linked together in a list type structure starting from the genesis block. The genesis block is given a height 0 zero. The second block in the blockchain or the first block after the genesis block is at height 1 and so on.

In this article, I have explained the structure of an Ethereum block. The article explained the header and some properties of the blocks. I hope you have learned something new from it. Take care!

The post Structure of a Block in Blockchain appeared first on The Engineering Projects.



No comments:

Post a Comment