What is it in simple words ? Blockchain is a virtual ledger, where each record of this is a block. That records are distributed in a network for everybody, where them can read and write, but not change the information of it. To understand this better, let's get to know what is a block and what is inside of it, and then how a block connects with other block. For this explanation, I'm going to explain blockchain based in the bitcoin implementation.

Anatomy of a block Each block contains a header and a body.

Block

These are the data that each block have. Besides that, every block has a max size in bytes that is defined by the developer. When this max size is reached, this block is added to the blockchain and a new one starts to be created. I'll explain each of those items below.

Block Number Every block in a blockchain have a number that represents your position in the chain. The 1st block added to the chain has a special name, they are called genesis block.

PrevBlockHash Every block have in the header a reference of the previous block hash number. This is really important, because this is how the blockchain keeps consistent and control the immutability. The genesis block, doesn't have nothing that refers a previous block, since it is the first block.

MerkleRoot The merkleRoot is the hashing result of all transactions inside the block. If anything is changed inside the block, this hash also changes and invalidate the changed block and the next ones also. Now you can wonder: why this field is called MerkleRoot instead of blockHash ? This is because Bitcoin uses the Merkle Tree to generate the hash from block's data.

Nonce This is a 32-bit number that is related with the mining process of a block. This number is used only once to find a hash that matches the difficulty of the blockchain. I'm going to write about mining later and hopefully this will be more clear for you.

CreationTimestamp This is the timestamp of the block creation.

Data Here is where all the transactions data remains.

Hashing I've talked a lot about hashing, right? What kind of hashing algorithm is used here? That's really depends of each implementation of the blockchain, but for the cases that I talked here this should be a One-Way hashing algorithm. Bitcoin uses the SHA-256 (Secure Hash Algorithm) with 256-bit length. If you want to read more about: SHA-2

Now that we know what is inside a block and what type of hashing is used, let's show how is it inside a blockchain.

Blockchain Here is where we will have our blocks linked together by the prevBlockHash as you can see below.

Blockchain

The merkleRoot value is generated from the Data information, and if anything changes in there, the merkleRoot will change too and the rest of the blocks that was linking the prevBlockHash after the changed block won't be valid anymore. That's why the blockchain is immutable.

Built With

Share this project:

Updates

Submission history