Blockchain layers — What are they?
Tags: blockchain, web3, beginners, layer
Published: 2022-10-05 13:08:01

After reading a little more about blockchain, I’ve come to the conclusion it’s pretty similar to an onion. Hear me out, it has layers, it’s smelly & makes you cry (probably but don’t quote me on the last two).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6k0lbkk8mdqpiizg3tq.png)

---

**What are the layers and what does each one do?**

The multiple layers of blockchain are broken down into;

-     Hardware/Infrastructure Layer
-     Data Layer
-     Network Layer
-     Consensus Layer
-     Application and Presentation Layer


![The various layers that make up the blockchain.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adiy29gdb3i09wdww8as.png)


**Hardware/Infrastructure Layer**

Somewhere in the world the blockchains content is stored & clients can request content or data from servers via the web and apps — this is called client-server architecture.

Clients can also connect with peers and share data — this is called a peer to peer (P2P) network, essentially a big group of computers that share data.

Blockchain is a peer to peer network, and each computer in this network is called a node. This network has a shared ledger which validates & records transactions. Due to the way peer to peer networks work, the data is distributed between nodes which creates a distributed database.


![Client-server model vs Peer-to-peer (P2P) model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/byeovj9dgy3zs9qt13zs.jpeg)

**Data Layer**

The data structure of blockchain consists of ordered transactions, which can be expressed as a linked list of blocks. A linked list is a list which chains together items within that list. Each item consists of pointers which reference the previous item in the list and data.

Blockchain transactions are digitally signed, which helps to protect the security and integrity of the data contained within the blockchain. The digital signature ensures unity, detects information manipulation and along with encryption of the data, any manipulation will render the digital signature invalid. The owner/sender’s identity is protected by a digital signature, therefore, a signature is legally associated to its owner and cannot be ignored.


![Linked list connection between blocks in blockchain.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zb8e8nsykwsoh947lrp.png)


**Network Layer**

The network layer is also known as the peer to peer layer or the propagation layer. Blockchains operate over a peer-to-peer network. Peers share information about the state of the network. Privacy and security is included in the network layer. It’s responsibilities include;

- Inter-node communications
-     Discovery
-     Transactions
-     Block propagation

This layer makes sure that nodes can find & interact with each other and synchronise in order to keep the blockchain network in the correct state.


![A P2P network graphic.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zv9899y36c17yxhmjyb2.png)


**Consensus Layer**

The consensus layer perhaps the most critical layer & is essential for blockchain platforms to exist. This layer validates the blocks, orders them and ensures everyone agrees.

Read more about consensus mechanisms here on [Ethereum.org](https://ethereum.org/en/developers/docs/consensus-mechanisms/).


![Consensus mechanism graphic.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vh4f2iw7bzrb48vnbnnu.png)

**Application and Presentation Layer.**

The application layer is made up of decentralised applications (Dapps), Decentralized Autonomous Organizations (DAO), chain code and smart contracts. The protocols in the application layer are subdivided into application and execution layers

The application layer hosts the programs that end users interact with to communicate on the blockchain network. User interfaces, scripts, frameworks and API’s are all a part of this layer.

The transactions will then move from the application layer to the execution layer to be validated and executed. The application will hand instructions over to the execution layer, which in turn will execute the transaction and ensures the deterministic behaviour of the blockchain.

---

Now hopefully you’ll agree with me in the fact blockchains are like onions, at least the layers part of it, and also have a (slightly) better understanding of what each blockchain layer is doing.