If you are deep in Crypto Twitter, you must have already heard of blockchain layers. Well, what most do not know is that these layers are similar to how Web2 projects are built on web stacks - but Web3 still offers a whole new dimension by instigating decentralization.
Reading this article will allow you to visualize how decentralized applications are built from the bottom-up and how each layer interacts with another.
Layer 0 is the blockchain architecture piece where the hardware and infrastructure exists as the foundation of everything to be built on top. On this layer nodes, operating systems, and physical devices are storing and exchanging data, mining tokens, and building the distributed ledger that blockchains are known for.
It has two primary functions - peer-to-peer internet overlay protocols, and providing a platform neutral language which basically translates to sharing security, communication across nodes, and unifying computing languages.
Despite this layer being somewhat less popular, there are already many projects that function as Layer 0s. These include Polkadot and Cosmos.
Without this layer, blockchains won’t exist. A huge part of Layer 1s’ job is to run its consensus mechanisms, which is a set of rules that a blockchain uses in order to determine who gets to produce a new block and whether a transaction is valid or not. The efficiency of this mechanism determines the congestion of the network or how long the “queue” is going to be. The mechanism also answers how each transaction is processed in a blockchain.
Speed, however, is not the only factor that is integral in Layer 1s. Several Layer 1s are competing with each other over the three factors in the Blockchain Trilemma, i.e., Scalability, Security & Decentralization. As no blockchain is able to successfully optimize these three key features, Layer 2s have emerged to mitigate the issues.
Popular Layer 1s include Ethereum, Fantom, Bitcoin, Avalanche, and Binance Smart Chain.
It enhances Layer 1s in the aspects they fall short of by providing utilities through oracles, scaling solutions, protocols, computation, and many more. Layer 2s may also be in charge of validating transactions, lifting a huge workload from its affiliated Layer 1. Nevertheless, the creation of blocks is still managed by Layer 1s.
Some Layer 2s also make use of off-chain scaling solutions wherein transactions are batch-processed outside the blockchain before submitting it to the blockchain thereafter. While this reduces security and decentralization, it improves scalability.
Popular Layer 2s include Bitcoin’s Lightning Network and Ethereum’s Plasma.
Developers use special development platforms, runtime environments and code libraries that are in this layer in order to build decentralized applications and smart contracts. Programming languages may differ across networks. For example, Solidity and Vyper for Ethereum, Plutus for Cardano, and Rust for Substrate.
Layer 4 includes the browser, the application hosting services, and the decentralized applications. This layer allows general users to interact with blockchains via a special protocol-extensible user-interface cradle browser or app allowing the user to use decentralized applications, execute transactions, as well as accept and reject transactions. A very common example of this browser is Metamask.