Nargo Configuration
Relevant source files
The following files were used as context for generating this wiki page:
Nargo is the build system and package manager for Noir, the programming language used to write the smart contracts within the Aztec Standards repository. The Nargo configuration files (Nargo.toml) define the identity, dependencies, and compilation targets for each contract module, ensuring that the Noir compiler can correctly resolve external libraries and internal project references.
The configuration architecture is decentralized, with each contract—such as the Token, NFT, Escrow, and Dripper—maintaining its own Nargo.toml file. These configurations link to the core aztec-packages maintained by the Aztec Protocol, as well as local dependencies within the project's directory structure.
Core Package Structure
Every Noir contract in the project is defined as a type = "contract" in its respective configuration file. The package metadata typically includes the name of the contract and the required compiler version.
Package Metadata Common Fields
| Field | Description | Common Value |
|---|---|---|
name | The unique identifier for the Noir package | e.g., token_contract, nft_contract |
authors | The authors of the package | [""] (Empty in current configs) |
compiler_version | The version constraint for the Nargo compiler | >=1.0.0 |
type | The artifact type produced by the package | contract |
Sources: src/token_contract/Nargo.toml:1-5, src/nft_contract/Nargo.toml:1-5, src/escrow_contract/Nargo.toml:1-5
Dependency Management
The Aztec Standards contracts rely on a mix of remote Git dependencies and local path-based dependencies. This allows the contracts to utilize standardized Noir libraries provided by the Aztec Protocol while also referencing other internal standards (e.g., the Escrow contract depending on the Token contract).
Remote Dependencies
All contracts reference the aztec-packages repository to access core framework libraries. These are pinned to a specific tag to ensure build reproducibility.
The diagram above illustrates how local contracts inherit core functionality from the Aztec Protocol's Noir libraries while maintaining local inter-dependencies.
Sources: src/token_contract/Nargo.toml:8-13, src/nft_contract/Nargo.toml:8-11, src/escrow_contract/Nargo.toml:8-12
Local Dependency Resolution
Contracts frequently reference each other or shared utilities using relative paths. This is particularly evident in the Escrow and Dripper contracts.
| Contract | Local Dependency | Path |
|---|---|---|
token_contract | generic_proxy | ../generic_proxy |
nft_contract | generic_proxy | ../generic_proxy |
escrow_contract | token | ../token_contract |
escrow_contract | nft | ../nft_contract |
dripper | token | ../token_contract |
test_logic_contract | escrow_contract | ../../../ |
Sources: src/token_contract/Nargo.toml:14, src/nft_contract/Nargo.toml:12, src/escrow_contract/Nargo.toml:11-12, src/dripper/Nargo.toml:9, src/escrow_contract/src/test/test_logic_contract/Nargo.toml:10
Build Integration and Tooling
Nargo configuration is integrated into the broader project lifecycle through the package.json scripts and shell scripts. The project uses the aztec CLI (which wraps Nargo functionality) for compilation and testing.
Compilation Workflow
- Compile: Executing
yarn compiletriggersaztec compile, which reads theNargo.tomlfiles to build Noir artifacts. - Codegen: Executing
yarn codegenrunsaztec codegen, converting the compiled Noirtarget/*.jsonfiles into TypeScript artifacts. - Inspect: The build script iterates through the
target/directory and runsaztec inspect-contracton the Nargo-generated JSON files to extract contract interfaces.
Dependency Configuration Example
The token_contract provides a representative example of a complex Nargo configuration, requiring multiple specialized Aztec libraries to handle private state and protocol interfaces.
[dependencies]
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/%22%2C tag = "v4.0.0-devnet.1-patch.0", directory = "noir-projects/aztec-nr/aztec" }
uint_note = { git = "https://github.com/AztecProtocol/aztec-packages/%22%2C tag = "v4.0.0-devnet.1-patch.0", directory = "noir-projects/aztec-nr/uint-note" }
balance_set = { git = "https://github.com/AztecProtocol/aztec-packages/%22%2C tag = "v4.0.0-devnet.1-patch.0", directory = "noir-projects/aztec-nr/balance-set" }
compressed_string = { git = "https://github.com/AztecProtocol/aztec-packages/%22%2C tag = "v4.0.0-devnet.1-patch.0", directory = "noir-projects/aztec-nr/compressed-string" }
contract_instance_registry = { git = "https://github.com/AztecProtocol/aztec-packages/%22%2C tag = "v4.0.0-devnet.1-patch.0", directory = "noir-projects/noir-contracts/contracts/protocol_interface/contract_instance_registry_interface" }
generic_proxy = { path = "../generic_proxy" }
Sources: src/token_contract/Nargo.toml:8-14
Summary
The Nargo configuration within Aztec Standards establishes a modular environment where privacy-preserving contracts are built upon a foundation of standardized Aztec Protocol libraries. By using a combination of Git-tagged remote dependencies and local path references, the project ensures that its token, NFT, and escrow implementations remain compatible with the evolving Aztec Network specifications while facilitating internal interoperability.