Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5f9bee9
refactor: aztec new and init creating 2 crates
benesjan Feb 20, 2026
03a2410
refactor: aztec new and init creating 2 crates (#20681)
benesjan Feb 20, 2026
55975d8
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
0c5202d
fix: hodgepodge of small things (#20720)
Thunkar Feb 20, 2026
08834de
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
11309f4
test: aztec new scaffold works (#20711)
benesjan Feb 20, 2026
06e6c24
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
1508091
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
56686e4
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
40da7cb
feat: add `aztec profile` command with gate count profiling (#20695)
nchamo Feb 20, 2026
f28dfde
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
b425e7f
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
c185ee0
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
6a94eb4
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
b54f2b7
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
eba601a
Merge branch 'next' into merge-train/fairies
Feb 20, 2026
0f3a219
Merge branch 'next' into merge-train/fairies
Feb 21, 2026
beb96cc
Merge branch 'next' into merge-train/fairies
Feb 21, 2026
4c5d4fe
Merge branch 'next' into merge-train/fairies
Feb 21, 2026
ccc24c0
Merge branch 'next' into merge-train/fairies
Feb 22, 2026
86c8d3c
Merge branch 'next' into merge-train/fairies
Feb 23, 2026
a711149
fix(txe): committing after txs (#20714)
benesjan Feb 23, 2026
0d669bb
Merge branch 'next' into merge-train/fairies
Feb 23, 2026
b6d0507
Merge branch 'next' into merge-train/fairies
Feb 23, 2026
8ae73d5
feat: add aztec profile flamegraph command (#20741)
nchamo Feb 23, 2026
4982688
feat: printing out public contract function debug logs in a tx (#20749)
benesjan Feb 23, 2026
284ae9b
Merge branch 'next' into merge-train/fairies
Feb 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aztec-up/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ EOF
}

function test_cmds {
for test in amm_flow bridge_and_claim basic_install counter_contract; do
for test in amm_flow bridge_and_claim basic_install counter_contract default_scaffold; do
echo "$hash:TIMEOUT=15m aztec-up/scripts/run_test.sh $test"
done
}
Expand Down
26 changes: 18 additions & 8 deletions aztec-up/test/counter_contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,37 @@ export LOG_LEVEL=silent

# Execute commands as per: https://docs.aztec.network/tutorials/codealong/contract_tutorials/counter_contract
aztec new counter_contract
if [ ! -f counter_contract/Nargo.toml ] || [ ! -f counter_contract/src/main.nr ]; then
echo "Failed to create contract."

# Verify workspace structure
if [ ! -f counter_contract/Nargo.toml ]; then
echo "Failed to create workspace Nargo.toml."
exit 1
fi
if [ ! -f counter_contract/contract/Nargo.toml ] || [ ! -f counter_contract/contract/src/main.nr ]; then
echo "Failed to create contract crate."
exit 1
fi
if [ ! -f counter_contract/test/Nargo.toml ] || [ ! -f counter_contract/test/src/lib.nr ]; then
echo "Failed to create test crate."
exit 1
fi

# Check counter_contract dir is owned by aztec-dev.
# Check counter_contract dir is owned by ubuntu.
if [ "$(stat -c %U counter_contract)" != "ubuntu" ]; then
echo "counter_contract dir is not owned by ubuntu."
exit 1
fi

# "Write" our contract.
cp -Rf ./aztec-packages/noir-projects/noir-contracts/contracts/test/counter_contract .
# "Write" our contract over the scaffold.
cp -Rf ./aztec-packages/noir-projects/noir-contracts/contracts/test/counter_contract/* counter_contract/
cd counter_contract
sed -i 's|\.\./\.\./\.\./\.\./|/home/ubuntu/aztec-packages/noir-projects/|g' Nargo.toml
sed -i 's|\.\./\.\./\.\./\.\./\.\./|/home/ubuntu/aztec-packages/noir-projects/|g' contract/Nargo.toml test/Nargo.toml

# Compile the contract.
aztec compile
# Codegen
aztec codegen -o src/artifacts target
if [ ! -d src/artifacts ]; then
aztec codegen -o contract/src/artifacts target
if [ ! -d contract/src/artifacts ]; then
echo "Failed to codegen TypeScript."
exit 1
fi
Expand Down
36 changes: 36 additions & 0 deletions aztec-up/test/default_scaffold.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail

# Tests that the default scaffold generated by `aztec new` compiles and passes its tests without any modifications.
# This catches regressions in the template files produced by setup_workspace.sh (e.g. syntax errors, stale imports,
# or API changes in aztec-nr) that would otherwise go unnoticed until a user runs `aztec new` themselves.

export LOG_LEVEL=silent

aztec new my_contract

# Verify workspace structure.
if [ ! -f my_contract/Nargo.toml ]; then
echo "Failed to create workspace Nargo.toml."
exit 1
fi
if [ ! -f my_contract/contract/Nargo.toml ] || [ ! -f my_contract/contract/src/main.nr ]; then
echo "Failed to create contract crate."
exit 1
fi
if [ ! -f my_contract/test/Nargo.toml ] || [ ! -f my_contract/test/src/lib.nr ]; then
echo "Failed to create test crate."
exit 1
fi

cd my_contract

# This is unfortunate as it makes the test worse but in CI setting the aztec version is 0.0.1 which doesn't exist as
# a remote git tag, so we need to rewrite dependencies to use local aztec-nr.
sed -i 's|aztec = .*git.*AztecProtocol/aztec-nr.*|aztec = { path="/home/ubuntu/aztec-packages/noir-projects/aztec-nr/aztec" }|' contract/Nargo.toml test/Nargo.toml

# Compile the default scaffold contract.
aztec compile

# Run the default scaffold tests.
aztec test
2 changes: 2 additions & 0 deletions boxes/init/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
codegenCache.json
8 changes: 2 additions & 6 deletions boxes/init/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
[package]
name = "init"
type = "contract"

[dependencies]
aztec = { path = "../../noir-projects/aztec-nr/aztec" }
[workspace]
members = ["contract", "test"]
27 changes: 27 additions & 0 deletions boxes/init/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# init

An Aztec Noir contract project.

## Compile

```bash
aztec compile
```

This compiles the contract in `contract/` and outputs artifacts to `target/`.

## Test

```bash
aztec test
```

This runs the tests in `test/`.

## Generate TypeScript bindings

```bash
aztec codegen target -o src/artifacts
```

This generates TypeScript contract artifacts from the compiled output in `target/` into `src/artifacts/`.
6 changes: 6 additions & 0 deletions boxes/init/contract/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "init"
type = "contract"

[dependencies]
aztec = { path = "../../../noir-projects/aztec-nr/aztec" }
10 changes: 10 additions & 0 deletions boxes/init/contract/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use aztec::macros::aztec;

#[aztec]
pub contract Main {
use aztec::macros::functions::{external, initializer};

#[initializer]
#[external("private")]
fn constructor() {}
}
9 changes: 0 additions & 9 deletions boxes/init/src/main.nr

This file was deleted.

7 changes: 7 additions & 0 deletions boxes/init/test/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "init_test"
type = "lib"

[dependencies]
aztec = { path = "../../../noir-projects/aztec-nr/aztec" }
init = { path = "../contract" }
17 changes: 17 additions & 0 deletions boxes/init/test/src/lib.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use aztec::test::helpers::test_environment::TestEnvironment;
use init::Main;

#[test]
unconstrained fn test_constructor() {
let mut env = TestEnvironment::new();
let deployer = env.create_light_account();

// Deploy the contract with the default constructor:
let contract_address = env.deploy("@init/Main").with_private_initializer(
deployer,
Main::interface().constructor(),
);

// Deploy without an initializer:
let contract_address = env.deploy("@init/Main").without_initializer();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ High-level structure of how Aztec smart contracts including the different compon

## Directory structure

Here's a common layout for a basic Aztec.nr Contract project:
When you create a new project with `aztec new`, it generates a workspace with two crates: a `contract` crate for your smart contract and a `test` crate for Noir tests.

```text title="layout of an aztec contract project"
─── my_aztec_contract_project
├── src
│ └── main.nr <-- your contract
└── Nargo.toml <-- package and dependency management
├── Nargo.toml <-- workspace root
├── contract
│ ├── src
│ │ └── main.nr <-- your contract
│ └── Nargo.toml <-- contract package and dependencies
└── test
├── src
│ └── lib.nr <-- your tests
└── Nargo.toml <-- test package and dependencies
```

The workspace root `Nargo.toml` declares both crates as workspace members. The contract code lives in `contract/src/main.nr`, and tests live in a separate `test` crate that depends on the contract crate.

See the vanilla Noir docs for [more info on packages](https://noir-lang.org/docs/noir/modules_packages_crates/crates_and_packages).

## Contract block
Expand Down
7 changes: 3 additions & 4 deletions docs/docs-developers/docs/aztec-nr/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ storage.votes.insert(new_vote).deliver(vote_counter); // the vote counter accoun

### Flow

1. Write your contract and specify your contract dependencies. Every contract written for Aztec will have
aztec-nr as a dependency. Add it to your `Nargo.toml` with
1. Write your contract and specify your contract dependencies. Create a new project with `aztec new my_project`, which sets up a workspace with a `contract` crate and a `test` crate, with the `aztec` dependency already configured. If you need additional dependencies, add them to `contract/Nargo.toml`:

```toml
# Nargo.toml
# contract/Nargo.toml
[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-nr/", tag="#include_aztec_version", directory="aztec" }
```

Update your `main.nr` contract file to use the Aztec.nr macros for writing contracts.
Update your `contract/src/main.nr` contract file to use the Aztec.nr macros for writing contracts.

#include_code setup /docs/examples/contracts/counter_contract/src/main.nr rust

Expand Down
13 changes: 7 additions & 6 deletions docs/docs-developers/docs/aztec-nr/testing_contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ Always use `aztec test` instead of `nargo test`. The `TestEnvironment` requires

## Basic test structure

When you create a project with `aztec new` or `aztec init`, a separate `test` crate is created alongside the `contract` crate. Tests live in `test/src/lib.nr` and import the contract crate by name (not `crate::`):

```rust
use crate::MyContract;
use my_contract::MyContract;
use aztec::{
protocol::address::AztecAddress,
test::helpers::test_environment::TestEnvironment,
Expand All @@ -72,12 +74,11 @@ unconstrained fn test_basic_flow() {
:::

:::tip Organizing test files
You can organize tests in separate files:
Tests live in the separate `test` crate that `aztec new` creates. You can organize them into modules:

- Create `src/test.nr` with `mod utils;` to import helper functions
- Split tests into modules like `src/test/transfer_tests.nr`, `src/test/auth_tests.nr`
- Import the test module in `src/main.nr` with `mod test;`
- Share setup functions in `src/test/utils.nr`
- Split tests into modules like `test/src/transfer_tests.nr`, `test/src/auth_tests.nr`
- Import them in `test/src/lib.nr` with `mod transfer_tests;`, `mod auth_tests;`
- Share setup functions in `test/src/utils.nr`
:::

## Deploying contracts
Expand Down
26 changes: 26 additions & 0 deletions docs/docs-developers/docs/resources/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,32 @@ Aztec is in active development. Each version may introduce breaking changes that

## TBD

### `aztec new` and `aztec init` now create a 2-crate workspace

`aztec new` and `aztec init` now create a workspace with two crates instead of a single contract crate:

- A `contract` crate (type = "contract") for your smart contract code
- A `test` crate (type = "lib") for Noir tests, which depends on the contract crate

The new project structure looks like:

```
my_project/
├── Nargo.toml # [workspace] members = ["contract", "test"]
├── contract/
│ ├── src/main.nr
│ └── Nargo.toml # type = "contract"
└── test/
├── src/lib.nr
└── Nargo.toml # type = "lib"
```

**What changed:**
- The `--contract` and `--lib` flags have been removed from `aztec new` and `aztec init`. These commands now always create a contract workspace.
- Contract code is now at `contract/src/main.nr` instead of `src/main.nr`.
- The `Nargo.toml` in the project root is now a workspace file. Contract dependencies go in `contract/Nargo.toml`.
- Tests should be written in the separate `test` crate (`test/src/lib.nr`) and import the contract by package name (e.g., `use my_contract::MyContract;`) instead of using `crate::`.

### Scope enforcement for private state access (TXE and PXE)

Scope enforcement is now active across both TXE (test environment) and PXE (client). Previously, private execution could implicitly access any account's keys and notes. Now, only the caller (`from`) address is in scope by default, and accessing another address's private state requires explicitly granting scope.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,28 @@ This tutorial is compatible with the Aztec version `#include_aztec_version`. Ins
Run this to create a new contract project:

```bash
aztec new --contract counter
aztec new counter
```

Your structure should look like this:

```tree
.
|-counter
| |-src
| | |-main.nr
| |-Nargo.toml
| |-Nargo.toml <-- workspace root
| |-contract
| | |-src
| | | |-main.nr
| | |-Nargo.toml <-- contract package config
| |-test
| | |-src
| | | |-lib.nr
| | |-Nargo.toml <-- test package config
```

The file `main.nr` will soon turn into our smart contract!
The `aztec new` command creates a workspace with two crates: a `contract` crate for your smart contract code and a `test` crate for Noir tests. The file `contract/src/main.nr` will soon turn into our smart contract!

Add the following dependencies to `Nargo.toml` under the autogenerated content:
Add the following dependency to `contract/Nargo.toml` under the existing `aztec` dependency:

```toml
[dependencies]
Expand All @@ -47,7 +53,7 @@ balance_set = { git="https://github.com/AztecProtocol/aztec-nr/", tag="#include_

## Define the functions

Go to `main.nr`, and replace the boilerplate code with this contract initialization:
Go to `contract/src/main.nr`, and replace the boilerplate code with this contract initialization:

```rust
#include_code setup /docs/examples/contracts/counter_contract/src/main.nr raw
Expand Down
Loading
Loading