Project Structure
Relevant source files
The following files were used as context for generating this wiki page:
Aztec Standards is a collection of reusable, standardized smart contracts designed for the Aztec Network. The project provides a framework for privacy-preserving applications by implementing token primitives (fungible and non-fungible), vaults, and escrow mechanisms. The architecture supports both private and public operations, utilizing Noir for contract logic and TypeScript for testing, deployment, and benchmarking.
The repository is structured to manage multi-language development, separating Noir source code, TypeScript testing utilities, and automated build scripts for generating artifacts. It serves as a foundation for developers building confidential DeFi protocols, such as staking pools or governance systems, by providing audited and standardized building blocks.
Sources: README.md:1-12, package.json:1-10
Core Directory Organization
The project follows a modular structure where individual contract types are isolated into their own subdirectories within src/. Each module typically contains its own Noir source code, documentation, and configuration.
Directory Mapping
| Directory | Purpose | Key Files |
|---|---|---|
src/ | Main source code for Noir contracts and TypeScript artifacts. | Noir contracts, deployments.json |
src/ts/test/ | TypeScript test suites and shared utilities. | utils.ts, token.test.ts, escrow.test.ts |
benchmarks/ | Performance testing scripts for contract methods. | token_contract.benchmark.ts, logic_contract.benchmark.ts |
scripts/ | Shell scripts for CI/CD and build processes. | build-package.sh |
target/ | Compiled Noir artifacts (JSON format). | Generated by aztec compile |
Sources: scripts/build-package.sh:7-35, src/ts/test/utils.ts:30-40, package.json:10-25
Build and Artifact Pipeline
The project utilizes a multi-stage pipeline to transform Noir source code into usable TypeScript/JavaScript artifacts. This process is orchestrated via scripts/build-package.sh and the package.json scripts.
The diagram above shows the flow from raw Noir code to the final distribution package.
- Compilation: Noir contracts are compiled into JSON artifacts stored in the
target/directory using theaztec compilecommand. - Codegen: The
aztec codegenutility generates TypeScript interfaces and classes from the JSON artifacts, placing them insrc/artifacts/. - Transpilation: TypeScript artifacts are transpiled to JavaScript using
tsc, targeting thenodenextmodule resolution for modern Node.js compatibility. - Packaging: The
build-package.shscript aggregates these artifacts, Noir JSON files, and a trimmedpackage.jsoninto anexport/directory for distribution.
Sources: package.json:14-25, scripts/build-package.sh:7-14, tsconfig.json:3-15
Dependency Management
The project manages dependencies for both the Noir environment and the TypeScript testing environment. Noir dependencies are defined in Nargo.toml files found within each contract subdirectory, while TypeScript dependencies are in the root package.json.
Noir Dependencies (Nargo.toml)
Noir contracts depend on standard Aztec libraries for core functionality like private state management and cryptographic primitives.
aztec: Core Aztec Noir library.uint_note: Utilities for managing numeric private notes.balance_set: Logic for private balance management.compressed_string: Efficient string handling in circuits.
TypeScript Dependencies (package.json)
The TypeScript environment relies on the @aztec suite of packages for interacting with the Private eXecution Environment (PXE) and the Aztec node.
@aztec/aztec.js: Primary SDK for contract interaction.@aztec/test-wallet: Sandbox environment for automated testing.@defi-wonderland/aztec-benchmark: Framework for measuring circuit performance.
Sources: src/token_contract/Nargo.toml:7-13, package.json:31-40
Testing and Benchmarking Infrastructure
The infrastructure in src/ts/test/utils.ts provides a robust foundation for simulating complex Aztec transactions. It includes utilities for deploying contracts with specific initializers (e.g., constructor_with_minter) and managing "AuthWitnesses" for private authorizations.
The sequence diagram illustrates the interaction between TypeScript tests and the underlying Aztec infrastructure.
Key Testing Components
| Function | File | Description |
|---|---|---|
setupTestSuite | utils.ts | Initializes a fresh Aztec node client, creates test wallets, and registers network accounts. |
deployEscrow | utils.ts | Deploys an escrow instance using universalDeploy and predicted salts. |
setPrivateAuthWit | utils.ts | Creates a private authorization witness allowing one account to call a function on behalf of another. |
decryptRawPrivateLog | utils.ts | Low-level utility to decrypt private logs using AES-128-CBC and ECDH shared secrets. |
Sources: src/ts/test/utils.ts:60-85, src/ts/test/utils.ts:210-230, benchmarks/logic_contract.benchmark.ts:40-65
Standard Implementation Modules
The project is organized around several key standards, each represented by a contract module:
- Token Contract: Implements AIP-20 for fungible tokens with private/public balance support.
- NFT Contract: Implements AIP-721 for non-fungible tokens.
- Escrow Standard: A two-part system consisting of an
Escrow Contract(minimal private storage) and aLogic Libraryfor delegated release logic. - Tokenized Vault: An implementation of AIP-4626 for yield-bearing shares.
Sources: README.md:15-50, src/escrow_contract/README.md:1-15
Conclusion
The project structure of Aztec Standards is designed for scalability and developer ergonomics within the Aztec ecosystem. By strictly separating Noir contract logic from TypeScript tooling and providing comprehensive benchmarking and testing utilities, the repository ensures that privacy-preserving primitives can be reliably built, verified, and integrated into larger decentralized applications.
Sources: README.md:5-12, package.json:14-25