Skip to content

OpenZeppelin/compact-tools

Repository files navigation

Generic badge Contributor Covenant OpenSSF Scorecard

OpenZeppelin Compact Tools

Tools for compiling, building, and testing Compact smart contracts. This is a monorepo containing:

  • packages/cli: CLI utilities to run the Compact compiler and builder
  • packages/simulator: TypeScript simulator to run and test Compact contracts locally

External usage (via git submodule until npm publish)

Until packages are published to the npm registry, you can consume this repo from another project using a git submodule:

# In your project
git submodule add https://github.com/OpenZeppelin/compact-tools
git submodule update --init --recursive

# Install and build the tools
yarn --cwd tools/compact-tools install
yarn --cwd tools/compact-tools build

# Use the simulator as a local dependency
# package.json
"devDependencies": {
  "@openzeppelin/compact-tools-simulator": "file:./compact-tools/packages/simulator"
}
yarn install

# Call the CLIs directly or via scripts
node compact-tools/packages/cli/dist/runCompiler.js --help
node compact-tools/packages/cli/dist/runBuilder.js --help

Requirements

  • Node.js >= 20 (root and packages/cli), >= 22 for packages/simulator
  • Yarn 4 (Berry)
  • Turbo
  • Optional: Midnight Compact toolchain installed and available in PATH

Confirm your Compact toolchain:

$ compact compile --version

Compactc version: 0.26.0
0.26.0

Getting started

Install dependencies at the repo root:

nvm install
yarn

Build everything:

yarn build

Run tests (root runs package tests via Turbo):

yarn test

Format and lint (Biome):

yarn lint
yarn lint:fix

Clean generated artifacts:

yarn clean

Packages

@openzeppelin/compact-tools-cli (packages/cli)

CLI utilities for compiling and building Compact smart contracts.

Quickstart:

# Compile all .compact files
compact-compiler

# Skip ZK proofs for faster development builds
compact-compiler --skip-zk

# Compile specific directory
compact-compiler --dir security

# Full build (compile + TypeScript + copy artifacts)
compact-builder

See packages/cli/README.md for full documentation including all options, programmatic API, and examples.

@openzeppelin/compact-tools-simulator (packages/simulator)

TypeScript simulator for testing Compact contracts locally.

Quickstart:

import { createSimulator } from '@openzeppelin/compact-tools-simulator';

const simulator = createSimulator({});
// Deploy and execute contract circuits, inspect state, etc.

See package tests in packages/simulator/src/integration and src/unit for full examples.

Contributing

Before opening a PR, please read CODE_OF_CONDUCT.md. Use the root scripts to build, test, and format. For targeted work inside a package, run the scripts in that package directory.

License

MIT

About

A monorepo for collecting all the shared Compact tools

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5