- Sample Noir contract
- Basic Counter contract demonstrating private-to-public execution patterns and owner access control.
- Aztec development setup
- Pre-configured Aztec workspace with Noir contract compilation and TypeScript artifact generation.
- TypeScript integration
- Complete TypeScript setup with generated contract bindings and utilities for interacting with Aztec sandbox.
- Comprehensive testing
- Noir unit tests for contract logic and TypeScript integration tests using Vitest. Tests automatically start and manage the Aztec sandbox - no manual setup required.
- Automated benchmarking
- GitHub Actions workflow that automatically benchmarks your contracts on every PR, comparing Gates, DA Gas and L2 Gas against the base branch.
- Development tooling
- Integrated linting with Prettier and streamlined build commands for rapid development.
- Install Aztec by following the instructions from their documentation.
- Install the dependencies by running:
yarn install
- Ensure you have Docker installed and running (required for Aztec sandbox)
The complete build pipeline includes cleaning, compiling Noir contracts, and generating TypeScript artifacts:
yarn build
This runs:
yarn clean
- Removes all build artifactsyarn compile
- Compiles Noir contracts using aztec-nargoyarn codegen
- Generates TypeScript bindings from compiled contracts
The tests automatically start and manage the Aztec sandbox for you.
Option 1: Automatic Just run the tests and the sandbox will be handled automatically:
yarn test # Sandbox starts automatically and stops when tests complete
Option 2: Manual Control If you prefer to manage the sandbox yourself (e.g., for debugging or multiple test runs):
aztec start --sandbox # Start manually in separate terminal
yarn test # Run tests against existing sandbox
The sandbox runs on http://localhost:8080
by default.
Run both Noir contract tests and TypeScript integration tests:
yarn test
Test your contract logic directly:
yarn test:nr
Test contract interactions through TypeScript:
yarn test:js
This repository includes automated benchmarking that measures and compares performance metrics across pull requests.
- Gates: Total gate count in zero-knowledge circuits (measures circuit complexity)
- DA Gas: Data Availability gas costs
- L2 Gas: Layer 2 execution gas costs
Every pull request automatically:
- Runs benchmarks on the base branch
- Runs benchmarks on your PR branch
- Generates a comparison report as a PR comment
- Shows performance improvements or regressions
Benchmarks also benefit from automatic sandbox management:
# Option 1: Automatic sandbox management (recommended)
yarn benchmark # Sandbox starts automatically
# Option 2: Manual sandbox control
aztec start --sandbox # Start manually in separate terminal
yarn benchmark # Run against existing sandbox
Benchmark results are saved to benchmarks/
directory.
Create a new benchmark file extending the base Benchmark
class or add a new method line to your existing setup:
import { Benchmark } from '@defi-wonderland/aztec-benchmark';
export class MyContractBenchmark extends Benchmark {
async setup() {
// Initialize your contract and dependencies
}
getMethods(context: CounterBenchmarkContext): BenchmarkedInteraction[] {
const { contract, accounts } = context;
const [alice] = accounts;
const methods = [
// Add the function calls that you want to benchmark here
contract.withWallet(alice).methods.method(1),
] as BenchmarkedInteraction[];
return methods.filter(Boolean);
}
}
├── src/
│ ├── nr/ # Noir contracts
│ │ └── counter_contract/ # Example Counter contract
│ ├── ts/ # TypeScript tests and utilities
│ └── artifacts/ # Generated TypeScript bindings
├── benchmarks/ # Performance benchmarking
├── target/ # Compiled Noir artifacts
└── .github/
└── workflows/ # CI/CD pipelines
The Counter contract demonstrates key Aztec patterns:
The increment()
function is private but enqueues a public increment_internal()
call. This pattern maintains privacy while updating public state.
- Owner: Immutable address set at deployment
- Counter: Mutable public value
constructor
: Initializes contract with ownerget_owner
: Returns owner address (public)increment
: Private function that enqueues public state updateincrement_internal
: Internal public function for state modificationget_counter
: Returns current counter value (public)
- Modify Noir contracts in
src/nr/
- Run
yarn build
to rebuild and regenerate TypeScript artifacts - Write tests in
src/ts/
using generated artifacts - Run tests with
yarn test
(sandbox starts automatically) - Format code with
yarn lint:prettier
- Create PR and review automated benchmark results
Format all TypeScript and JavaScript files:
yarn lint:prettier
This project uses Conventional Commits to ensure consistent and meaningful commit messages. All commits are automatically validated using commitlint.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Write tests for your changes
- Ensure all tests pass and benchmarks are acceptable
- Follow commit guidelines
- Commit your changes (
git commit -m 'feat: add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
The automated benchmarking will run on your PR, providing performance insights compared to the base branch.
This project is licensed under the MIT License - see the LICENSE file for details.