Contracts for Compact

A library for secure smart contract development written in Compact for Midnight. This library consists of modules to build custom smart contracts.

This repo contains highly experimental code. Expect rapid iteration. Use at your own risk.

Installation

Make sure you have nvm and yarn installed on your machine.

Follow Midnight’s compact installation guide and confirm that compactc is in the PATH env variable.

$ compactc

Compactc version: 0.24.0
Usage: compactc.bin <flag> ... <source-pathname> <target-directory-pathname>
       --help displays detailed usage information

Project setup

Clone the repository:

git clone git@github.com:OpenZeppelin/midnight-contracts.git

cd into it and then install dependencies and prepare the environment:

nvm install && \
yarn && \
yarn prepare

Usage

Compile the contracts:

$ npx turbo compact

(...)
 [COMPILE] [1/2] Compiled FungibleToken.compact
@openzeppelin-compact/fungible-token:compact:     Compactc version: 0.24.0
@openzeppelin-compact/fungible-token:compact:
 [COMPILE] [1/6] Compiled Initializable.compact
@openzeppelin-compact/utils:compact:     Compactc version: 0.24.0
@openzeppelin-compact/utils:compact:
 [COMPILE] [2/6] Compiled Pausable.compact
@openzeppelin-compact/utils:compact:     Compactc version: 0.24.0
@openzeppelin-compact/utils:compact:
 [COMPILE] [3/6] Compiled Utils.compact
@openzeppelin-compact/utils:compact:     Compactc version: 0.24.0
@openzeppelin-compact/utils:compact:
 [COMPILE] [4/6] Compiled test/mocks/MockInitializable.compact
@openzeppelin-compact/utils:compact:     Compactc version: 0.24.0
@openzeppelin-compact/utils:compact:     Compiling 3 circuits:
 [COMPILE] [5/6] Compiled test/mocks/MockPausable.compact
@openzeppelin-compact/utils:compact:     Compactc version: 0.24.0
@openzeppelin-compact/utils:compact:     Compiling 5 circuits:
 [COMPILE] [6/6] Compiled test/mocks/MockUtils.compact
@openzeppelin-compact/utils:compact:     Compactc version: 0.24.0
@openzeppelin-compact/utils:compact:

 [COMPILE] [2/2] Compiled test/mocks/MockFungibleToken.compact
@openzeppelin-compact/fungible-token:compact:     Compactc version: 0.24.0
@openzeppelin-compact/fungible-token:compact:     Compiling 15 circuits:

    Tasks:    2 successful, 2 total
Cached:    0 cached, 2 total
  Time:    7.178s

Speed up the development process by skipping the prover and verifier key file generation:

npx turbo compact -- --skip-zk

Run tests:

npx turbo test