Skip to content

Compile

  1. Tools
  2. Commands
  3. Unravelling Macros
  4. Contract Artifacts
  5. Structure of an Artifact
  6. 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-nargo installed (included with the sandbox)
  • Contract project with proper Nargo.toml configuration

Compile your contract

Step 1: Compile to JSON artifacts

Compile your Noir contracts to generate JSON artifacts:

aztec-nargo compile

This outputs contract artifacts to the target folder.

Step 2: Process for Aztec

Process the artifacts for Aztec compatibility:

aztec-postprocess-contract

This 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 Contract class from aztec.js
  • Interact with deployed contracts using type-safe interfaces
  • Import contracts in other Aztec.nr projects