Skip to content
ZK Sync: trustless scaling and privacy engine for Ethereum
Rust TypeScript Vue JavaScript Shell Makefile Other
Branch: master
Clone or download
dvush Merge pull request #214 from matter-labs/gluk64-patch-1
Update correct link
Latest commit 42f8ca5 Dec 19, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github remove an owner Oct 30, 2019
bin rename to zksync Dec 5, 2019
contracts Bump eslint-utils from 1.4.0 to 1.4.3 in /contracts Dec 5, 2019
docker Deploy updates Dec 2, 2019
docs rename to zksync Dec 5, 2019
etc Merge branch 'master' into dvush/deploy-params Dec 5, 2019
js fixed hashes Dec 12, 2019
.drone.yml rename to zksync Dec 5, 2019
.gitignore Merge branch 'master' of into jazzand… Oct 23, 2019
Cargo.toml fixed a lot of errors Sep 27, 2019
Makefile rename to zksync Dec 5, 2019 Update Dec 18, 2019
docker-compose.yml fix compose file name (#128) Nov 11, 2019

ZK Sync: scaling and privacy engine for Ethereum

Check out ZK Sync live demo.

ZK Sync is a scaling and privacy engine for Ethereum. Its current functionality scope includes low gas transfers of ETH and ERC20 tokens in the Ethereum network. This document is a description of the JS library that can be used to interact with ZK Sync.

ZK Sync is built on ZK Rollup architecture. ZK Rollup is an L2 scaling solution in which all funds are held by a smart contract on the mainchain, while computation and storage are performed off-chain. For every Rollup block, a state transition zero-knowledge proof (SNARK) is generated and verified by the mainchain contract. This SNARK includes the proof of the validity of every single transaction in the Rollup block. Additionally, the public data update for every block is published over the mainchain network in the cheap calldata.

This architecture provides the following guarantees:

  • The Rollup validator(s) can never corrupt the state or steal funds (unlike Sidechains).
  • Users can always retrieve the funds from the Rollup even if validator(s) stop cooperating because the data is available (unlike Plasma).
  • Thanks to validity proofs, neither users nor a single other trusted party needs to be online to monitor Rollup blocks in order to prevent fraud.

In other words, ZK Rollup strictly inherits the security guarantees of the underlying L1.

To learn how to use ZK Sync, please refer to the ZK Sync SDK documentation.


Prepare dev environment prerequisites: see docs/

Setup local dev environment


zksync dev-up
zksync init

To completely reset the dev environment:

  • Stop services: zksync dev-down
  • Remove containers data:
ssh minikube
rm -r /data/*
  • Repeat the setup procedure above

(Re)deploy db and contraсts:

zksync redeploy

Environment configurations

Env config files are held in etc/env/

List configurations:

zksync env

Switch between configurations:

zksync env <ENV_NAME>

Monitoring & management:

Seed for Metamask: fine music test violin matrix prize squirrel panther purchase material script deal Geth: geth attach $(bin/kube-geth-url)

NOTE: if you are resetting geth, each Metamask account must be manually reset via Settings > Advanced > Reset account.

Build and run server + prover locally for development:

Run server:

zksync server

By default block chunk size set to 100. For testing & development purposes you ca change it to smaller values. Two places requires a change:

  1. Environment variable value in ./etc/env/dev.env BLOCK_SIZE_CHUNKS
  2. Rust constant at ./core/models/ BLOCK_SIZE_CHUNKS If you apply changes, do not forget to redeploy contracts zksync redeploy.

You must prepare keys. This only needs to be done once:

zksync redeploy

Run prover:

zksync prover

Run client

zksync client

Client UI will be available at http://localhost:8080. Make sure you have environment variables set right, you can check it by running: zksync env. You should see * dev in output.

Start server and prover in minikube (this setup is closest to prod):

  • Prerequisite: zksync dev-up; zksync init

  • Start: zksync start

  • Watch logs: Server: zksync log-server Prover: zksync log-prover

  • Stop: zksync stop

Build and push images to dockerhub:

zksync dockerhub-push


Database migrations

  • cd core/storage
  • Add diesel migration
  • Rename core/storage/ to
  • Run tests: zksync db-tests

Generating keys

To generate a proving key, from server dir run:

cargo run --release --bin read_write_keys

It will generate a *VerificationKey.sol and *_pk.key files for 'deposit', 'exit' and 'transfer' circuits in the root folder.

Move files to proper locations:

mv -f n*VerificationKey.sol ./contracts/contracts/
mv -f *_pk.key ./prover/keys/

If the pregenerated leaf format changes, replace the EMPTY_TREE_ROOT constant in contracts/contracts/PlasmaStorage.sol.


Re-build contracts:

cd contracts; yarn build

IMPORTANT! Generated .abi and .bin files are fed to cargo to build module plasma::eth.

So you need to rebuild the code on every change (to be automated).

Publish source code on etherscan

zksync publish-source


ZK Sync is distributed under the terms of both the MIT license and the Apache License (Version 2.0).


You can’t perform that action at this time.