Build System & Scripts
Relevant source files
The following files were used as context for generating this wiki page:
The Aztec Standards project utilizes a specialized build system designed to handle the compilation of Noir (NR) smart contracts, the generation of TypeScript (TS) artifacts, and the packaging of distribution-ready assets. The system integrates the Aztec CLI for contract compilation and code generation, while using standard Node.js tools like Yarn, TypeScript (tsc), and Vitest for development and testing workflows.
The primary goal of this build system is to transform raw Noir source code and TypeScript test utilities into a structured package under the export/@defi-wonderland/aztec-standards directory. This includes compiled bytecode, contract interfaces, and stripped-down metadata suitable for publication to registry services.
Sources: package.json:1-40, scripts/build-package.sh:1-10
Script Workflows
The project defines several core scripts in package.json to manage the lifecycle of Aztec contracts and their corresponding TypeScript wrappers.
Core Development Commands
| Command | Description | Implementation |
|---|---|---|
compile | Compiles Noir contracts into JSON artifacts | aztec compile |
codegen | Generates TS wrappers from compiled artifacts | aztec codegen target --outdir src/artifacts -f |
build | Executes the full packaging script | bash scripts/build-package.sh |
clean | Removes artifacts, targets, and cache | rm -rf ./src/artifacts ./target codegenCache.json |
test:nr | Runs native Noir contract tests | aztec test |
ccc | Sequential clean, compile, and codegen | yarn clean && yarn compile && yarn codegen |
Sources: package.json:14-25
Compilation and Artifact Flow
The build process follows a strict dependency chain where Noir source code must be compiled before TypeScript artifacts can be generated or tested.
The flow above illustrates how Noir contracts are transformed into usable JavaScript/TypeScript libraries.
Sources: package.json:17-19, scripts/build-package.sh:7-9
Packaging and Distribution
The build-package.sh script automates the creation of a distribution-ready directory. It handles the transition from development-heavy files to a clean export.
Process Steps
- JS Artifact Compilation: Compiles generated TypeScript artifacts using
tsctargetinges2020andnodenextmodule resolution. - Contract Inspection: Runs
aztec inspect-contracton all JSON files in thetarget/directory to validate metadata. - Directory Preparation: Creates an export structure under
export/@defi-wonderland/aztec-standards. - Resource Mirroring: Copies compiled JS artifacts, raw Noir contract targets, deployments, and documentation (README/LICENSE).
- Package Optimization: Uses
jqto stripdevDependencies,scripts, and other development-only fields frompackage.jsonbefore placing it in the export folder.
Sources: scripts/build-package.sh:7-40
Testing Infrastructure
The testing system is built on Vitest and includes automated environment management for the Aztec Sandbox.
Sandbox Management
The start-sandbox.ts script handles the lifecycle of the Aztec local node. It spawns the aztec start --sandbox process and implements a retry mechanism to ensure the node is responsive before tests begin.
Vitest Configuration
The vitest.config.ts file configures the execution environment, specifically handling the heavy requirements of the Aztec Sandbox.
- Timeouts: Both
hookTimeoutandtestTimeoutare set to 200,000ms (200 seconds) to accommodate ZK proof generation and sandbox latency. - Parallelism:
fileParallelismis disabled to prevent resource contention during sandbox interactions. - Dependency Inlining: Specific packages including
@aztec,@noble, andviemare inlined to ensure Vite's transform pipeline handles module resolution correctly.
Sources: vitest.config.ts:14-35
Configuration Management
TypeScript Setup
The project uses tsconfig.json to enforce strict typing and modern ESM standards. Key settings include:
- Module:
NodeNextfor modern Node.js compatibility. - Target:
es2020to support modern JavaScript features used in the Aztec SDK. - Paths: Includes
src,scripts, andartifactsto ensure comprehensive coverage during type checking.
Sources: tsconfig.json:3-23
Dependency Standards
Dependencies are strictly locked to the Aztec Devnet version 4.0.0-devnet.1-patch.0 across all contract Nargo.toml files and the root package.json. This ensures compatibility between the Noir circuits and the TypeScript SDK.
Sources: package.json:28-36, src/token_contract/Nargo.toml:8-12
Summary
The build system of aztec-standards provides a robust bridge between Noir smart contract development and TypeScript application integration. Through automated scripts like build-package.sh and environment managers like start-sandbox.ts, it ensures that contracts are consistently compiled, verified, and packaged for the Aztec Network.