Deployment Configuration
Relevant source files
The following files were used as context for generating this wiki page:
Deployment configuration in the Aztec Standards project encompasses the automation scripts, utilities, and testing frameworks required to compile, derive addresses for, and deploy privacy-preserving smart contracts on the Aztec Network. This system ensures that contracts such as Tokens, NFTs, and Escrows are consistently instantiated with the correct parameters, salt, and public keys.
The configuration leverages the aztec CLI for compilation and contract inspection, while a TypeScript-based utility suite handles complex address derivation and wallet registration. This infrastructure is critical for maintaining the deterministic nature of Aztec contract addresses, which depend on contract class IDs, salted initialization hashes, and public keys.
Sources: scripts/build-package.sh, src/ts/test/utils.ts:321-360
Build and Artifact Management
The build process is centralized in the build-package.sh script, which orchestrates the transformation of Noir source code and TypeScript artifacts into a deployable package.
Build Pipeline
- Artifact Compilation: TypeScript contract artifacts are compiled using
tscinto thedist/artifacts/directory. - Contract Inspection: The script iterates through compiled Noir contracts in the
target/*.jsondirectory and runsaztec inspect-contractto validate their structure. - Deployment Data Packaging: If a
src/deployments.jsonfile exists, it is included in the export directory to maintain a record of deployed contract instances across environments. - Package Preparation: A trimmed version of
package.jsonis generated usingjq, stripping development-only dependencies to create a clean production artifact.
Sources: scripts/build-package.sh:1-42, package.json:11-20
Key Build Commands
| Command | Description | Source |
|---|---|---|
yarn compile | Compiles Noir contracts using the Aztec compiler. | package.json:15 |
yarn codegen | Generates TypeScript wrappers from compiled contract targets. | package.json:14 |
yarn build | Executes the full build shell script to prepare the distribution package. | package.json:12 |
aztec inspect-contract | Validates contract ABI and functions during the build process. | scripts/build-package.sh:13 |
Address Derivation Logic
In Aztec, contract addresses are not just hashes of the bytecode but are derived from several factors to support privacy and account abstraction. The project implements utilities to predict these addresses before deployment.
Address Components
The derivation of an AztecAddress involves:
- Contract Class ID: Derived from the compiled contract artifact.
- Initialization Hash: A hash of the constructor artifact and its specific arguments.
- Salt: A
Frfield used to ensure uniqueness or to link contracts (e.g., using a Logic contract address as the salt for its Escrow). - Public Keys: The master public keys associated with the contract instance.
Sources: src/ts/test/utils.ts:321-360, src/ts/test/escrow.test.ts:114-125
The following diagram illustrates the flow of data required to compute a contract address:
The logic ensures that if the same salt and keys are provided, the address remains deterministic.
Sources: src/ts/test/utils.ts:327-353
Deployment Utilities
The utils.ts file provides high-level abstractions for deploying specific standards. These utilities simplify the interaction with the ContractDeployer and handle the necessary wallet registrations.
Standardized Deployment Functions
| Function | Targeted Contract | Description |
|---|---|---|
deployTokenWithMinter | TokenContract | Deploys a token with a designated minter address and standard 18 decimals. |
deployNFTWithMinter | NFTContract | Deploys an NFT with metadata (Name, Symbol) and an initial minter. |
deployEscrow | EscrowContract | Performs a universal deployment of an escrow contract using provided public keys. |
deployVaultAndAssetWithMinter | Token (Vault) | Orchestrates a dual deployment of an underlying asset and a compliant Tokenized Vault. |
Sources: src/ts/test/utils.ts:133-145, src/ts/test/utils.ts:175-184, src/ts/test/utils.ts:219-236
Escrow Deployment Sequence
Escrow contracts require a specific deployment flow because they depend on master secret keys for private balance management.
Test Environment Configuration
The deployment configuration is heavily integrated with the testing suite via vitest. The setupTestSuite function initializes a local environment for contract interactions.
Environment Setup Logic
- Data Directory: Creates a unique temporary directory for the PXE (Private eXecution Environment) data storage.
- Prover Configuration: Optionally enables the Barretenberg prover for benchmarks.
- Account Registration: Automatically registers initial local network accounts in the provided wallet.
- Cleanup: Includes a closure to stop the wallet and recursively delete the temporary data directory.
Sources: src/ts/test/utils.ts:55-90, vitest.config.ts:16-33
Dependency Management
The vitest.config.ts ensures that complex cryptographic dependencies (like @noble/hashes and @aztec packages) are correctly resolved and inlined through the Vite transform pipeline to prevent module resolution errors in CI environments.
Sources: vitest.config.ts:9-15, package.json:44-55
Summary
The deployment configuration for Aztec Standards provides a robust framework for managing the lifecycle of privacy-preserving contracts. By automating the build pipeline, providing deterministic address derivation utilities, and abstracting deployment complexities through standardized helpers, the project ensures that developers can reliably deploy and test complex DeFi primitives on the Aztec Network.
Sources: scripts/build-package.sh, src/ts/test/utils.ts