Genesis Block
A block is a fundamental element of a blockchain. A block is a data structure that consists of a block number also known as an index, a timestamp, a previous hash, hash, and data.
Common attributes of a block
- A block number is a unique number that identifies a block.
- A timestamp is the date and time when the block was created.
- Previous hash is the hash of the previous block. For the first block, the previous has is empty.
- A hash is the unique encrypted hash of the current block and its content including block number, nonce, and data and is used to validate a block.
- Data part of a block a transaction or list of transactions.
- A nonce is a random number that is used to create a signed block.
In code, a block is a data structure and can easily be represented by a structure or a class. Listing 1 is an example of the Block class with its properties.
- public class Block
- {
- public int Index { get; set; }
- public DateTime Timestamp { get; set; }
- public string PreviousHash { get; set; }
- public string Hash { get; set; }
- public string Data { get; set; }
- }
A block can store any kind of data you with to store on the blockchain.
A genesis block is the first block (block number 0) in a blockchain. This is the only block in a blockchain that does not have a valid reference to a previous block and does not have any transactions.