In the following series of posts we are going to introduce technologies that we currently implement in our project. The first post is about Layer 2 blockchain technology.
What is Layer 2 blockchain technology?
Blockchain usually consists of several layers. Layer 1 is the root chain or the base layer. On this layer all the operations are processed, and the data is stored. Layer 2 is an off-chain solution that is built on top of the Layer 1. It is added to “on-chain” base and relies on it for security and finality.
Why is Level 2 an absolutely indispensable addition to Level 1?
Layer 1 alone cannot satisfy high data processing needs. It faces scalability problem and challenges cost effectiveness of operations.
Scalability problem implies that Layer 1 can facilitate only small amount of transactions per second (tps). For example, Bitcoin can handle over only about 5,68 tps, whereas VISA can process 24,000 tps.
In addition, transaction fees are relatively high. In October 2018 the average Bitcoin transaction fee is 0,7$ per transaction (bitcoinfees.info).
Level 2 is a promising solution that deals with both problems still retaining decentralization and ensuring security.
How does Level 2 work?
Layer 2 consists of protocols that employ smart contracts through which users interact with each other off-chain. By running transactions off-chain, Layer 2 cuts down data processing on the blockchain. In other words, this technology enables to offload transactions from the main chain (Layer 1) onto its extension (Layer 2).
As a result, Level 2 decreases the amount of data storage on the root chain, and free up resources on Level 1. Thus, Level 2 helps to scale Level 1, making it possible to meet high processing needs and increasing its transaction output.
How does Level 2 ensure security of funds?
Level 2 relies on Level 1 for security through the system of smart contracts. Level 2 is designed to regularly communicate with the root chain by smart contracts, on which users submit information about transactions.
For example, users submit cryptocurrency into Layer 1 smart contracts. If User 1 tries to cheat User 2, the information about his or her fraudulent actions are submitted from Layer 2 to the smart contract in Level 1. After checking this information, Level 1 might punish User 1 by locking his deposit or awarding it to User 2.
How do we employ Layer 2 technology in our project?
We use Lightning Network (LN) payment channels with multichain compatibility as Layer 2 technology.
Depositing cryptocurrency in our exchange, user falls into smart contracts that for the movement of funds need only user’s signature.
When user moves funds into the trading account, they become “staked” or fixed. It means that user can proceed to trade limitlessly and commission-free through LN channels.
When user withdraws the funds from the trading account, we check his balance to confirm the exact end of trading activity. Then we move these funds onto user’s secure EOS account from which user can withdraw.
As a result, user stakes funds and then trades million transactions going from one crypto to another, and at the end withdraw the results of trading actions. During this process only two transaction fees are spent: for staking and withdrawing.
Why do we employ LN payment channels as off-chain solution?
LN payment channels enable us to create a safe decentralized exchange (DEX) with the transaction speed and usability of Binance. Besides, this technology allows us to provide a wide range of trading options, including HFT, Margin Trading and others.