Compile
- Tools
- Commands
- Unravelling Macros
- Contract Artifacts
- Structure of an Artifact
- Common Errors
This guide shows you how to compile your Aztec contracts into artifacts ready for deployment and interaction.
Prerequisites
- An Aztec contract written in Aztec.nr
aztec-nargoinstalled (included with the sandbox)- Contract project with proper
Nargo.tomlconfiguration
Compile your contract
Step 1: Compile to JSON artifacts
Compile your Noir contracts to generate JSON artifacts:
aztec-nargo compileThis outputs contract artifacts to the target folder.
Step 2: Process for Aztec
Process the artifacts for Aztec compatibility:
aztec-postprocess-contractThis step:
- Transpiles functions for the Aztec VM
- Generates verification keys for private functions
- Caches keys for faster subsequent compilations
Use generated interfaces
The compiler automatically generates type-safe interfaces for contract interaction.
Import and use contract interfaces
Use generated interfaces instead of manual function calls:
contract FPC {
use dep::token::Token;
#[private]
fn fee_entrypoint_private(amount: Field, asset: AztecAddress, secret_hash: Field, nonce: Field) {
assert(asset == storage.other_asset.read());
Token::at(asset).transfer_to_public(context.msg_sender(), context.this_address(), amount, nonce).call(&mut context);
FPC::at(context.this_address()).pay_fee_with_shielded_rebate(amount, asset, secret_hash).enqueue(&mut context);
}
}Next steps
After compilation, use the generated artifacts to:
- Deploy contracts with the
Contractclass fromaztec.js - Interact with deployed contracts using type-safe interfaces
- Import contracts in other Aztec.nr projects