Choosing the right scaling solution for your dApp can significantly reduce costs and transaction times using ZK-rollups. We’ll explain what ZK-rollups are, how they differ from other Layer 2 solutions, and how ZK technology works.
There are many Ethereum scaling solution choices for Web3 developers when it comes to picking one. Layer 1 improvements like Ethereum 2.0, Layer 2 chains like Optimism and Arbitrum, and side chains like Polygon or xDai are all available.
Web3 developers have three choices within the Layer 2 Ethereum scaling solution category: state channels, optimistic rollups, or zero-knowledge (ZK) rollups.
ZK-rollups are an Ethereum scaling solution that is growing in popularity and has the potential to significantly decrease costs and transaction time. We will describe the advantages of ZK-rollups compared to other Layer 2 solutions, as well as discuss the ZK technology in depth.
What are the Ethereum Layer 2s?
An Ethereum Layer 2 is a blockchain that is cheaper and quicker than Ethereum’s main chain, while maintaining the same level of security. Layer 2s are geared towards diminishing the high fees and sluggish performance that are typical on Ethereum when network usage is high (Mansouri, 2019).
In general, layer 2 solutions process transactions “off-chain,” not on Ethereum, and batch them into a simpler, cheaper transaction that is published on the Ethereum blockchain.
However, the ways Layer 2 scaling solutions securely process, batch, and post off-chain transactions to Ethereum are dependent on the scaling technology they employ.
Let’s examine the three different types of Layer 2 scaling solutions.
Are there different types of Ethereum Layer 2s, and what are they?
State channels, optimistic rollups, and zero-knowledge rollups are three Ethereum Layer 2s that help solve Ethereum’s scalability issue.
Let’s look at the different types of Layer 2 solutions.
State channels are a scaling solution for Ethereum that allows users to make an unlimited number of off-chain transactions while only having to post two transactions to the Ethereum network: the initial transaction and the last one.
It is quite simple:
Here’s how it works:
- The first transaction opens a state channel and “locks” that state.
- Users perform transactions off-chain.
- The remaining state after off-chain transactions are complete is recorded in a second transaction that “closes” the state channel.
Examples of Ethereum L2s that leverage state channels include:
- Connext – a network for fast, trustless, cross-chain applications and communication
- Kchannels – offers a trust-minimized payment channel for Ethereum
- Perun – offers user an off-chain framework that supports real-time payments
- Radien – offers a fast, cheap way to transfer ERC20 tokens
Processing a large volume of transactions, handling computation off-chain, and “rolling” them up in a simpler transaction that gets published to Ethereum’s execution layer is what an optimistic rollup involves.
An optimistic rollup is said to be optimistic because transactions are assumed to be valid until proven false.
An invalid transaction can be disputed by submitting a fraud proof before optimistic rollup transactions are confirmed on Ethereum’s main chain.
All remaining transactions are confirmed onto Ethereum once the fraud proof’s dispute period is over.
Optimistic Layer 2s are designed to utilise fraud proofs, which means that transaction confirmation times are likely to be longer than with solutions such as Zero-Knowledge rollups.
Examples of Ethereum L2s that leverage optimistic rollups include:
- Arbitrum – the largest optimistic rollup by TVL ($3.2B) and market share (54.7%)*
- Metis – third largest optimistic rollup by TVL ($457M) and market share (7.84%)*
- Optimism – 2nd largest optimistic rollup by TVL ($465M) and market share (7.97%)*
- Boba Network – 4th largest optimistic rollup by TVL ($187M) and market share (3.22%)*
*Layer 2 TVL and market share data provided by L2Beat.
ZK-rollups are similar to optimistic rollups in that they combine a large number of Layer 2 transactions that were executed off-chain and submit them as one transaction onto Ethereum.
ZK-rollups, on the other hand, verify transaction validity instantly rather than assuming them to be valid until proven otherwise.
ZK-rollups are more difficult to develop than optimistic rollups because of the technology’s complexity and its ability to execute arbitrary code. When evaluating whether to build on a ZK-rollup Layer 2 blockchain versus another EVM-compatible blockchain, this is something to keep in mind.
Examples of Ethereum L2s that leverage ZK-rollups include:
- Starknet – used by dYdX and ImmutableX the leading decentralized exchange for perpetual contracts on Ethereum
- zkSync – used by dApps like Yearn Finance, FRAX, and Zerion
How are ZK-rollups implemented?
The concept behind ZK-rollups is difficult to grasp without first understanding zero-knowledge proofs (ZKPs).
Having knowledge and proving it without revealing the actual knowledge is what ZKPs are all about.
With regards to the recently popular Wordle game, I can verify that I have the answer without divulging it by sending a picture of my final board. With no prior knowledge of the correct solution, anyone may agree that I have got it right. This is the significance of a ZKP.
Off-chain Layer 2 transactions are aggregated into one Ethereum mainnet-mined transaction to create ZK-rollups.
A single transaction can be used to process 100s of transactions at once.
A single transaction forms a validity proof, which is a non-interactive, succinct argument for knowledge (SNARK) or an argument for transparent knowledge (STARK).
A cryptographic transaction hash can be used to represent the components of an Ethereum transaction, without revealing the transaction data, as shown in the example below. Even though there are many components to a typical Ethereum transaction, they can all be represented in a unique transaction hash without revealing the transaction data. SNARKs and STARKs are the same concept.
Mining just one transaction as opposed to hundreds of Ethereum transactions is what makes ZK-rollups significantly cheaper than using Ethereum’s Layer 1 chain.
An on-chain verification of ZK-SNARKs sent to Ethereum is different from optimistic rollups, which force transactions to wait for fraud proofs. A receiving smart contract can instantly verify if the proof is valid or not.
Because ZK-SNARKs are verified instantly, funds are able to be withdrawn on ZK-rollups as soon as the ZK-SNARK transaction is mined on Ethereum (~12 seconds), rather than waiting days or weeks for the dispute period to end.
Unlike optimistic rollups, ZK-rollups prevent fraud without manual intervention or verification, making transaction confirmation much faster and scalable.
Zookram is the ultimate guide to learning web3 + crypto. We cover everything you need to know, from how to buy each cryptocurrency to how to mint NFTs.