This article compares the transaction costs of the four major Layer 2 solutions
Author: Xiang|W3.Hitchhiker
Revised: Marina, Evelyn | W3. Hitchhiker

Author: Xiang|W3.Hitchhiker
Revised: Marina, Evelyn | W3. Hitchhiker
With the rise of Ethereum, we have seen the rapid development of decentralized finance (DeFi) and now the explosion of non-fungible tokens (NFT). However, Ethereum can only process less than 20 transactions per second (TPS), and the gas fee has risen sharply due to the congestion of the Ethereum network. Higher throughput and cheaper fees will undoubtedly be required before these networks can be effectively adopted more widely. But the expansion of ETH 2.0 will take time. In the short to medium term, Layer 2 solutions can solve the inefficiencies faced by the main network, while still maintaining the integrity of the Ethereum blockchain.
Layer 2 deserves attention for the following reasons:
The Layer 2 network will be faster and cheaper, allowing more users to enter the Ethereum ecosystem;
Participate in the incentives of the Layer 2 network in advance and get rewards;
Therefore, Layer 2 is also one of the most important things to watch this year. For users, in addition to experience comfort, the most concerned thing is transaction costs. This article starts by comparing the transaction costs of various Layer 2 solutions, so that readers can more clearly understand the advantages and disadvantages of each solution.
1. Layer-2 expansion technology
1. Layer 2 expansion technology

2. The gas-cost of each solution

2. Gas cost of each solution
image description
[The premise of the above calculation is that the current Eth price is 2500u, the block gas limit is 30000000, the gas fee is 30Gwei, and the average block generation time is 13 seconds. The limit TPS means that the corresponding operating environment occupies all the Ethereum block space (in the proof verification It costs 500,000 gas), and ordinary TPS means that the corresponding operating environment occupies 1/3 of the block space of all Ethereum. 】

️-Calculation method
▶️ Calculation method
As shown in the figure above, ordinary transfer eth needs about 112 bytes, ZK compression is 12 bytes, and op system compression is 78.4 (not fixed, assuming 30% of the space is compressed), assuming that swap transfer requires about 180 bytes, ZK is compressed to 14 bytes, and op is compressed to 126 bytes.On the existing Ethereum chain, the upper limit of gas is 30 million, and each non-zero-byte calldata data in a transaction requires 16 gas, and 0-byte requires 4 gas. If ZK occupies all the block space of Ethereum (500k gas is spent on proof verification), the number of 0 bytes is ignored.Then the batch could have (29.5 million / 16) = 1,843,750 bytes of data. As shown above, the ETH transfer summary for each user operation requires only 12 bytes, which means that the batch can contain up to 153,645 transactions.
in 13 seconds
At an average block time of , this translates to ~11,818 TPS (compared to 13 million / 21000 / 13 ~= 101 TPS for ETH transfers directly on Ethereum itself).
It can be seen from the above that the scalability of ZK Rollup transfer eth has increased by 100 + times, and the biggest advantage of zk is not in transferring eth. Compared with transferring erc20 contract tokens, the gaslimit consumed by the main network is more than that of uniswap transactions. The cost performance of ZK Rollup compression is also higher. Compared with the uniswap transaction expansion of the main network, ZK Rollup can increase by 400+ times.
Note: EIP-4488 and EIP-4844 will greatly reduce the cost of rollup.
1. The transaction fee of zk-rollup
1. Transaction fees of ZK RollupIn zkSync, the cost per transaction has two components:
Off-chain part (storage + prover cost):
The cost of state storage and SNARK (zero-knowledge proof) generation.(This is partly dependent on hardware resource usage and thus constant. Our benchmark estimates ~$0.001 per transfer.)
On-chain part (gas cost):

For each zkSync block, the verifier must pay Ethereum gas to verify the SNARK, and an additional payment of about 0.4k gas per transaction to publish the state ∆.
(The on-chain part is a variable depending on the current gas price in the Ethereum network. However, this part is orders of magnitude cheaper than the cost of a normal ETH/ERC20 transfer.)
(1) Floor price of transaction fees

The transaction floor price of ZK rollup depends on the gas cost of the eth main network.
On-chain gas fee = price per wei * transaction size * gas fee * token risk factorIs ZK Rollup the more you use, the lower the cost? OP, AR has a mechanism like this? The user's state number is updated, the more the user uses, the Gas fee paid by ZK to layer1 will be relatively less, but it is not shared equally among the users.
Off-chain part:
The cost of SNARK (zero-knowledge proof) generation. This part depends on the usage of hardware resources and thus is constant. Our estimated base per transfer is about $0.001.
Actual size = (zkp_cost_chunk * op_chunks) * token_usd_risk;
Off-chain gas cost for normal transactions = 0.001 * 2 * 1 = 0.002u
The off-chain gas cost of the transaction receiver being the new address = 0.001 * 6 * 1 = 0.006u




Off-chain gas cost of swap = 0.001 * 5 * 1 = 0.005u▶️ The verification process refers to the following code block:
On-chain part (gas cost):
For each zkSync block, the validator must pay Ethereum gas to verify the SNARK, and additionally pay about 0.4k gas per transaction to publish the state. The on-chain part is a variable that depends on the current gas price in the Ethereum network. However, this part is orders of magnitude cheaper than the cost of a normal ETH/ERC20 transfer.
= wei_price_usd*gas_tx_amount*scale_gas_price*token_usd_riskActual size = price per wei * transaction size * gas fee * current gas price * token
risk factor
Suppose the price of ETH is 2500u and the current gas price is 30GweiOn-chain gas cost of normal transactions = 2500/10^18*(0+300+2002)(30*10^9)1.31 = 0.068u
The on-chain gas cost of the transaction recipient being the new address = 2500/10^18*(0+940+2006) (30*10^9)1.31 = 0.20865u
Suppose the eth price is 2500u and the current gas price is 30Gwei▶️
On-chain gas cost of normal transactions = 2500/10^18*(0+300+200*2)* (30*10^9)*1.3*1 = 0.068u
The on-chain gas cost of the transaction recipient being the new address = 2500/10^18*(0+940+200*6)* (30*10^9)*1.3*1 = 0.20865u
Gas_tx_amount of swap = on-chain verification cost + submission cost + Chunk * Swap Chunk parameter (0 + 710 + 200*5)











On-chain cost of swap = 2500/(10^18)*(0+710+200*5)* (30*10^9)*1.3*1 = 0.1667u
▶️ The verification process is as follows:
Total cost = on-chain + off-chain
Total common transaction cost = 0.002 + 0.068 = 0.07 u
total swap cost = 0.005 + 0.1667 = 0.1672u
(2) Factors affecting the floor price
(2) Factors affecting the floor price
The EIP related to the gas of ETH in the draft stage is mainly EIP4488. This solution reduces the non-zero byte data of calldata from 16 gas to 3 gas, which has a great impact on layer2 TPS. It is good for layer2 Rollup and can greatly reduce the cost of Rollup mainnet. Transaction costs, non-zero byte data can be reduced to less than 1/5 of the current cost, and 0 byte data can also be slightly reduced (ab, op, zk, etc. are expected to be reduced to 1/5 of the current handling fee) .
(3) Fee payment method
Transfers in zkSync naturally support "gasless transactions": users pay transaction fees in the tokens being transferred. So, for example, if you want to trade the DAI stablecoin, you don't need to own ETH or any other token. Just pay a fraction of the fee in DAI.
2. The transaction fee of zkporter
At present, there is no zkPorter-related code on github. Since zkPorter does not require data availability on the chain, it is expected that the cost will be greatly reduced.

existzkSync 2.0Primarily off-chain costs, transactions can be controlled at a constant fee of 1 to 3 cents. Quoted from official documentation.

exist
In , the L2 state will be divided into 2 aspects: ZK Rollup with on-chain data availability and zkPorter with off-chain data availability.
These two parts will be composable and interoperable: contracts and accounts on the ZK Rollup side will be able to seamlessly interact with accounts on the zkPorter side.
From a user perspective, the only noticeable difference is the 100x reduction in fees for zkPorter accounts.
Imagine the application scenario: Uniswap deploys their smart contracts on the ZK Rollup side, and zkPorter accounts can be swapped at a fee of less than $0.03. A zkPorter account can make thousands of swaps on the Uniswap contract, but only need to post a single update to Ethereum.
zksync20 mainnet launch time
according tozksync2.0 mainnet launch timeaccording to

It can be known from the content that within 6 months, zkPorter will launch the mainnet together with zksync2.0.
3. Arbitrum-gas-mechanism

3. Arbitrum Gas mechanism





▶️ Part of the code:
4. Optimism-gas-mechanism
There are two sources of cost in optimism transactions: L2 execution fees and L1 data/security fees.
(1) l2-execution fee
(1) L2 Execution Fee
l2_execution_fee = transaction_gas_price * l2_gas_used
Just like on Ethereum, transactions on Optimism must pay gas for the amount of computation and storage they use. Every L2 transaction pays an execution fee equal to the amount of gas used by the transaction multiplied by the gas price attached to the transaction. This is also how fees are charged in Ethereum.
The amount of L2 gas used depends on the particular transaction you are trying to send, transactions typically use about the same amount of gas on Optimism as they do on Ethereum.
(2) l1-data fee
(2) L1 data fee
Optimism is different from Ethereum because all transactions on Optimism are also published to Ethereum. This step is critical to Optimism's security properties, as it means that all data needed to sync Optimism nodes is always publicly available on Ethereum. This is what makes Optimism an L2.
Users on Optimism have to pay a fee for submitting transactions to Ethereum. Call it the L1 data fee, and it's the main difference between Optimism (and other L2s) and Ethereum. Since gas is very expensive on Ethereum, L1 data fees often dominate the total cost of a transaction on Optimism. This fee is based on four factors:
Ethereum's current gas price.
The gas cost of publishing a transaction to Ethereum. This transaction length is proportional to the size (in bytes).
formula:
L1_data_fee = L1_gas_price * (tx_data_gas + fixed_overhead) * dynamic_overhead
3. Summary
3. Summary
3. Summary
As more and more applications are connected to the blockchain, user adoption and transaction volume will grow exponentially. From DeFi, NFT to DAO, they will eventually consume more throughput and generate more transaction costs on Ethereum, making it less enjoyable to use, thus hindering the opportunity for blockchain to expand to a larger population.


