• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 3 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CLI to create a zkApp (zero-knowledge app) for Mina Protocol

Mina zkApp CLI

The Mina zkApp CLI allows you to scaffold, write, test, and deploy zkApps (zero knowledge apps) for Mina Protocol using recommended best practices.

Apps are written using SnarkyJS, a TypeScript framework for writing zero knowledge proof-based smart contracts. SnarkyJS is automatically included when you create a project using the Mina zkApp CLI.

Getting Started

Read through this README file and the Mina Protocol zkApp Developer docs.

Build foundational knowledge by completing the guided steps in the zkApp Developer Tutorials.

Get Involved

To learn about ways to participate and interact with community members, see the Mina Online Communities docs.

Contributions are always appreciated. See the zkApp CLI CONTRIBUTING guidelines.

Install the Mina zkApp CLI

To install the Mina zkApp CLI:

$ npm install -g zkapp-cli

To confirm successful installation:

$ zk --version

Update the Mina zkApp CLI

You are prompted to install the new version if you are running an earlier zkApp CLI minor version. For example, if you are running version 0.9.8, but the current version is 0.10.2, you are prompted to update.

You are not prompted to update if you are using an earlier patch version. For example, you are not notified to upgrade when you are running 0.10.1, and the current version is 0.10.2.

To update to the latest version of the Mina zkApp CLI:

$ npm update -g zkapp-cli

Dependencies

To use the zkApp CLI and SnarkyJS, your environment requires:

  • NodeJS v16 and later (or NodeJS v14 using --experimental-wasm-threads)
  • NPM v6 and later
  • Git v2 and later

Use a package manager to install the required versions and upgrade older versions if needed. Package managers for the supported environments are:

  • MacOS Homebrew

  • Windows Chocolatey

  • Linux

    • apt, yum, and others

    On Linux, you might need to install a recent Node.js version by using NodeSource. Use deb or rpm as recommended by the Node.js project.

To verify your installed versions, use npm -v, node -v, and git -v.

Usage

To see all of the zkApp CLI commands:

zk --help

Create a project

zk project my-proj  # or path/to/my-proj

✔ Fetch project template
✔ Initialize Git repo
✔ NPM install
✔ Set project name
✔ Git init commit

Success!

Next steps:
  cd my-proj
  git remote add origin <your-repo-url>
  git push -u origin main

This command creates a directory containing a new project template, fully set up and ready for local development.

  • See the included README for usage instructions. All of the usual commands are available: npm run build, npm run test, npm run coverage, and so on.
  • A GitHub repo is automatically initialized in the project directory. For consistency and by convention, we use main as the default development branch.
  • A GitHub Actions CI workflow is also included. If you push your project to GitHub, GitHub Actions run your tests (named as *.test.js) automatically whenever you push a commit or open a pull request.
  • Code style consistency (using Prettier) and linting (using ES Lint) is automatically enforced using Git pre-commit hooks. This requires no configuration and occurs automatically when you commit a change, for example, git commit -m 'feat: add awesome feature'.

Create an example project

zk example <name>

where name is one of the names found in the zkApps examples directory.

All examples are based on the standard project template created by the zkApp CLI and contain only changes within the src directory, so feel free to use one of these examples as your project base.

When inside an example folder in your terminal, you can run the example:

npm run build && node ./build/src/index.js

Create a new file

zk file <name>  # or path/to/name

This command creates name.js and name.test.js.

For convenience, when you run this command in your project's root directory creates the files inside your project's src dir automatically, even if you don't specify src/ as part of your file path.

When you run this command when you are not in your project's root dir, files are created at the path you specify relative to your terminal's current working directory.

Show system info

zk system

This command outputs system info such as your NodeJS version, NPM version, zkapp-cli version, and so on. For easier troubleshooting, be sure to include this information if submitting a bug report for zkapp-cli. See the CONTRIBUTING guidelines.

Update your config.json

zk config

The auto-generated config.json file contains your deployment-related configurations.

Run the zk config command to add a new deployment configuration to this file.

Respond to the interactive command prompts to build or update a deploy alias.

A deploy alias consists of:

  • A self-describing name. This tutorial uses berkeley. The deploy alias name can be anything and does not have to match the network name.

  • The Mina GraphQL API URL that defines the network that receives your deploy transaction and broadcasts it to the appropriate Mina network (Testnet, Devnet, Mainnet, and so on)

  • The transaction fee (in MINA) to use when deploying

  • Two key pairs:

    • A key pair for the zkApp account. Public and private keys to use in your application are automatically generated in keys/berkeley.json.

    • A key pair to use as a fee payer account for updates and deployments. Public and private keys are stored on your local computer and can be used across multiple projects.

  • Fee payer account alias

    A fee payer account is required. If you don't have a fee payer account, you are prompted to select one of these options:

    • Recover a fee payer account from an existing base58 private key
    • Create a new fee payer key pair

Deploy your smart contract

zk deploy <alias>
// OR
zk deploy // shows a list of aliases in your project to choose from

Deployment is supported only to Berkeley Testnet. zkApp programmability is not yet available on the Mina Mainnet.

After you run zk config, the zk deploy command allows you to deploy a smart contract to a specified deploy alias.

Note: When you deploy to an alias for the first time, you are prompted to choose which smart contract you want to deploy from those that exist as named exports in your project. The name of the smart contract that you choose is remembered by being saved into your config.json for this alias. For safety, the next time you run zk deploy <alias> this same smart contract automatically deploys to this alias. See Tutorial 3: Deploy to a Live Network.

License

Apache-2.0

More Repositories

1

o1js

TypeScript framework for zk-SNARKs and zkApps
TypeScript
509
star
2

snarky

OCaml DSL for verifiable computation
OCaml
494
star
3

proof-systems

The proof systems used by Mina
Rust
404
star
4

docs2

Docs website for the Mina Protocol.
JavaScript
79
star
5

ocamlbyexample

Learn Ocaml by reading code examples
OCaml
68
star
6

zkapp-resource-kit

This repository is a resource kit contains links to all code, tools, documentation, and learning materials necessary to successfully become a zkApp developer and contributor. Add your projects or findings here!
57
star
7

snarkette

Pure OCaml implementation of the Groth-Maller SNARK verifier (and associated crypto)
OCaml
53
star
8

verkle-tree

Rust
26
star
9

Archive-Node-API

This is a GraphQL server that is built with the intention of exposing information from Mina's Archive Node
TypeScript
17
star
10

snarkyjs-workshop

TypeScript
13
star
11

o1js-bindings

Bindings for o1js to lower layers of the proof system and the Mina transaction logic
JavaScript
10
star
12

ocaml-gen

This crate provides automatic generation of OCaml bindings. Refer to the rustdoc for more information.
Rust
9
star
13

ppx_version

Versioning of types with bin_prot serialization
OCaml
8
star
14

integers_stubs_js

Javascript stubs for the integers library in js_of_ocaml
JavaScript
6
star
15

snarkyjs-examples

TypeScript
5
star
16

anonvote

JavaScript
5
star
17

mina-book

Specifications and documentation for the Mina protocol
5
star
18

snarkyjs-crypto

JavaScript crypto library accompanying snarky
OCaml
5
star
19

mina-lightweight-explorer

Lightweight Mina Explorer
HTML
4
star
20

rfcs

RFCs for everything O(1) Labs
4
star
21

wait-for-mina-network-action

GitHub Action to wait for the Mina network readiness.
TypeScript
4
star
22

sfbw-workshop

Tutorial code for the SFBW zk-SNARK workshop
OCaml
3
star
23

stationary

Static site generator
OCaml
2
star
24

code-review-question

Code review interview question repo
JavaScript
2
star
25

dune-nix

Nix wrapping suitable for multi-package dune repositories
Nix
2
star
26

libsnark-ocaml

C++
1
star
27

mina-web3

TypeScript
1
star
28

eslint-plugin-o1js

ESLint rules for o1js
TypeScript
1
star