Introduction to Zecrey Layer 2 Protocol

Zecrey Protocol
7 min readMar 28, 2022

--

ZK-Rollup is an L2 scaling solution in which all funds are held by a smart contract on the main chain, while it performs computation and storage off-chain where ZK-proofs ensure the validity of computation.

By Joseph NKOU, Zecrey Team.

Introduction

This article presents What is a Layer 2 Blockchain, an overview of the implementation of Zecrey’s L2 protocol and the various functionalities enabled by Zecrey L2 protocol.

What is a Layer 2 Blockchain, and what does it mean?

Why do we need a Layer 2 protocol?

According to Vitalik Buterin, there exists a trilemma where no blockchain can achieve decentralization, security and scalability at the same time. Well-known blockchains such as Ethereum compromises scalability for security and Bitcoin loses out on scalability for decentralization. This results in Bitcoin being able to roughly handle only 7 transactions per second (TPS) in contrast with Visa’s payment system which scales up to 24,000 TPS.

Layer 2 protocols, among several solutions, is an effective way to resolve throughput and scalability issues.

What is an L2 protocol?

While layer 1 (L1) refers to the blockchain system itself, layer 2 (L2) on the other hand, refers to a secondary framework or protocol that is built on top of an existing blockchain system (L1), in order to solve throughput and scalability issues.

Types of L2 protocols

There exist many types of L2 protocols, among which Nested, Channels, Sidechains, and Rollups.

L2 protocols that conduct computations outside of L1 are known as rollups. Rollups will send a record of transactions to L1 at regular intervals to update the blockchain.

Rollups run data transactions without relying on L1, resulting in higher throughput and lower gas costs. The security of rollups is ensured by posting transaction data on the main layer (L1).

There exist two types of rollup solutions: Optimistic and Zero-knowledge (ZK).

Zecrey’s implementation of L2 protocol

Zecrey Layer 2 protocol is a turn-key solution for cross-chain and privacy enabled by ZK-Rollup. ZK-Rollup is an L2 scaling protocol in which all funds are held by a smart contract on the main chain, while it performs computation and storage off-chain where ZK-proofs ensure the validity of computation. While providing transaction privacy, ZK-Rollup significantly reduces handling fees and improves performance. Zecrey handles transaction states on L2 and updates the same final state on each L1. The state updates are maintained by ZK-Rollup, resulting in the same level of decentralization and security with L1. Zecrey also adopts an account-based model, which provides programmability and flexibility for both users and developers.

Zecrey L2 Protocol

L2 Account Activation

What is Zecrey L2 wallet address?

It’s a short domain address with zecrey suffix. Example: joseph.zecrey. It is has to be unique in the system. Before performing any operation with Zecrey L2 protocol, the L2 wallet address has to be activated.

How to activate L2 account?

1. Launch Zecrey Wallet from the browser’s toolbar (If it is not launched).
2. Click on Zecrey logo in the lower right corner to activate the L2 account.
3. Click on Register and enter a short account name.
4. Click on Deposit Now directly during the activation process according to the wizard, or choose to deposit in the new L1 account.

Important Notice:

1- You may switch between L1 and L2 accounts after the L2 account is activated.
2- You need to deposit assets on L2, before you can activate your L2 account.
3- All transactions in L2 are encrypted, which makes them private. That is one of the core functions of the Zecrey Protocol.

Zecrey L2 protocol gives you the ability to: transfer, swap, add/remove liquidity and under privacy protection.

L2 Transfer

What’s the difference between L1 and L2 transfers?

How to perform transfers in L2?

1- Click on Transfer to select a token
2- Choose one or more receivers for the transaction
3- Input the respective L2 addresses and corresponding amounts
4- Add a transfer memo (Optional)
5- Check the gas fee
6- Click on Confirm to confirm the transaction

Important Notice:

1- The One-to-many functionality developed by Zecrey team provides you with a very efficient way of transferring assets to many L2 addresses in just one transaction.

2- The gas fee (transaction fee) involved in L2 transfers utilizes the token you are transferring

Swap

Why is the swap price in L2 different from the market price?

The swap of L2 is determined based on an AMM (Automatic Market Maker) based DEX (Decentralized Exchange). Its exchange rate mainly depends on the amount of fund in the token pool in the smart contract of the system. Due to the insufficient depth of the token pool during the test period, there are certain discrepancies between the swap price and the real market price. This will be resolved as we add liquidity after the launch of our L2 mainnet.

How to Swap in L2?

1- Click on Swap and select a token pair you wish to exchange
2- Enter the amount and choose one token for gas fee
3- Click on Swap to get the witness
4- Click on Confirm

Important Notice:

1- All tokens on L2 can be used as Swap gas fees: REY, ETH, MATIC, NEAR, etc.

2- If you choose REY as gas fee, you will get a 20 percent discount.

Add Liquidity

What is Add Liquidity?

The liquidity pool is a pool of tokens locked in a smart contract to increase market liquidity among traders. A liquidity pool has two kinds of tokens, that constitute a trading pair. When a new liquidity pool is created, the first liquidity provider (LP) will set the initial price in the pool.The LP is incentivised to keep the exchange ratio of the two assets close to the market price. LP will receive tokens as a reward for providing funds and liquidity to the liquidity pool.

How to add liquidity?

1- Click on Swap
2- Click on Add Liquidity
3- Click on Add Liquidity and select a token pair
4- Enter the amount you wish and the system will match the token ratio automatically
5- Select a token for gas fee
6- Click on Confirm to confirm the transaction

Remove Liquidity

1- Click on Swap
2- Click on Add Liquidity, and click the clock-like button in the upper right corner to view liquidity.
3- Click on Detail to select the liquidity pair to remove.
4- Click on Remove
5- Click on Confirm to confirm the transaction

Important Notice:

1- You may choose different tokens as gas fee.
2- You may choose the proportion of liquidity to burn and the system will match the amount automatically.
3- The actual amount of assets you got depends on the current pool liquidity pair ratio.

Unlock Assets

What is Unlock Assets?
Unlocking means granting permission to spend assets through smart contracts, which is the opposite process of locking. Unlocked assets and rewards will be sent to the users’ L2 accounts and become available for use.

How to Unlock Assets?

1- Click on Unlock to select an asset.
2- Click on Detail to select the locked assets
3- Click on Unlock
4- Click on Confirm

Important Notice:

1- You may also choose different supported tokens as gas fee.
2- The reward will be supported in the future.

Withdraw

What does it mean to withdraw?
Withdraw is to take assets back to L1 wallet address supported by Zecrey, which is part of cross chain. It is a cross-chain operation that consists of taking assets back to an L1 wallet supported by Zecrey.

How to withdraw?

1- Click on Withdraw
2- Select a token
3- Input the amount, L1 address and the fee
4- Click on Withdraw
5- Click on Confirm

Important Notice:

1- Witness generation and transaction confirmation might take a few seconds.
2- The availability of funds to the entered L1 address might require a few minutes.
3- The amount you want to withdraw cannot exceed the current balance of certain public chains.
4- The gas fee is 0.1% of the amount of token you withdraw to L1.

Summary

Zecrey L2 protocol is based on ZK-Rollup protocol and it enables scalability, privacy and cross-chain transactions. This significantly reduces gas fees and improves performance. To be able to use the L2 protocol functions, one has to activate an L2 account and deposit funds. The user can then have the ability to transfer assets, perform swaps, add/remove liquidity under a built-in privacy protection.

--

--