Book a free call

How to Build Enterprise AI dApps on a ZK Layer 2

An enterprise AI dApp on a ZK layer 2 pairs private, verifiable AI work with cheap, fast settlement. Here is the architecture, the build steps, and the trade-offs.

Hertiv engineering teamReviewed by a senior engineer
9 min read
How to Build Enterprise AI dApps on a ZK Layer 2
On this page

Short answer

An enterprise AI dApp on a ZK layer 2 is a decentralised application that runs AI features off-chain, proves the work with zero-knowledge proofs, and settles the result on a ZK rollup. The AI stays private and fast, the proof lets anyone check the work without seeing the data, and the rollup keeps settlement cheap.

What is an enterprise AI dApp on a ZK layer 2?

An enterprise AI dApp on a ZK layer 2 is a decentralised application that uses AI to do work, uses zero-knowledge proofs to show that work was done correctly, and settles the result on a ZK rollup. The three parts each solve a different problem: the AI does the work, the proof makes it checkable, and the rollup makes it cheap to record.

A dApp is an application whose core state and rules live on a blockchain rather than on one company's server. An AI dApp adds a model to that picture: it reads data, makes a decision or a prediction, and records the outcome on-chain. In an enterprise setting, that outcome might be a credit check, a fraud flag, or a quality score.

The ZK layer 2 is a rollup that bundles many transactions, proves them with zero-knowledge proofs, and posts a small proof to the main chain. The main chain checks the proof instead of re-running every transaction, which keeps costs down while keeping the security of the main chain.

The combination matters for enterprises because they need privacy and proof at the same time. A bank cannot publish its customer data, but its partners still need to trust the result. Zero-knowledge proofs are the bridge: they let a company prove a result without showing the data behind it, as explained in how AI agents use ZK proofs.

What does the ZK layer add that a plain layer 2 does not?

The ZK layer adds privacy and verifiability that a plain layer 2 does not. A plain optimistic rollup assumes transactions are correct unless someone challenges them, while a ZK rollup proves each batch is correct before it is accepted.

What you needPlain layer 2ZK layer 2
Proof the work is rightChallenge window, days longProof checked at once
Keep inputs privateData visible on-chainProof hides the inputs
Withdraw funds fastWait for the challenge windowWithdraw once the proof lands
Cost per transactionLowLow, proof cost shared

The proof is the key difference. With a ZK rollup, a batch of transactions is accepted only after its proof checks out, so there is no waiting period for challenges. That matters for enterprises that need to move funds or finalise a decision the same day, not a week later.

Privacy is the second difference. A ZK proof can show that a computation was done correctly without revealing the inputs. An insurer can prove a claim was checked against its rules without showing the claim details, and a lender can prove a credit check passed without sharing the applicant's file.

The trade-off is complexity. Building a ZK rollup, or proving AI work with it, needs specialist skills and careful testing. The rollup itself is covered in how to implement a ZK rollup, and the basics are in the explainer of what a rollup is.

Where does the AI run: on-chain, off-chain, or both?

The AI runs off-chain in almost every enterprise AI dApp, because running a model on-chain is too slow and too costly. The chain holds the result, the proof and the rules; the model runs on servers the enterprise controls.

Off-chain AI is the practical choice. A model that scores credit risk or flags fraud needs to read large amounts of data and answer in seconds, and a blockchain cannot do that work at a sensible cost. So the model runs on normal infrastructure, and only the outcome is recorded on-chain.

The question then becomes how to trust the off-chain work. Three answers are common. The simplest is a signed result: the server signs its answer, and the dApp checks the signature. A stronger answer is a ZK proof that the model ran correctly on the stated inputs. The strongest, and rarest, is to run the model inside a trusted environment and prove that too.

Most teams start with signed results and add proofs for the steps that matter most, such as the final decision or the payment. Proving every step is expensive and slow, so prove the steps where a wrong answer would cost the most, and sign the rest.

How do you design the architecture?

You design the architecture by splitting the system into four parts: the model, the proof, the contracts and the interface, with clear rules for what each part can see and change.

The model is the AI itself: what it reads, what it decides, and what it returns. It runs off-chain, behind the enterprise firewall, and it should never see more data than the task needs. Keep the model and its data in the part of the system the enterprise already controls.

The proof layer turns the model's work into something others can check. For each decision that matters, it produces either a signature or a ZK proof, plus a record of which inputs were used. The proof does not need to reveal the inputs, only that the stated rules were followed.

The contracts are the on-chain rules: who can call the dApp, what a valid proof looks like, and what happens when the proof checks out. Keep the contracts small. Every rule that lives on-chain is a rule that is hard to change later, so put the stable rules on-chain and the changing logic off-chain.

The interface is what users and partners see: a web app or an API that takes a request, runs the AI, and shows the result with its proof. The interface should show the proof status clearly, so a partner can see at a glance whether a result was verified or merely signed.

How to build one in 6 steps

Build an enterprise AI dApp on a ZK layer 2 in six steps: define the decision, pick the rollup, build the contracts, wire the AI, add the proof, and test with real data.

  1. Define one decision. Pick a single decision the dApp will make, such as approving a claim or flagging a transaction. A narrow decision is easier to prove and easier to audit.
  2. Pick the rollup. Choose a ZK rollup that fits your cost, speed and tooling needs, and check that your team can deploy and monitor contracts on it.
  3. Build the contracts. Write small contracts that check proofs, record outcomes and enforce who can call them. Test them on a testnet first.
  4. Wire the AI. Connect the model to the data it needs, define its inputs and outputs, and record which version of the model produced each result.
  5. Add the proof. For the decision that matters most, generate a ZK proof or a signed result, and have the contract check it before recording the outcome.
  6. Test with real data. Run the full flow on past cases, check the proofs, and measure the cost and time of each step before going live.

The rollup side of the work is detailed in what a ZK rollup is and the implementation guide. Keep the first version narrow: one decision, one rollup, one proof.

How do you handle data, compliance and audits?

You handle data, compliance and audits by keeping private data off-chain, recording only proofs and outcomes on-chain, and keeping a full log of every decision, model version and proof.

Data privacy starts with a simple rule: personal and commercially sensitive data never goes on-chain. The chain holds the proof that a decision was made correctly and the outcome of that decision, while the data itself stays in the enterprise's own systems. That split is what makes the design workable under privacy law.

Compliance depends on the industry, but the pattern is the same: know which rules apply, build the checks into the dApp, and keep records an auditor can follow. A financial dApp needs to show who approved what and when; a healthcare dApp needs to show that only authorised people saw patient data. The proof and the log are the evidence.

Audits are easier when every decision carries its own trail. Record the model version, the input references, the proof and the time for each decision, and keep that record in a place the auditor can read. If a decision is challenged, the team should be able to replay it from the log without guessing.

Plan for model change too. Models are updated, and each update changes the results. Version every model, record which version made each decision, and re-test the proofs when the model changes, because a new model can break a proof that worked before.

Example (hypothetical): an invoice-checking dApp

Example (hypothetical): a logistics company checks 2,000 supplier invoices a month. Its AI dApp reads each invoice, checks it against the contract and the delivery record, and flags the ones that look wrong. The flags are recorded on a ZK layer 2 with a proof that the check ran on the stated rules.

The model flags 140 invoices, which is 7 in every 100. A human reviews each flagged invoice for 15 minutes, so the review takes 140 times 15 minutes, or 2,100 minutes, which is 35 hours a month. Before the dApp, the team sampled 10 in every 100 invoices, which is 200 invoices, and the same 15-minute review took 200 times 15 minutes, or 3,000 minutes, which is 50 hours a month.

The dApp therefore saves 50 minus 35, or 15 hours a month, while checking every invoice instead of a sample. The saving is modest, but the coverage is the real gain: the sample could miss a wrong invoice, while the dApp sees all of them.

Each flagged invoice carries a proof that the check ran, so a supplier who disputes a flag can be shown the rule that was applied without seeing other suppliers' data. That proof is what makes the dispute short instead of a long argument.

What are the common mistakes?

The most common mistakes are putting private data on-chain, proving everything instead of the steps that matter, writing contracts that cannot be changed, and forgetting to version the model.

  • Private data on-chain. Anything written to a chain is hard to remove, so keep personal and sensitive data off-chain and store only proofs and outcomes.
  • Proving everything. Generating a proof for every step is slow and costly. Prove the decision that matters and sign the rest.
  • Contracts that cannot change. Rules change, so design contracts that can be upgraded or replaced instead of locking the logic in forever.
  • Forgetting model versions. A decision without a recorded model version cannot be replayed or defended later.
  • Trusting the proof alone. A proof shows the computation ran correctly, not that the inputs were honest. Check the data sources too.
  • Skipping the cost check. Proof generation and on-chain settlement both cost money, so measure the cost per decision before launch.

Key takeaways

  • The AI runs off-chain; the chain holds the result, the proof and the rules
  • A ZK rollup proves each batch is correct at once, with no challenge window to wait out
  • Proofs let a company show a decision was right without showing the data behind it
  • Keep private data off-chain and record only proofs and outcomes on-chain
  • Version every model and record which version made each decision

Frequently asked questions

What is a ZK layer 2 in plain terms?

A ZK layer 2 is a rollup that bundles many transactions, proves them correct with zero-knowledge proofs, and posts a small proof to the main chain. The main chain checks the proof instead of re-running every transaction, which keeps settlement cheap while keeping the main chain's security.

Why not run the AI on-chain?

Running a model on-chain is too slow and too costly for real work. A model needs to read large amounts of data and answer in seconds, and a blockchain is not built for that. So the AI runs on normal servers, and only the result and its proof go on-chain.

What does a zero-knowledge proof actually prove?

It proves that a computation was done correctly on the stated inputs, without revealing the inputs themselves. In an AI dApp, that means proving the model ran the right rules on the right data, while keeping the data private.

Is a ZK rollup cheaper than the main chain?

Usually yes, because many transactions share one proof and the main chain only checks that proof. The saving depends on the rollup and the volume, so measure the cost per decision on a testnet before committing to a design.

How do enterprises keep data private in a dApp?

Private data stays in the enterprise's own systems and never goes on-chain. The chain holds the proof and the outcome only. Partners can check the proof without seeing the data, which is the point of the design.

What is the hardest part of building one?

The proof layer is usually the hardest part, because it needs specialist skills and careful testing. Most teams start with signed results for the whole flow and add a ZK proof for the single decision that matters most, then expand from there.

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 an enterprise AI dApp on a ZK layer 2? Talk to Hertiv.

A senior engineer replies within one business day. Or see our dApp 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 contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call