Skip to main content
Version: v3.0.0-nightly.20251231

Contract Structure

A contract is a collection of persistent state variables and functions which may manipulate these variables. Functions and state variables within a contract's scope are said to belong to that contract.

A contract can only access and modify its own state. If a contract wishes to access or modify another contract's state, it must make a call to an external function of the other contract. For anything to happen on the Aztec network, an external function of a contract needs to be called.

Contract

A contract is declared using the #[aztec] attribute and the contract keyword. By convention, contracts are named in PascalCase.

setup
use dep::aztec::macros::aztec;

#[aztec]
pub contract Counter {
Source code: docs/examples/contracts/counter_contract/src/main.nr#L1-L6
A note for vanilla Noir devs

There is no main() function within a Noir contract scope. More than one function can be an entrypoint.

Directory structure

Here's a common layout for a basic Aztec.nr Contract project:

layout of an aztec contract project
─── my_aztec_contract_project
├── src
│ └── main.nr <-- your contract
└── Nargo.toml <-- package and dependency management

See the vanilla Noir docs for more info on packages.

Next steps