Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/custom-note-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Custom Note Tests

on:
push:
branches:
- next
pull_request:
branches:
- next
paths:
- "custom-note/**"
- ".github/workflows/custom-note-tests.yml"
workflow_dispatch:

jobs:
custom-note-tests:
name: Custom Note Tests
runs-on: ubuntu-latest
env:
AZTEC_VERSION: 5.0.0-rc.1

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Enable Corepack for Yarn
run: corepack enable

- name: Install Aztec CLI
run: |
INSTALL_URL="https://install.aztec.network/${{ env.AZTEC_VERSION }}/"
curl -sL $INSTALL_URL > tmp.sh
VERSION=${{ env.AZTEC_VERSION }} bash tmp.sh <<< yes "yes"

- name: Update path
run: |
echo "$HOME/.aztec/current/bin" >> $GITHUB_PATH
echo "$HOME/.aztec/current/internal-bin" >> $GITHUB_PATH
echo "$HOME/.aztec/current/node_modules/.bin" >> $GITHUB_PATH
echo "$HOME/.aztec/bin" >> $GITHUB_PATH

# custom-note is a contract-only example — compiling it is the smoke test
# (no local network or JS dependencies required).
- name: Compile custom-note contract
working-directory: custom-note
run: |
ulimit -s unlimited
script -e -c "aztec compile"
2 changes: 1 addition & 1 deletion .github/workflows/note-send-proof-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
env:
AZTEC_ENV: local-network
AZTEC_VERSION: 4.3.0
AZTEC_VERSION: 5.0.0-rc.1

steps:
- name: Checkout repository
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/prediction-market-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
env:
AZTEC_ENV: local-network
AZTEC_VERSION: 4.3.0
AZTEC_VERSION: 5.0.0-rc.1

steps:
- name: Checkout repository
Expand All @@ -29,10 +29,8 @@ jobs:
with:
node-version: "22"

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.1.36
- name: Enable Corepack for Yarn
run: corepack enable

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down Expand Up @@ -67,7 +65,7 @@ jobs:

- name: Install project dependencies
working-directory: prediction-market
run: bun install
run: yarn install

- name: Run Noir unit tests
working-directory: prediction-market
Expand All @@ -85,7 +83,7 @@ jobs:

- name: Run end-to-end tests
working-directory: prediction-market
run: bun test
run: yarn test
timeout-minutes: 15

- name: Upload test results if failed
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/recursive-verification-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
env:
AZTEC_ENV: local-network
AZTEC_VERSION: 4.3.0
AZTEC_VERSION: 5.0.0-rc.1

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-wallet-webapp-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Test Wallet Webapp Tests
runs-on: ubuntu-latest
env:
AZTEC_VERSION: 4.3.0
AZTEC_VERSION: 5.0.0-rc.1

steps:
- name: Checkout repository
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ target
.DS_Store
ivc
node_modules
.playwright-mcp
101 changes: 30 additions & 71 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,23 @@ This is a collection of Aztec smart contract examples written in Noir, designed

```
aztec-examples/
├── recursive_verification/ # Noir proof verification in Aztec contracts example
├── custom-note/ # Defining a custom private note type
├── note-send-proof/ # Off-chain note-hash proofs + Vite frontend
│ ├── circuits/ # Vanilla Noir circuit (aztec-nargo)
│ ├── uint-note/ # Local copy of the uint-note note library
│ ├── sample-contract/ # Aztec contract under test
│ ├── scripts/ # Proof/data generation (TypeScript)
│ ├── tests/ # Jest integration tests
│ └── vite/ # React frontend
├── prediction-market/ # Private CSMM prediction market (uint-note partial notes)
├── recursive_verification/ # Verify Noir UltraHonk proofs inside an Aztec contract
│ ├── circuit/ # Noir circuit that generates proofs (proves x ≠ y)
│ ├── contract/ # Aztec contract that verifies Noir proofs
│ ├── scripts/ # TypeScript utilities for proof generation and deployment
│ ├── tests/ # Integration test suite
│ ├── data.json # Generated proof data (created by `yarn data`)
│ ├── README.md # Comprehensive documentation
│ ├── CLAUDE.md # Project-specific AI guidance
│ ├── EXPLAINER.md # Technical deep-dive explanation
│ └── run-tests.sh # Local test runner script
├── starter-token/ # Token contract example with start-here and reference implementations
│ ├── start-here/ # Template for implementing a token
│ │ ├── contract/ # Noir contract code
│ │ ├── external-call-contract/ # Cross-contract calls
│ │ └── ts/ # TypeScript client code
│ └── reference/ # Complete reference implementation
│ ├── contract/ # Full token implementation
│ ├── external-call-contract/ # Cross-contract example
│ └── ts/ # TypeScript client
└── .github/ # CI/CD configuration
└── workflows/
└── recursive-verification-tests.yml # Automated testing workflow
│ ├── contract/ # Aztec contract that verifies Noir proofs
│ ├── scripts/ # TypeScript utilities for proof generation and deployment
│ ├── tests/ # Vitest integration test suite
│ └── data.json # Generated proof data (created by `yarn data`)
├── test-wallet-webapp/ # Vite/React app: embedded wallet + deploy + tx
└── .github/workflows/ # CI: one *-tests.yml per tested example
```

## Development Commands
Expand All @@ -54,7 +49,7 @@ aztec-examples/
bash -i <(curl -s https://install.aztec.network)

# Set specific version (examples may require different versions)
aztec-up 4.3.0 # For recursive_verification
aztec-up 5.0.0-rc.1 # For recursive_verification
```

### Building Contracts
Expand All @@ -71,7 +66,7 @@ yarn ccc # Compiles contract and generates TypeScript bindings

### Building Vanilla Noir Circuits

The compatible `nargo` (version 1.0.0-beta.21) is bundled with the Aztec CLI at `~/.aztec/current/bin/aztec-nargo`. As of Aztec v4.3.0, bundled binaries are exposed only under their `aztec-` prefixed names — invoke `aztec-nargo` (a drop-in for `nargo`) rather than the bare name, which is no longer on `PATH`. Ensure `~/.aztec/current/bin` is on your `PATH` (the Aztec installer adds this automatically).
The compatible `nargo` (version 1.0.0-beta.22) is bundled with the Aztec CLI at `~/.aztec/current/bin/aztec-nargo`. As of Aztec v4.3.0, bundled binaries are exposed only under their `aztec-` prefixed names — invoke `aztec-nargo` (a drop-in for `nargo`) rather than the bare name, which is no longer on `PATH`. Ensure `~/.aztec/current/bin` is on your `PATH` (the Aztec installer adds this automatically).

```bash
# Verify nargo is available
Expand Down Expand Up @@ -177,22 +172,6 @@ yarn test
cd circuit && aztec-nargo test
```

### Starter Token Example

```bash
# Navigate to reference implementation
cd starter-token/reference

# Build the contract
cd contract && aztec compile && cd ..

# Build and run TypeScript client
cd ts
npm install
npm run build
npm start
```

## Contract Architecture

### Aztec Contract Structure
Expand All @@ -216,19 +195,10 @@ The recursive verification example demonstrates:

- **Off-chain proof generation**: Noir circuits compiled and executed with Barretenberg
- **On-chain verification**: Using `bb_proof_verification::verify_honk_proof` in Aztec contracts
- **UltraHonk proving system**: Generates proofs with 508 field elements, verification keys with 115 fields
- **UltraHonk proving system**: Generates proofs with 458 field elements, verification keys with 115 fields
- **VK Hash Storage**: Verification key hash stored in `PublicImmutable` storage, readable from private context
- **Public state management**: Using `PublicMutable` for per-user counters

### Token Pattern (starter-token)

The token example showcases:

- **Dual balance system**: Public and private token balances
- **State management**: Using `PublicMutable` and `Map` for storage
- **Access control**: Owner-based permissions for minting
- **Cross-contract calls**: External contract interactions

### Testing Pattern

Tests use the Testing Execution Environment (TXE):
Expand Down Expand Up @@ -256,13 +226,13 @@ Aztec contracts specify dependencies in `Nargo.toml`:

```toml
[dependencies]
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "vX.X.X", directory = "noir-projects/aztec-nr/aztec" }
easy_private_state = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "vX.X.X", directory = "noir-projects/aztec-nr/easy-private-state" }
aztec = { git = "https://github.com/AztecProtocol/aztec-nr/", tag = "v5.0.0-rc.1", directory = "aztec" }
uint_note = { git = "https://github.com/AztecProtocol/aztec-nr/", tag = "v5.0.0-rc.1", directory = "uint-note" }
```

**Version Compatibility**: All examples use the same Aztec version:

- All examples: v4.3.0
- All examples: v5.0.0-rc.1

### JavaScript/TypeScript Dependencies

Expand All @@ -276,32 +246,21 @@ TypeScript projects use:
### Runtime Requirements

- **Node.js**: v22+ for all TypeScript examples
- **yarn**: Package manager for recursive_verification example
- **npm**: Package manager for starter-token example
- **yarn**: Package manager used across the TypeScript examples
- **Docker**: Required for running Aztec local network
- **Memory**: 8GB+ RAM recommended for proof generation

## CI/CD

The repository includes GitHub Actions workflows for automated testing:

### recursive-verification-tests.yml

Runs on:

- Push to next branch
- Pull requests modifying `recursive_verification/**`
- Manual workflow dispatch
GitHub Actions workflows automatically test examples on pull requests to `next` (and pushes to `next`). Each tested example has its own workflow under `.github/workflows/`:

Steps:
- `recursive-verification-tests.yml`
- `prediction-market-tests.yml`
- `note-send-proof-tests.yml`
- `test-wallet-webapp-tests.yml`
- `custom-note-tests.yml`

1. Sets up Node.js (v22) and yarn
2. Installs Aztec CLI
3. Starts Aztec local network
4. Compiles circuits and contracts
5. Generates proof data
6. Runs integration tests
7. Uploads test artifacts on failure
Each workflow installs the pinned Aztec CLI (`AZTEC_VERSION`), starts a local network when the example's tests need one, compiles circuits/contracts, and runs that example's tests (uploading logs on failure). The `custom-note` workflow is contract-only, so it just compiles.

## Common Issues and Solutions

Expand Down
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A collection of example Aztec smart contracts and circuits written in Noir, desi

## Overview

This repository contains practical examples demonstrating various features of Aztec's zero-knowledge smart contract platform, from basic token implementations to advanced proof verification patterns.
This repository contains practical examples demonstrating various features of Aztec's zero-knowledge smart contract platform, from custom notes to advanced proof verification patterns.

You can find additional examples in the Aztec monorepo [docs examples folder](https://github.com/AztecProtocol/aztec-packages/tree/next/docs/examples), including:

Expand All @@ -16,25 +16,27 @@ You can find additional examples in the Aztec monorepo [docs examples folder](ht

## Examples

### 1. [Recursive Verification](./recursive_verification)
All examples target **Aztec v5.0.0-rc.1**.

**Aztec Version**: 4.3.0
### [custom-note](./custom-note)

Demonstrates how to verify Noir circuit proofs within Aztec smart contracts using the UltraHonk proving system. This example showcases:
Defining a custom private note type with the `#[note]` macro and inserting it from a contract.

- Zero-knowledge proof generation from Noir circuits
- On-chain proof verification in private smart contracts
- Private state management using `EasyPrivateUint`
- Integration between off-chain proving and on-chain verification
### [note-send-proof](./note-send-proof)

**Key features**:
Creating private notes and proving facts about their note hashes off-chain (with `bb.js` / `noir_js`), then verifying them on-chain. Includes a Vite/React frontend.

- Circuit that proves two values are not equal (x ≠ y)
- Smart contract that verifies proofs and maintains private counters
- Comprehensive test suite and GitHub Actions CI/CD pipeline
- TypeScript utilities for proof generation and contract deployment
### [prediction-market](./prediction-market)

[View README](./recursive_verification/README.md)
A private prediction market built on a constant-sum market maker (CSMM), using `uint_note` partial notes for private deposits, withdrawals, and outcome purchases.

### [recursive_verification](./recursive_verification)

Verifying Noir UltraHonk proofs _inside_ an Aztec contract: off-chain proof generation, on-chain verification with `bb_proof_verification::verify_honk_proof`, VK-hash storage in `PublicImmutable`, and per-user private counters.

### [test-wallet-webapp](./test-wallet-webapp)

A minimal Vite/React app that connects to an embedded Aztec wallet/PXE, creates an initializerless Schnorr account, deploys a contract, and sends transactions.

## Quick Start

Expand All @@ -45,7 +47,7 @@ Demonstrates how to verify Noir circuit proofs within Aztec smart contracts usin
bash -i <(curl -s https://install.aztec.network)

# Set specific Aztec version (if needed)
aztec-up 4.3.0
aztec-up 5.0.0-rc.1
```

## Development Workflow
Expand All @@ -63,7 +65,7 @@ Each example includes its own test suite:
```bash
# Recursive Verification tests
cd recursive_verification
bun test
yarn test

# Run with CI-like environment
./run-tests.sh
Expand Down
1 change: 0 additions & 1 deletion account-contract/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion account-contract/.yarnrc.yml

This file was deleted.

8 changes: 0 additions & 8 deletions account-contract/Nargo.toml

This file was deleted.

Loading
Loading