Skip to content

Latest commit

 

History

History
217 lines (164 loc) · 7.33 KB

zkapp-development-frameworks.mdx

File metadata and controls

217 lines (164 loc) · 7.33 KB
title sidebar_label hide_title description keywords
zkApps Development Frameworks
zkApps Development Frameworks
true
zkApps (zero knowledge apps) are Mina Protocol smart contracts powered by zero knowledge proofs, specifically using zk-SNARKs.
zkapps
mina protocol
smart contracts
zero knowledge proofs
off-chain execution
typescript
quickstart zkapps
o1js
protokit

zkApp Development Frameworks

Applications on Mina are called zkApps, and they come in a wide range of forms, including DeFi, games, state bridges, and more. However, due to Mina’s client-side execution model, the developer experience differs somewhat from that of other blockchain networks, such as Ethereum.

Developers build zkApps with o1js. Developers can either use o1js directly or use o1js with Protokit, a framework built on top of o1js. Both options offer the full benefits of Mina’s verifiable, privacy-preserving zero knowledge proofs, but offer different tradeoffs between developer experience, performance, and decentralization.

Info
Please note that Protokit is in alpha, and settlement support with reorgs is still in progress.

This page provides a guide to choosing the best approach for your zkApp development - o1js directly or Protokit on top of o1js.

If you are unsure about any of the information presented here and need guidance on choosing the most suitable framework for you, drop by Discord and let us help!

Choosing a framework

Developers can build zkApps either directly with o1js, or with o1js + Protokit.

Protokit is built on top of o1js and simplifies the development of zkApps with concurrent users requiring a shared state, such as DEXes or games. Protokit is recommended for most developers.

o1js is the best way to write custom zero knowledge circuits and construct low-level primitives on Mina, such as an NFT standard or a zkML library.

Info
For developers coming from the Ethereum ecosystem, think of zkApps like smart contracts that can be verified off-chain.

This enables Mina to employ a client-side execution model, which gives Mina its scalability and privacy properties, but it can make it difficult to develop applications with concurrent users requiring a shared state. Protokit builds on top of o1js to solve these concurrency challenges.

Protokit is designed for zkApps with concurrent users requiring a shared state, for example, DEXes and most games. In addition to this Protokit provides an integrated verifiable data storage solution that further simplifies the developer experience compared to o1js.

Protokit can operate in two modes: Based Sequencing and Hybrid Sequencing.

In Based Sequencing mode, Protokit sends all transactions to the Mina L1, providing the decentralization guarantees of the L1, but limited to the L1’s throughput and latency. Based Sequencing mode is best for zkApps where censorship resistance and liveness are more important than the additional performance benefits.

In Hybrid Sequencing mode, Protokit runs an off-chain sequencer with off-chain data availability, providing higher throughput and lower latency than the Mina L1 but at the expense of decentralization. Hybrid Sequencing mode is best for zkApps where performance is critical.

Important: Users of a zkApp in Hybrid Sequencing mode can always submit transactions directly to the L1, for example, to withdraw funds (in case the zkApp sequencer is unavailable) but it does rely on the Protokit’s data availability (DA). Solutions are in the works for DA guarantees even in Hybrid Sequencing mode so that developers can get higher throughput and latency while retaining censorship resistance and liveness guarantees.

Start developing zkApps with Protokit here:

o1js

o1js is the best way to author highly-optimized ZK circuits and primitives, but it does not provide an easy-to-use solution for managing a shared global state.

o1js can be used directly on the Mina L1, and is thus limited by the L1’s throughput and latency, but maintains strong decentralization guarantees.

Info
Did you know? zkApps written directly with o1js can orchestrate concurrent users requiring shared state using Mina L1’s Actions & Reducer, but it requires significant development to orchestrate Action & Reducers. At its core, Protokit is a framework for orchestrating the Mina L1 Actions & Reducers out of the box.

Start developing zkApps with o1js here:

Choosing between Protokit and o1js

Still can’t decide between Protokit and o1js?

This section provides a comparison table to help zkApp developers choose which framework to use.

Protokit Hybrid Protokit Based o1js
Concurrency 🟡
Shared State 🟡
Throughput 🟡 🟡
Latency 🟡 🟡
Censorship Resistance 🟡
Liveness 🟡
Security

Understanding the performance vs. centralization tradeoff

Protokit includes an off-chain sequencer and off-chain storage. If one or the other becomes inaccessible, users may find they can no longer access the zkApp including any tokens they may have in the zkApp.

If the Protokit instance’s sequencer is unavailable but the storage is still accessible, users may submit transactions (e.g. withdrawals) directly to the Mina L1.

If the Protokit instance’s storage is inaccessible, users will not be able to submit transactions to the Mina L1 and their tokens may be locked until the storage can be recovered.

Solutions are in the works for DA guarantees even in Hybrid Sequencing mode so that developers can get higher throughput and latency while retaining censorship resistance and liveness guarantees.