Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ FROM --platform=linux/amd64 ubuntu:24.04
SHELL ["/bin/bash", "-c"]

ENV NVM_DIR=/root/.nvm
ENV NODE_VERSION=22.15.0
ARG AZTEC_VERSION=4.0.0-devnet.2-patch.1
ENV NODE_VERSION=24.12.0
ARG AZTEC_VERSION=4.2.0-aztecnr-rc.2
ENV AZTEC_VERSION=$AZTEC_VERSION
ENV NON_INTERACTIVE=1
ENV BIN_PATH=/usr/local/bin
Expand Down
40 changes: 0 additions & 40 deletions .github/workflows/devnet.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/local-network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
runs-on: ubuntu-latest
env:
AZTEC_ENV: local-network
AZTEC_VERSION: 4.2.0-aztecnr-rc.2

steps:
- name: Checkout repository
Expand All @@ -33,7 +34,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
node-version: "24"
cache: "yarn"

- name: Install Foundry
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
node-version: "24"
cache: "yarn"

- name: Install project dependencies
Expand Down
20 changes: 9 additions & 11 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

Aztec Starter — a Pod Racing game contract built with Noir on the Aztec network. Two players allocate points across 5 tracks over 3 rounds with private state; scores are revealed at the end (commit-reveal pattern). The player who wins more tracks (best of 5) wins.

**Aztec version: `4.1.0`** — pinned across `Nargo.toml`, `package.json`, `config/*.json`, and README. All must stay in sync when updating.
**Aztec version: `4.2.0-aztecnr-rc.2`** — pinned across `Nargo.toml`, `package.json`, `config/*.json`, and README. All must stay in sync when updating.

## Build & Development Commands

Expand Down Expand Up @@ -47,33 +47,31 @@ NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --

## Deployment & Scripts

All scripts support `::devnet` and `::testnet` suffixes for remote network targeting:
All scripts support `::testnet` suffixes for remote network targeting:

```bash
yarn deploy # Deploy contract to local network
yarn deploy::devnet # Deploy contract to devnet
yarn deploy::testnet # Deploy contract to testnet
yarn deploy-account # Deploy a Schnorr account
yarn multiple-wallet # Deploy from one wallet, interact from another
yarn profile # Profile a transaction deployment
yarn read-logs # Demo utility function for client-side debug logging
yarn read-logs::devnet # Same on devnet
yarn read-logs::testnet # Same on testnet
```

## Environment Configuration

- `AZTEC_ENV` variable selects config: `local-network` (default), `devnet`, or `testnet`
- Config files: `config/local-network.json`, `config/devnet.json`, `config/testnet.json`
- `AZTEC_ENV` variable selects config: `local-network` (default) or `testnet`
- Config files: `config/local-network.json`, `config/testnet.json`
- `config/config.ts` — singleton `ConfigManager` loads the appropriate JSON based on `AZTEC_ENV`
- `.env` stores secrets (SECRET, SIGNING_KEY, SALT, contract keys) — never commit

## Branch Model

- **`next` branch** — default branch; used for local network and devnet development
- **`next` branch** — default branch; used for local network development
- **`testnet` branch** — used for testnet development; may run a different Aztec version

Devnet PRs target `next`. Testnet PRs target `testnet`. Each branch pins its own Aztec version independently.
PRs target `next`. Testnet PRs target `testnet`. Each branch pins its own Aztec version independently.

## Project Structure

Expand All @@ -98,7 +96,7 @@ Devnet PRs target `next`. Testnet PRs target `testnet`. Each branch pins its own

**TypeScript utilities:**

- `src/utils/setup_wallet.ts` — creates `EmbeddedWallet` with environment-aware config (prover enabled on devnet)
- `src/utils/setup_wallet.ts` — creates `EmbeddedWallet` with environment-aware config
- `src/utils/create_account_from_env.ts` — Schnorr account from env vars
- `src/utils/deploy_account.ts` — account deployment with sponsored fees
- `src/utils/sponsored_fpc.ts` — SponsoredFPC (Fee Payment Contract) setup
Expand All @@ -113,7 +111,7 @@ Devnet PRs target `next`. Testnet PRs target `testnet`. Each branch pins its own
- **ESM project**: `"type": "module"` in package.json. All TS scripts run via `node --loader ts-node/esm`.
- **Private-public interaction**: `play_round` is private (creates `GameRoundNote` notes), then enqueues a public call (`validate_and_play_round`) to update round counters. `finish_game` reads private notes, sums them, and enqueues a public call to reveal totals.
- **Fee payment**: All transactions use `SponsoredFeePaymentMethod` via the SponsoredFPC contract.
- **Wallet setup**: `EmbeddedWallet.create()` with `ephemeral: true` for tests; prover is enabled only on devnet.
- **Wallet setup**: `EmbeddedWallet.create()` with `ephemeral: true` for tests.
- **PXE store**: Data persists in `./store`. Must delete after local network restart to avoid stale state errors.

## Simulate Before Send (IMPORTANT)
Expand Down Expand Up @@ -152,7 +150,7 @@ When updating the Aztec version, update all of these locations:

1. `Nargo.toml` — `aztec` dependency tag
2. `package.json` — all `@aztec/*` dependency versions
3. `config/local-network.json`, `config/devnet.json`, and/or `config/testnet.json` — `settings.version` (update the configs relevant to the branch you're on)
3. `config/local-network.json` and/or `config/testnet.json` — `settings.version` (update the configs relevant to the branch you're on)
4. `README.md` — install command version

> **Note:** The `next` and `testnet` branches may pin different Aztec versions. Only update the config files relevant to the branch.
Expand Down
2 changes: 1 addition & 1 deletion Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ authors = [ "" ]
compiler_version = ">=0.18.0"

[dependencies]
aztec = { git = "https://github.com/AztecProtocol/aztec-nr/", tag = "v4.1.0", directory = "aztec" }
aztec = { git = "https://github.com/AztecProtocol/aztec-nr/", tag = "v4.2.0-aztecnr-rc.2", directory = "aztec" }
79 changes: 22 additions & 57 deletions ONBOARDING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Onboarding: From Ethereum to Aztec

This guide takes you from "reading code in a browser" to "deploying on devnet" — progressively, with no install required until Phase 3.
This guide takes you from "reading code in a browser" to "deploying contracts" — progressively, with no install required until Phase 3.

**What you'll learn:** How Aztec contracts work by studying a Pod Racing game — a two-player competitive game that uses private state to implement commit-reveal in a single transaction.

Expand All @@ -9,7 +9,7 @@ This guide takes you from "reading code in a browser" to "deploying on devnet"
* **Phases 1-2** need only a browser (read code, compile in a Codespace)
* **Phases 3-6** need local tools (deploy, interact, extend, advanced topics)

**Aztec version pinned in this repo:** `4.1.0` (check `Nargo.toml` and `package.json` for source of truth)
**Aztec version pinned in this repo:** `4.2.0-aztecnr-rc.2` (check `Nargo.toml` and `package.json` for source of truth)

**Links:**

Expand Down Expand Up @@ -101,7 +101,7 @@ struct Storage<Context> {
}
```

<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/main.nr#L40-L59" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lstorage</a></sub></sup>
<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/src/main.nr#L40-L59" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lstorage</a></sub></sup>

**What is `Context`?** You'll notice `Context` appears as a generic parameter throughout the storage definition. In Aztec, the context is the execution environment passed to every function — it's how your contract accesses blockchain state like `context.msg_sender()` (the caller's address) and `context.block_number()`. Think of it as an expanded version of Solidity's global variables (`msg.sender`, `block.number`, etc.), but packaged as an object. The `<Context>` generic on storage types lets the same storage struct work in both public and private execution contexts. You don't need to construct it yourself — the framework provides `self.context` automatically in every contract function.

Expand Down Expand Up @@ -149,7 +149,7 @@ fn constructor(admin: AztecAddress) {
}
```

<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/main.nr#L61-L68" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lconstructor</a></sub></sup>
<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/src/main.nr#L61-L68" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lconstructor</a></sub></sup>

Sets the admin address. The `#[initializer]` macro means this runs once at deployment, like a Solidity constructor.

Expand Down Expand Up @@ -180,7 +180,7 @@ fn create_game(game_id: Field) {
}
```

<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/main.nr#L70-L93" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lcreate-game</a></sub></sup>
<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/src/main.nr#L70-L93" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lcreate-game</a></sub></sup>

Creates a new game. Checks the game ID isn't taken (player1 must be zero address), then writes a new `Race` struct with the caller as player1 and an expiration time.

Expand All @@ -202,7 +202,7 @@ fn join_game(game_id: Field) {
}
```

<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/main.nr#L95-L109" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Ljoin-game</a></sub></sup>
<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/src/main.nr#L95-L109" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Ljoin-game</a></sub></sup>

A second player joins. The `Race::join()` method validates that player1 exists, the player2 slot is empty, and the joiner isn't player1.

Expand Down Expand Up @@ -236,7 +236,7 @@ fn finalize_game(game_id: Field) {
}
```

<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/main.nr#L269-L296" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lfinalize-game</a></sub></sup>
<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/src/main.nr#L265-L292" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lfinalize-game</a></sub></sup>

After both players have revealed, this compares track scores, determines the winner, and updates the leaderboard.

Expand Down Expand Up @@ -336,15 +336,11 @@ fn play_round(

// Enqueue a public function call to update the round counter
// This reveals that a round was played, but not the point allocation
self.enqueue_self.validate_and_play_round(
player,
game_id,
round,
);
self.enqueue_self.validate_and_play_round(player, game_id, round);
}
```

<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/main.nr#L111-L160" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lplay-round</a></sub></sup>
<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/src/main.nr#L111-L156" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lplay-round</a></sub></sup>

Three things happen here that have no direct Ethereum equivalent:

Expand Down Expand Up @@ -406,7 +402,7 @@ fn finish_game(game_id: Field) {
}
```

<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/main.nr#L179-L230" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lfinish-game</a></sub></sup>
<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/src/main.nr#L175-L226" target="_blank" rel="noopener noreferrer">Source code: /src/main.nr#Lfinish-game</a></sub></sup>

This is the "reveal" phase:

Expand Down Expand Up @@ -526,7 +522,7 @@ The `.devcontainer/` configures:

* **Base image:** Ubuntu 24.04 with Node.js v22.15.0
* **Docker-in-Docker** for running the Aztec local network
* **Aztec CLI** installed via `curl -fsSL "https://install.aztec.network/4.1.0" | VERSION="4.1.0" bash -s`
* **Aztec CLI** installed via `curl -fsSL "https://install.aztec.network/4.2.0-aztecnr-rc.2" | VERSION="4.2.0-aztecnr-rc.2" bash -s`
* **VS Code extension:** `noir-lang.vscode-noir` for Noir syntax highlighting
* **Dependencies:** `yarn install` runs automatically

Expand Down Expand Up @@ -737,7 +733,7 @@ pub unconstrained fn setup() -> (TestEnvironment, AztecAddress, AztecAddress) {
**Aztec toolkit:**

```bash
export VERSION=4.1.0
export VERSION=4.2.0-aztecnr-rc.2
curl -fsSL "https://install.aztec.network/${VERSION}" | VERSION="${VERSION}" bash -s
```

Expand Down Expand Up @@ -801,25 +797,11 @@ private constructor() {
}
```

**`config/devnet.json`:**

```json
{
"name": "devnet",
"environment": "devnet",
"network": {
"nodeUrl": "https://next.devnet.aztec-labs.com",
"l1RpcUrl": "https://ethereum-sepolia-rpc.publicnode.com",
"l1ChainId": 11155111
}
}
```

Key exports from `config/config.ts`:

* `getAztecNodeUrl()` — returns the node URL for the current environment
* `getTimeouts()` — returns environment-specific timeout values (local: 60s tx, devnet: 180s tx)
* `getEnv()` — returns the environment name (`"local-network"` or `"devnet"`)
* `getTimeouts()` — returns environment-specific timeout values
* `getEnv()` — returns the environment name (e.g. `"local-network"`)

***

Expand Down Expand Up @@ -849,7 +831,7 @@ export async function getSponsoredFPCInstance(): Promise<ContractInstanceWithAdd
}
```

<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/utils/sponsored_fpc.ts#L11-L17" target="_blank" rel="noopener noreferrer">Source code: /src/utils/sponsored_fpc.ts#Lget-sponsored-fpc</a></sub></sup>
<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/src/utils/sponsored_fpc.ts#L11-L17" target="_blank" rel="noopener noreferrer">Source code: /src/utils/sponsored_fpc.ts#Lget-sponsored-fpc</a></sub></sup>

**Run it:**

Expand Down Expand Up @@ -880,12 +862,12 @@ const deployRequest = PodRacingContract.deploy(wallet, address);
await deployRequest.simulate({
from: address,
});
const { receipt } = await deployRequest.send({
const { contract: podRacingContract, receipt: deployReceipt } = await deployRequest.send({
from: address,
fee: { paymentMethod: sponsoredPaymentMethod },
wait: { timeout: timeouts.deployTimeout, returnReceipt: true }
wait: { timeout: timeouts.deployTimeout }
});
const podRacingContract = receipt.contract;
const instance = deployReceipt.instance;
```

<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/scripts/deploy_contract.ts#L44-L55" target="_blank" rel="noopener noreferrer">Source code: /scripts/deploy_contract.ts#Ldeploy-contract</a></sub></sup>
Expand Down Expand Up @@ -1018,7 +1000,7 @@ yarn test:js

## Phase 6: Advanced Topics

**Goal:** Explore multi-wallet patterns, fee strategies, devnet, and profiling.
**Goal:** Explore multi-wallet patterns, fee strategies, and profiling.

### 6.1 — Multiple Wallets / Multiple PXEs

Expand All @@ -1033,7 +1015,7 @@ const wallet1 = await EmbeddedWallet.create(node, walletOpts);
const wallet2 = await EmbeddedWallet.create(node, walletOpts);
```

<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/scripts/multiple_wallet.ts#L22-L25" target="_blank" rel="noopener noreferrer">Source code: /scripts/multiple_wallet.ts#Lmultiple-wallets</a></sub></sup>
<sup><sub><a href="https://github.com/AztecProtocol/aztec-starter/blob/main/scripts/multiple_wallet.ts#L40-L43" target="_blank" rel="noopener noreferrer">Source code: /scripts/multiple_wallet.ts#Lmultiple-wallets</a></sub></sup>

It then deploys a Token contract from wallet1, creates an account on wallet2, mints tokens to wallet2's account, registers the token contract on wallet2, and reads balances.

Expand All @@ -1059,20 +1041,7 @@ yarn multiple-wallet
yarn fees
```

### 6.3 — Deploying to Devnet

All scripts support a `::devnet` suffix:

```bash
yarn deploy::devnet
yarn deploy-account::devnet
yarn interaction-existing-contract::devnet
yarn test::devnet
```

Devnet uses real provers and connects to the Aztec devnet at `https://next.devnet.aztec-labs.com` with Sepolia as the L1. Timeouts are longer (deploy: 20 min, tx: 3 min) to account for real proving time.

### 6.4 — Transaction Profiling
### 6.3 — Transaction Profiling

**`scripts/profile_deploy.ts`** shows how to profile a transaction:

Expand All @@ -1089,7 +1058,7 @@ The `.profile()` method runs the transaction through the prover and returns deta
yarn profile
```

### 6.5 — Querying Blocks
### 6.4 — Querying Blocks

**`scripts/get_block.ts`** shows how to query the Aztec node directly:

Expand Down Expand Up @@ -1138,7 +1107,6 @@ yarn get-block
| `scripts/get_block.ts` | Block querying |
| `config/config.ts` | Config manager (loads JSON by env) |
| `config/local-network.json` | Local network configuration |
| `config/devnet.json` | Devnet configuration |
| `Nargo.toml` | Noir project manifest |
| `.devcontainer/devcontainer.json` | GitHub Codespace configuration |
| `.devcontainer/Dockerfile` | Codespace Docker image |
Expand All @@ -1163,16 +1131,13 @@ yarn get-block
| `yarn get-block` | Query block data |
| `yarn clean` | Delete `./src/artifacts` and `./target` |
| `yarn clear-store` | Delete `./store` (PXE data) |
| `yarn deploy::devnet` | Deploy to devnet |
| `yarn test::devnet` | Run E2E tests on devnet |

### C. Troubleshooting

| Problem | Solution |
| -------------------------------------------------------- | ------------------------------------------------------------------------ |
| "Store" or PXE errors after restarting the local network | Delete `./store`: `rm -rf ./store` |
| Compilation errors after updating dependencies | Run `yarn compile` again |
| Timeout errors on devnet | Check timeout values in `config/devnet.json` (deploy: 20 min, tx: 3 min) |
| "Contract not registered" error | Call `wallet.registerContract(instance, artifact)` before interacting |
| Account not found | Ensure `.env` has correct `SECRET`, `SIGNING_KEY`, and `SALT` values |
| Local network not starting | Ensure Docker is running and the correct Aztec version is installed |
Expand Down
Loading
Loading