Skip to Content

Copied from docs/SETUP.md  at build time. Edit that file.

zx402: Setup

FieldValue
Statusv1.0, 2026-10-06
ForAnyone who builds or tests this project

Follow these steps on a fresh machine. Each step ends with a check.

1. Toolchain

ToolVersionWhy this version
Node.js22 or later@x402/cardano and the Mesh SDK target modern Node
Aiken1.1.24, through the npm package @aiken-lang/aikenThe latest release. It knows the protocol version 11 cost models. The npm package pins it for everyone
circom2.2.x, through the circom2 npm package 0.2.23No native install needed
snarkjs0.7.6Supports Groth16 on curve bls12-381
poseidon-bls12381-circom1.0.0The Poseidon255 circuits
poseidon-bls123811.0.2The matching TypeScript library
@noble/curves2.4.0Point compression to the format Cardano expects
Mesh SDK (@meshsdk/core)1.9.xTransaction building
@x402/cardano2.28.xThe x402 scheme for Cardano
aiken-lang/merkle-patricia-forestry2.1.0The nullifier set
@aiken-lang/merkle-patricia-forestry (npm)1.3.1The off-chain side of the nullifier set. It pairs with the on-chain library 2.1.0
TypeScript, tsx5.9.x, 4.xType checks, and node:test runs on TypeScript sources

Section 4 lists which stdlib version to pin, and how these versions were checked.

Steps

  1. Install Node 22 or later. Check with node --version.
  2. Install everything else from the repo root. This one command installs every tool at its pinned version, including the Aiken compiler, circom, and snarkjs. Nothing needs a global install.
npm ci
  1. Check the tools. The first must print 1.1.24. The second must print a 2.2.x compiler version.
npx aiken --version npx circom2 --version
  1. Run the toolchain smoke test. It must report 6 passing tests.
npm run test:smoke
  1. Run the contract tests. Aiken downloads its two packages on the first run.
npm run check:contracts

2. Accounts and keys

ItemNeeded forNote
Blockfrost project for Cardano mainnetChain data, evaluation, submitKeep the project ID in .env, never in git
Operator, relayer, admin, ASP, and test walletsThe runbookSee RUNBOOK-M0.md section 1

CAUTION: .env files, seed phrases, signing keys, and proving keys must never enter git. The .gitignore already blocks .env, *.zkey, and *.ptau.

3. AI coding agents

This repo works with AI coding agents. AGENTS.md  holds the rules they must follow.

For Claude Code, install the Cardano Dev Skills plugin. It bundles current Aiken, Mesh, x402, and Masumi documentation.

  1. Add the marketplace:
/plugin marketplace add cardano-foundation/cardano-dev-skills
  1. Install the plugin:
/plugin install cardano-dev-skills@cardano-dev-skills
  1. Wire it into this project:
/cardano-context

Run the first two commands in that order. For other agents, clone the skills repo and link its skills folder as its README describes.

4. Verified combinations

These versions were run together on 2026-10-06, on macOS arm64 with Node 24.10.0.

CombinationResult
circom2 0.2.23 (circom 2.2.3) with --prime bls12381, snarkjs 0.7.6, poseidon-bls12381-circom 1.0.0Circuits compile, witnesses check, and hashes match poseidon-bls12381 1.0.2
snarkjs 0.7.6 Groth16 on bls12-381, @noble/curves 2.4.0, Aiken 1.1.24A converted proof verifies with the Plutus builtins
Aiken 1.1.24, aiken-lang/merkle-patricia-forestry 2.1.0, stdlib v2.2.1, v3.1.0, or v4.0.0Compiles, and a trie insert test passes
A fresh clone on Linux with Node 22 (GitHub Actions)npm ci, the smoke test, the type check, the tests, and the contract checks all pass

Pin stdlib v4.0.0 for this project.

Things that cost time in those runs:

  • Compile circuits with --O2. The default level makes each hash about 2.6 times larger.
  • circom2 needs a real node_modules folder in the working directory. A symlink fails.
  • Import @noble/curves/bls12-381.js, with the .js suffix.
  • A script that calls snarkjs must end with process.exit, or it hangs.
  • The trie library is imported as aiken/merkle_patricia_forestry.
  • Aiken caches packages under the home directory. Set HOME to a project folder if you need an isolated build.
  • A sandbox that blocks writes outside the repo also blocks that cache. Put the two packages under contracts/build/packages first.
  • npx snarkjs --version prints its help text and exits with code 99. That is normal.

See research/2026-10-06-measurements.md  and research/spikes/  for the full results.