> For the complete documentation index, see [llms.txt](/llms.txt)

# Compiling Contracts

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` installed
* Contract project with proper `Nargo.toml` configuration

## Compile your contract

Compile your Noir contracts to generate JSON artifacts:

```bash
aztec compile
```

This outputs contract artifacts to the `target` folder.

## 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:

```rust
contract MyContract {
    use token::Token;

    #[external("private")]
    fn transfer_tokens(token_address: AztecAddress, recipient: AztecAddress, amount: u128) {
        // Use the generated Token interface to call another contract
        self.call(Token::at(token_address).transfer(recipient, amount));
    }

    #[external("private")]
    fn transfer_then_mint(token_address: AztecAddress, recipient: AztecAddress, amount: u128) {
        // Private call executed immediately
        self.call(Token::at(token_address).transfer(recipient, amount));

        // Public call enqueued for later execution
        self.enqueue(Token::at(token_address).mint_to_public(recipient, amount));
    }
}
```

warning

Do not import generated interfaces from the same project as the source contract to avoid circular references.

## Test your contract

Run your contract's tests with the `aztec` CLI, not `nargo test`:

```bash
aztec test
```

`aztec test` compiles the workspace first (a no-op when nothing changed), starts the TXE test environment that `TestEnvironment` connects to, and runs the workspace's `#[test]` functions through `nargo test`. To write tests, see [Testing contracts](/developers/docs/aztec-nr/testing_contracts.md).

## 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
