A Block block in a blockchain is a Data Structure that stores a set of transaction data in a blockchain.
- A series of Blocks connected together in a linear sequence pattern forms a Blockchain. Each data in a block is hashed together with a Nonce number. Once a nonce number is generated it means the block is hashed and added to the blockchain.
- The initial Block in a Blockchain network is called the Genesis Block. It is the first block and doesn’t refer to any previous Block. A genesis block is usually hardcoded while developing the Blockchain.
- Block Height is the number of blocks confirmed/successfully added to the blockchain from the first block.
- Block size is the size of storage present in each block in a Blockchain. Size of the Bitcoin Blockchain is 1MB.
A Block consists of
A. Block Header
The head of the block is divided into six components:
1.Block version Number
Block number is the version number of the blockchain network protocol. It is used for identification of the software version which will be helpful for identifying the supported features or protocols.
2.The hash of the previous block
The hash of the previous block acts as a primary key identifier to form a chain of blocks in the blockchain without any issues. Except the genesis block, all other blocks in the blockchain have this previous block hash stored in the block header.
3.The root hash of the Merkle tree
- A Block has multiple transactions grouped and hashed together. This hash is called the root hash of the Merkle tree.
- Merkle Tree groups data into pairs. Let’s say that a single block contains a total of 848 transactions. The Merkle Tree would start by grouping these transactions into a pair of 424. Next, this transaction ID pair of 424 goes through a hashing function and the process continues.
- This pair of 424 would be split and paired up again into pairs of 212. The process is repeated multiple times, cutting the codes in half each time, until only one code remains. That code is the Merkle Root. It is the combined Hash of all transactions hash together in a block of a blockchain. The Merkle root is added to the Block Header.
- Think of that there are 4 transactions in 1 Block – A, B, C, and D. All the transactions are then hashed, producing: Hash A, Hash B, Hash C,
- Hash D. Hash A and Hash B are paired together to form Hash AB. Similarly, Hash C and Hash D are paired together to form Hash CD. Now here, Hash AB and Hash CD combine together to form the “Merkle Root” – Hash ABCD
4.The time in seconds since 1970–01–01 T00: 00 UTC
Timestamp of when this block was added to blockchain in seconds.
- Nonce is a 32-Bit number present in the block header. It is a number/value that can only be used once (Unique). It is widely used in cryptographic hash functions for authentication.
- Nonce is used in multiple blockchains for unique identification. Example: Bitcoin, Ethereum, Stellar, Hyperledger.
- Mining is a concept in PoWBlockchains where a miner (Computer) solves a mathematical problem producing a hash value. Once this problem is solved successfully, then the miner is rewarded which is called “Block Reward. After this verification, the block is added to the blockchain.
- Miners across the blockchain network in this process compete with each other to find a nonce that creates a hash value equal to or lower than the network difficulty set. Such a nonce found found by the miner is called “Golden Nonce”
- Nonce is a concept used to avoid “Double Spend” and “Replay Attacks” in blockchain. When a valid transaction is repeated or delayed in a blockchain maliciously then it is called a Replay Attack.
Ethereum Blockchain has : Block nonce, Transaction nonce
Bitcoin Blockchain has only Block Nonce
B. Block Body
The block body contains data of all the transactions that are added in this block and confirmed on the blockchain.
Understanding the Block structure and concepts is very much the basic step in starting to learn Blockchain. Feel free to leave out any questions or queries on the comments section. Thanks!
Get in touch with me if you are looking to hire a blockchain consultant/Project Manager for your Blockchain development project.