The second layer (or Layer 2 refers to the secondary layer or protocol that is build on top of a blockchain. These are designed to enhance the scaling of the ecosystem far above what can occur at the base layer. Blockchains tend to be limited in the number of transactions they can process. There are also memory concerns since individuals nodes have limitations there.
An example is Lightning Network, which is a Layer 2 solution for Bitcoin, enabling fast and less expensive transactions. Under this system, transactions are batched on the second layer and then posted to the blockchain.
This is a fairly straightforward payment system. Many question the ultimate viability since node operators are not incentivized. There is also the question of eventual centralization.
The base layer versus layer 2 debate really gets involved when discussing smart contracts. Ethereum was the first widespread chain to employ smart contracts. These were programmed into the base layer. For this reason, each node runs every contract.
Some things immediately stand out.
The first is that all nodes running the contracts are going to experience limitation at some point. If these contracts run into the hundreds of millions, that is going to be a lot of data to store.
A benefit to blockchain is that the code is housed on many servers around the world, meaning that nobody is in control of the network. If the servers are uncorrelated, we have a decentralized system.
Run base layer code that provides functionality to the network is important. We also know that decentralized ledgers, especially when tied to cryptocurrency are crucial. This is what separates this from the traditional system where banks are the ones who operate the ledgers.
The benefit of having smart contracts at the base layer is the fact the trust in the network extends to the contract. With the node operators being the same, there is no additional counterparty risk. This is not the case with a sidechain. Under that scenario, we have to ensure the node operators on that system are trustworthy and not increasing the risk we are undertaking.
The most famous smart contract hack is still pointed to as a reason to move these to the second layer.
June 17, 2016, a hacker was able to exploit the code to steal ETH valued at $70 million. This was done through the entry of a project called The DAO.
This was a decentralized venture capital fund for the cryptocurrency and decentralized technology industries. The Decentralized Autonomous Organization was to use its decentralized architecture to cut expenses while giving investors more power and access. The DAO was designed to run decentralized, relying on the collective judgment of its investors.
In contract, Ethereum Classic maintained the old chain that was altered by the Ethereum Foundation. This took the symbol ETC.
Layer 2 can encompass a variety of things. We can see applications that are tied to blockchains operating on the second layer. There are also protocols built.
A network, or sidechain, can be constructed either as decentralized or centralized. There is nothing that says the goal of a sidechain is decentralization. They can mirror the base layer in the server design or adopt something completely different.
In addition to scaling, Layer 2 solutions can be implemented for:
Due to limitations with many blockchain databases, auxiliary repositories are required. Bitcoin, for example, is distributed ledger technology (DLT). This is consistent with blockchains. However, in this instance, the data is limited to a financial ledger similar to a bank. This will show debits and credits in the different wallets.
If, however, different types of data are to be stored, another layer is required.
Blockchain is designed to be the transaction layer to transfer value. Here is where the medium of exchange typically resides. Layer 2 enables other applications and games to utilize the account system of the base layer along with the monetization that comes from tokenization.