What You Should Learn Before Building a zkApp

zkApps are relatively simple to build but there are three fundamental things you should understand first.

The wave of private and scalable smart contracts in Web3 is underway, and Mina Protocol, with its constant-sized succinct blockchain and easy-to-write zero knowledge apps, zkApps, is leading in this transformation. Mina is finally putting ZK in the hands of the Web3 developer with zkApps, short for zero knowledge decentralized applications.

Although building zkApps is relatively simple, there are three fundamental things you should understand before starting to build.

1. TypeScript Syntax

To ensure an intuitive developer experience, zkApps are written in TypeScript. TypeScript is a superset of JavaScript that adds type safety, meaning type correctness is checked at compile time. Another benefit of writing smart contracts in TypeScript is having familiar developer experience and TypeScript toolings, such as npm, Prettier, Jest, ESLint, VScode with IntelliSense code auto-completion, and more.

The main difference between writing zkApps and other zero knowledge smart contracts is that others use custom programming languages, requiring builders to learn something entirely new.

With most developers already knowing TypeScript, zkApps will be the easiest way to start building. If you aren’t familiar with TypeScript, however, there are many existing resources to learn how to write in TypeScript here or here. You can find the official TypeScript documentation here

As long as you know TypeScript syntax, you will be ready to get started quickly.  Installing TypeScript is unnecessary because the Mina zkApp CLI contains TypeScript locally. 

2. How zkApps Work

zkApps use zero knowledge proofs, specifically zk-SNARKs. They use off-chain computations and an off-chain state model, allowing for private executions and a flexible state model so users can choose to set their states private or public.  As opposed to other blockchains that run computations on chain with variable gas-fees for running dApp executions, zkApps offer limitless off-chain computations and on-chain verificaton for a low flat fee. SnarkyJS, the TypeScript library for writing zkApps, uses a Merkle tree to store data off-chain and zkOracles, which are a feature on the roadmap, will also further help with off-chain storage. 

In order to understand how zkApps work, there are a couple of concepts that you have to generally understand about zero knowledge smart contracts. There’s a prover function and a verifier function

A zkApps prover function runs locally on users’ browsers and executes smart contract logic. Circuits, which are covered later in this blog, are a part of the prover function.
A zkApps verifier function is stored on the Mina blockchain and it validates the correctness of prover function execution.

zkApps consists of two parts: a UI and a smart contract.  The prover and verifier functions are part of the smart contract. As privacy becomes more important to end-users, zkApps protect sensitive data so they don’t need to share publicly on a blockchain, but instead via the zkApp’s UI. Since the prover function runs locally, this private data acts as a private input to the prover function. Then the prover function generates a zero knowledge proof of its execution, without revealing any sensitive user data. This ZK proof is sent to the Mina blockchain, where the corresponding verifier function validates the proof. 

Mina’s off-chain execution allows users to keep their data in user custody and only share proof of computation with the world. Learn more about how zkApps work here.

3. How Circuits and SnarkyJS Work

Lastly, you need to learn the difference between developing smart contracts and ZK smart contracts. In ZK smart contracts, a zero knowledge proof is generated over computations inside a function called a circuit.  

To understand the zk-SNARK circuits, think of the boolean circuits analogy. In boolean circuits, a gate represents one of the Boolean operations (AND, OR, XOR, NOR). Inputs are variables on which the boolean operations are applied, and outputs are results of the boolean operations on these variables.

In an arithmetic circuit, the gate represents arithmetic operations (PLUS, MINUS, MULTIPLICATION, DIVISION), where inputs are variables, and outputs  are a result of arithmetic operation on the inputs. 

SnarkyJS is a library for writing zkApps for Mina Protocol, and it hides many zk-SNARK complexities from developers, providing a straightforward way of building on Mina. The experience of writing a zkApp is similar to writing regular TypeScript programs. SnarkysJS circuits work similarly to boolean and arthmetic circuits with their own assertions for inputs so you can set parameters to constrain state updates. The only difference is that SnarkyJS uses built-in data types and methods, instead of their JavaScript counterparts. Learn more in the SnarkyJS docs.

Next Steps

Once you’re familiar with these things, you will be equipped to start writing zkApps on Mina. Here are a few tips on how you can get started:

  1. Install the zkApp CLI here.
  2. Learn to code an example zkApp using this tutorial.  
  3. Build a zkApp with step-by-step challenges while earning points on a leaderboard (currently a soft launch, apply to the waitlist and participants will be admitted in waves).

There are many more resources on how to write, test, and deploy a zkApps here, but these steps should get you started.

If you have questions, please visit the  #zkapp-developers channel on Discord.

If you’d like to dive even deeper, the Mina ecosystem is active all around the world with a ZK developer meetup global tour and a quarterly community grants fund ready to be tapped into!

About Mina Protocol

Mina is the world’s lightest blockchain, powered by participants. Rather than apply brute computing force, Mina uses advanced cryptography and recursive zk-SNARKs to design an entire blockchain that is about 22kb, the size of a couple of tweets. It is the first layer-1 to enable efficient implementation and easy programmability of zero knowledge smart contracts (zkApps). With its unique privacy features and ability to connect to any website, Mina is building a private gateway between the real world and crypto—and the secure, democratic future we all deserve. Mina is stewarded by the Mina Foundation, a public benefit corporation headquartered in the United States.

More from our Blog

Community / 2022-09-27 / Mina Foundation
Meet the zkApp Builder — Marek Narozniak
Learn more about Marek and his first zero knowledge smart contract, LendApp.
Read more
Resource / 2022-09-26 / Mina Protocol
‘Berkeley’ Testnet Alpha Participation Guide
Read more
Ecosystem Update / 2022-09-20 / Mina Ecosystem Contributors
Mina Ecosystem Roadmap – Q3 2022
Read more
Learn / 2022-09-13 / Mina Foundation
Is Zero Knowledge Technology the Future of NFTs?
Read more

About the Tech


Mina uses advanced cryptography and recursive zk-SNARKs to deliver true decentralization at scale.

Get Started


Mina makes it simple to run a node, build and join the community.