npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@openzeppelin/compact-contracts

v0.2.0

Published

OpenZeppelin Compact contract library

Readme

Generic badge Contributor Covenant

This project is built on the Midnight Network.

OpenZeppelin Contracts for Compact

A library for secure smart contract development written in Compact for Midnight.

⚠️ WARNING! ⚠️

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

⚠️ Witnesses Are Test-Only Material ⚠️

Every TypeScript witness in this repo lives under contracts/src/<module>/test/witnesses/ and exists solely to drive the Compact circuits during off-chain tests. They are not part of the published package and are not maintained as a public API.

Witness implementations are security-critical. A witness controls the private state a circuit reads from — a buggy or malicious witness can leak secrets, produce invalid proofs, or undermine the guarantees of the contract it pairs with. Consumers of this library must author and audit their own witnesses for production use; the ones shipped here are reference test doubles only.

OpenZeppelin does not publish witnesses as a consumable artifact and takes no responsibility for any witness implementation reused outside its test context.

Learn

Documentation

Check out the full documentation site!

Usage

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

Follow Midnight's Compact Developer Tools installation guide and confirm that compact is in the PATH env variable.

$ compact compile --version

Compactc version: 0.29.0
0.29.0

Installation

Create a directory for your project.

mkdir my-project
cd my-project

Install the package.

yarn add @openzeppelin/compact-contracts

Write a custom contract using library modules

In the root of my-project, create a custom contract using OpenZeppelin Compact modules. Import the modules through ./node_modules/@openzeppelin/compact-contracts/....

// MyContract.compact

pragma language_version >= 0.21.0;

import CompactStandardLibrary;
import "./node_modules/@openzeppelin/compact-contracts/access/Ownable"
  prefix Ownable_;
import "./node_modules/@openzeppelin/compact-contracts/security/Pausable"
  prefix Pausable_;
import "./node_modules/@openzeppelin/compact-contracts/token/FungibleToken"
  prefix FungibleToken_;

constructor(
  _name: Opaque<"string">,
  _symbol: Opaque<"string">,
  _decimals: Uint<8>,
  _recipient: Either<Bytes<32>, ContractAddress>,
  _amount: Uint<128>,
  _initOwner: Either<Bytes<32>, ContractAddress>,
) {
  Ownable_initialize(_initOwner);
  FungibleToken_initialize(_name, _symbol, _decimals);
  FungibleToken__mint(_recipient, _amount);
}

/** IFungibleToken */

export circuit name(): Opaque<"string"> {
  return FungibleToken_name();
}

export circuit symbol(): Opaque<"string"> {
  return FungibleToken_symbol();
}

export circuit decimals(): Uint<8> {
  return FungibleToken_decimals();
}

export circuit totalSupply(): Uint<128> {
  return FungibleToken_totalSupply();
}

export circuit balanceOf(account: Either<Bytes<32>, ContractAddress>): Uint<128> {
  return FungibleToken_balanceOf(account);
}

export circuit allowance(
  owner: Either<Bytes<32>, ContractAddress>,
  spender: Either<Bytes<32>, ContractAddress>
): Uint<128> {
  return FungibleToken_allowance(owner, spender);
}

export circuit transfer(
  to: Either<Bytes<32>, ContractAddress>,
  value: Uint<128>,
): Boolean {
  Pausable_assertNotPaused();
  return FungibleToken_transfer(to, value);
}

export circuit transferFrom(
  fromAddress: Either<Bytes<32>, ContractAddress>,
  to: Either<Bytes<32>, ContractAddress>,
  value: Uint<128>
): Boolean {
  Pausable_assertNotPaused();
  return FungibleToken_transferFrom(fromAddress, to, value);
}

export circuit approve(spender: Either<Bytes<32>, ContractAddress>, value: Uint<128>): Boolean {
  Pausable_assertNotPaused();
  return FungibleToken_approve(spender, value);
}

/** IOwnable */

export circuit owner(): Either<Bytes<32>, ContractAddress> {
  return Ownable_owner();
}

export circuit transferOwnership(newOwner: Either<Bytes<32>, ContractAddress>): [] {
  return Ownable_transferOwnership(newOwner);
}

export circuit renounceOwnership(): [] {
  return Ownable_renounceOwnership();
}

/** IPausable */

export circuit pause(): [] {
  Ownable_assertOnlyOwner();
  Pausable__pause();
}

export circuit unpause(): [] {
  Ownable_assertOnlyOwner();
  Pausable__unpause();
}

Compile the contract

Compile the contract.

% compact compile MyContract.compact artifacts/MyContract
Compiling 14 circuits:
  circuit "allowance" (k=11, rows=1352)
  circuit "approve" (k=13, rows=3080)
  circuit "balanceOf" (k=10, rows=673)
  circuit "decimals" (k=6, rows=28)
  circuit "name" (k=6, rows=28)
  circuit "owner" (k=7, rows=76)
  circuit "pause" (k=13, rows=2365)
  circuit "renounceOwnership" (k=13, rows=2364)
  circuit "symbol" (k=6, rows=28)
  circuit "totalSupply" (k=6, rows=28)
  circuit "transfer" (k=13, rows=3990)
  circuit "transferFrom" (k=13, rows=4977)
  circuit "transferOwnership" (k=13, rows=2959)
  circuit "unpause" (k=13, rows=2362)
Overall progress [====================] 14/14

Development

OpenZeppelin Contracts for Compact exists thanks to its contributors. There are many ways you can participate and help build high quality software, make sure to check out the contribution guide in advance.

Requirements

Set up the project

Clone the OpenZeppelin Contracts for Compact library.

git clone [email protected]:OpenZeppelin/compact-contracts.git

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

nvm install && \
yarn && \
yarn compact

Run tests

yarn test

Check/apply Biome formatter

yarn fmt-and-lint
yarn fmt-and-lint:fix

Advanced

Targeted compilation

yarn compact:access
yarn compact:archive
...

Skip ZK prover/verifier keys

ZK key generation is slow and usually unnecessary during development.

# Full compilation with skip-zk (use environment variable)
SKIP_ZK=true yarn compact

# Access compilation with skip-zk (this compiles security first as a dependency)
SKIP_ZK=true yarn compact:access

Clean environment

# WARNING!
# These are destructive commands
yarn clean
rm -rf .turbo/

Troubleshooting

  • Issues with turbo's cache? Try cleaning: yarn clean && rm -rf .turbo/
  • Node version issues? Use nvm use to switch to the correct version

Security

This project is still in a very early and experimental phase. It has never been audited nor thoroughly reviewed for security vulnerabilities. DO NOT USE IT IN PRODUCTION.

Please report any security issues you find to [email protected].

Provenance

Releases are published from GitHub Actions with npm provenance enabled. Each published version carries a signed attestation in the public Sigstore transparency log linking the package to its source commit and build workflow run. View the verified source commit, build, and transparency-log links in the Provenance panel on the npm package page.