Book a free call

How to Implement a ZK Rollup, Step by Step

Implementing a ZK rollup means choosing a stack, building circuits and testing proofs before mainnet. Here is the sequence teams follow, and the traps to avoid.

Hertiv engineering teamReviewed by a senior engineer
6 min read
How to Implement a ZK Rollup, Step by Step
On this page

Short answer

To implement a ZK rollup, pick a proving stack and settlement chain, define what your rollup does, build and test the circuits, connect data availability, run a testnet under real load, and only then launch on mainnet with an upgrade path. Most of the work sits in the circuits and the testing, not in the deployment itself.

What is a ZK rollup?

A ZK rollup is a layer 2 chain that runs transactions off the main chain and posts a validity proof to it, so the main chain can check the result without re-running every transaction. The proof, built with zero-knowledge cryptography, shows the new state is correct without revealing every detail of the transactions inside it.

The idea is simple: do the heavy work off-chain, prove it on-chain. Users get lower fees and faster confirmations than the main chain offers, while the main chain still guarantees that nobody can publish a false state. The rollup inherits its security from the chain it settles on, which is the point of the design.

Part What it does Where it lives
Sequencer Orders transactions into batches Off-chain server
Prover Builds the validity proof Off-chain compute
Data availability Publishes the batch data Main chain or data layer
Settlement contract Checks proofs, stores state Main chain
Bridge Moves funds in and out Main chain

Rollups come in two broad shapes: general-purpose chains that run smart contracts, and application-specific chains built for one job, such as payments. The implementation steps are similar either way, but the choices inside each step differ, so the first decision is what the rollup is for. If the concept is new, what is a ZK rollup covers the basics first.

What do you need before you start building?

Before you start building, you need a clear answer to four questions: what transactions will the rollup handle, who will run it, what happens when the prover fails, and how users get their funds back. A rollup without an exit path is a trap, not a product.

You also need a team with the right mix: smart contract engineers for the settlement and bridge contracts, cryptography engineers for the circuits and prover, and infrastructure engineers for the sequencer and data pipeline. The cryptography work is the scarcest skill, and it is where most projects underestimate the effort.

Finally, decide the settlement chain and the data availability layer. Settling on a large chain costs more per batch but gives stronger guarantees; a cheaper settlement chain or an off-chain data layer cuts costs and adds trust assumptions. Write these choices down before writing code, because changing them later means rebuilding the circuits. A partner for blockchain development can supply the cryptography skill if your team does not have it in-house.

How do you implement a ZK rollup, step by step?

Implementing a ZK rollup follows a fixed order, and skipping a step usually means redoing it later. The sequence below is the one most teams follow, from the first design choice to a mainnet launch.

  1. Define the transaction types and state model: what users can do, what the state holds, and what a valid transition looks like.
  2. Choose a proving system and a stack, such as a Rust-based prover or an existing rollup framework, and settle the data availability choice.
  3. Write the circuits that prove state transitions, starting with the simplest transaction type and adding the rest one at a time.
  4. Build the settlement and bridge contracts on the main chain, including the verifier, the state commitment and the withdrawal path.
  5. Connect the sequencer, the prover and data availability, then run the whole system on a testnet with real load.
  6. Audit the contracts and the circuits, fix what the audit finds, and launch with an upgrade path and a pause mechanism.

The order matters because each step constrains the next. The circuits decide what the contracts must verify, and the contracts decide what the sequencer must submit. Teams that build the contracts first usually rewrite them once the circuits are done.

How do proofs, data availability and settlement fit together?

Proofs, data availability and settlement are the three parts that make a rollup trustworthy, and each one answers a different question: is the new state correct, can anyone see the data behind it, and where is the result recorded.

Part Question it answers If it fails
Validity proof Is the new state correct? False states could be published
Data availability Can anyone see the batch data? Nobody can rebuild the state
Settlement contract Where is the result recorded? There is no trusted anchor
Bridge Can users get funds out? Funds are locked in the rollup

The common mistake is to treat data availability as a detail. A valid proof over hidden data is useless, because nobody can check what happened or rebuild the state. That is why rollups publish transaction data where anyone can read it, even though it costs more than keeping it private.

Settlement is the anchor. The main chain contract stores the latest state commitment and only accepts it when the proof checks out. Withdrawals go through the bridge contract, which is why the bridge gets the most audit attention: it holds the funds.

How do you test a ZK rollup before launch?

You test a ZK rollup in layers: unit tests for the circuits, integration tests for the sequencer and prover together, and load tests that push the testnet past the volume you expect at launch. A circuit that passes unit tests can still fail when two transaction types interact, which is why integration tests matter most.

Testing should cover the use cases the rollup is built for — ZK rollup use cases shows the common ones — plus the failure cases nobody wants to see.

The testnet should run with real users and real value at stake, even if the value is small. Faucet tokens and friendly testers hide the failure modes that appear when strangers use the system: invalid transactions, stuck withdrawals, and a prover that falls behind under load. Run the testnet until the failure rate is flat, not until the calendar says to launch.

Two checks deserve special attention. First, the withdrawal path: every test user should be able to get funds out through the bridge without help. Second, the upgrade path: practice pausing the rollup and upgrading the contracts, because the first time you do it should not be during a real incident. Testing also reveals the real running cost — ZK rollup cost breaks down the build and running figures.

Example (hypothetical): a payments team ships a testnet rollup

Example (hypothetical): a payments team builds a rollup for small transfers. Each batch holds 1,000 transfers, the prover takes 12 seconds per batch, and the team submits a batch every 10 minutes, which is 6 batches an hour, or 6,000 transfers an hour.

Proving costs about $0.40 per batch in the team's planning figures, which is $0.0004 per transfer, and settlement costs about $0.60 per batch, which is $0.0006 per transfer. The total is about $0.001 per transfer before the sequencer and data availability costs, which the team tracks separately.

The numbers only hold while the prover keeps up. In load testing the team finds the prover falls behind once batches pass 1,400 transfers, so they cap batches at 1,000 and add a second prover before launch. The cap is a design choice, not a failure: a rollup that proves slowly is worse than one that batches less.

What are the common mistakes?

The most common mistakes in ZK rollup implementation are treating the circuits as a detail, skipping the withdrawal test, and launching without an upgrade path.

  • Choosing a proving system before defining the transaction types.
  • Publishing proofs but keeping the transaction data private.
  • Testing only with friendly users and faucet tokens.
  • Auditing the contracts but not the circuits.
  • Launching with no pause mechanism for a real incident.

The fix for most of these is the same: run the testnet until it breaks, fix the break, and run it again. A rollup that has never failed in testing will fail in production, and the cost of that failure is measured in user funds.

Key takeaways

  • A ZK rollup runs transactions off-chain and proves the result on-chain with a validity proof
  • Define the transaction types and state model before choosing a proving system
  • Proofs, data availability and settlement each answer a different trust question
  • Test the withdrawal path and the upgrade path before launch, not after
  • A rollup that has never failed in testing will fail in production

Frequently asked questions

How long does it take to implement a ZK rollup?

A simple application-specific rollup can reach testnet in a few months with a small team that already knows the stack. A general-purpose rollup takes much longer, because the circuits cover more transaction types and the audit is deeper. The cryptography work sets the pace.

Do you need to be a cryptographer to build one?

You need at least one person who understands the proving system and the circuits, but the rest of the team can be ordinary smart contract and infrastructure engineers. Existing rollup frameworks handle much of the plumbing, so the scarce skill is circuit design, not everything.

What is the difference between a ZK rollup and an optimistic rollup?

A ZK rollup posts a validity proof that the main chain checks at once, so withdrawals are fast. An optimistic rollup posts no proof and waits for a challenge period, so withdrawals take days. ZK rollups cost more to prove; optimistic rollups cost more in waiting time.

Can a ZK rollup keep transaction data private?

The proof can hide transaction details, but the data still needs to be available so anyone can rebuild the state. Fully private data breaks the model. Most rollups publish the data and keep the details of individual transactions out of the proof, which is a middle ground.

What happens if the prover goes down?

New batches stop until the prover recovers, because no state update can be proven without it. Users can still withdraw through the bridge using the last proven state, which is why the exit path matters more than the prover's uptime. Run a second prover if uptime matters.

How much does a ZK rollup cost to run?

The main costs are proving, data availability and settlement, plus the sequencer and monitoring. Proving dominates for most teams, and it grows with the number of transactions per batch. Testnet load testing gives a real figure; estimates before that are guesses.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a rollup or a layer 2 product? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Ethereum Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call