This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
When answering questions about the Aztec network, protocol, SDK, or tooling, fetch https://docs.aztec.network/llms.txt for the current official docs index. Prefer it over training-data knowledge, which may be stale.
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: 5.0.0-rc.2 — pinned across Nargo.toml, package.json, config/*.json, and README. All must stay in sync when updating.
Always use yarn compile or aztec compile to compile contracts, never nargo compile.
yarn compile # Compile Noir contract (aztec compile)
yarn codegen # Generate TS artifacts from compiled contract
yarn compile && yarn codegen # Full rebuild (always run both together)
yarn clean # Remove compiled artifacts (src/artifacts, target)
yarn clear-store # Remove PXE data store (rm -rf ./store)Two independent test systems:
yarn test:nr # Noir TXE tests — no network needed, runs in simulator
yarn test:js # TypeScript E2E tests — requires running local network
yarn test # Runs both (test:js then test:nr)E2E tests require a running local network:
aztec start --local-network # Start local network first
rm -rf ./store # Always clear store after network restartJest config: jest.integration.config.json — 600s test timeout, ESM mode via ts-jest, matches ./src/**/*.test.ts.
Run a single E2E test:
NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json -t "test name pattern"All scripts support ::testnet suffixes for remote network targeting:
yarn deploy # Deploy contract to local network
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::testnet # Same on testnetAZTEC_ENVvariable selects config:local-network(default) ortestnet- Config files:
config/local-network.json,config/testnet.json config/config.ts— singletonConfigManagerloads the appropriate JSON based onAZTEC_ENV.envstores secrets (SECRET, SIGNING_KEY, SALT, contract keys) — never commit
nextbranch — default branch; used for local network developmenttestnetbranch — used for testnet development; may run a different Aztec version
PRs target next. Testnet PRs target testnet. Each branch pins its own Aztec version independently.
Contract (Noir):
src/main.nr— PodRacing contract: public functions (create_game,join_game,finalize_game), private functions (play_round,finish_game), and internal#[only_self]validatorssrc/race.nr—Racestruct: public game state (players, round counters, track scores, end_block)src/game_round_note.nr—GameRoundNote: private note storing one round's point allocation per player
Tests (Noir TXE):
src/test/mod.nr— test module rootsrc/test/pod_racing.nr— unit tests using TXE simulator (env.call_public,env.call_private,env.public_context_at)src/test/utils.nr— test setup helpersrc/test/helpers.nr— test helpers (game setup, allocation strategies)
Tests (TypeScript E2E):
src/test/e2e/index.test.ts— full game lifecycle tests against real networksrc/test/e2e/accounts.test.ts— account testssrc/test/e2e/public_logging.test.ts— logging tests
TypeScript utilities:
src/utils/setup_wallet.ts— createsEmbeddedWalletwith environment-aware configsrc/utils/create_account_from_env.ts— Schnorr account from env varssrc/utils/deploy_account.ts— account deployment with sponsored feessrc/utils/sponsored_fpc.ts— SponsoredFPC (Fee Payment Contract) setup
Generated (do not edit):
src/artifacts/PodRacing.ts— generated byyarn codegentarget/— compiled contract output
- ESM project:
"type": "module"in package.json. All TS scripts run vianode --loader ts-node/esm. - Private-public interaction:
play_roundis private (createsGameRoundNotenotes), then enqueues a public call (validate_and_play_round) to update round counters.finish_gamereads private notes, sums them, and enqueues a public call to reveal totals. - Fee payment: All transactions use
SponsoredFeePaymentMethodvia the SponsoredFPC contract. - Wallet setup:
EmbeddedWallet.create()withephemeral: truefor tests. - PXE store: Data persists in
./store. Must delete after local network restart to avoid stale state errors.
Always call .simulate() before .send() for every state-changing transaction. Simulation runs the transaction locally and surfaces revert reasons immediately. Without it, a failing transaction will hang until the send timeout (up to 600s) with an opaque error.
// Simulate first — surfaces revert reasons instantly
await contract.methods.create_game(gameId).simulate({ from: address });
// Then send — only after simulation succeeds
await contract.methods.create_game(gameId).send({
from: address,
fee: { paymentMethod },
wait: { timeout: timeouts.txTimeout }
});For deployments, store the deploy request to avoid constructing it twice:
const deployRequest = MyContract.deploy(wallet, ...args);
await deployRequest.simulate({ from: address });
const contract = await deployRequest.send({ ... });Checklist:
- Every
.send()call must be preceded by a.simulate()call .simulate()does not need fee parameters — onlyfromis required- View/read-only calls (e.g.
balance_of_private) already use.simulate()to return values — no.send()needed for those
When updating the Aztec version, update all of these locations:
Nargo.toml—aztecdependency tagpackage.json— all@aztec/*dependency versionsconfig/local-network.jsonand/orconfig/testnet.json—settings.version(update the configs relevant to the branch you're on)README.md— install command version
Note: The
nextandtestnetbranches may pin different Aztec versions. Only update the config files relevant to the branch.
ONBOARDING.md is generated — do not edit it directly. Edit docs/ONBOARDING.src.md instead, then rebuild:
yarn docs:build # remark docs/ONBOARDING.src.md -o ONBOARDING.mdThe source file uses #include_code directives (via the include_code remark plugin) to extract code snippets from source files at build time. Source files have // docs:start:<name> / // docs:end:<name> marker pairs that define snippet boundaries.
When making code changes:
- Source code snippets update automatically on rebuild — no manual copy needed
- If you add/remove/rename a marker, update the corresponding
#include_codedirective indocs/ONBOARDING.src.md - Run
yarn docs:buildto regenerateONBOARDING.md - Phase 5 exercises and non-source prose still need manual updates in
docs/ONBOARDING.src.md
Files with docs:start/docs:end markers:
src/main.nr—storage,constructor,create-game,join-game,play-round,validate-and-play-round,finish-game,validate-finish-game,finalize-gamesrc/race.nr—race-struct,calculate-winnersrc/game_round_note.nr—game-round-note,game-round-note-newsrc/test/utils.nr—test-setupsrc/test/helpers.nr—allocation-strategies,setup-helperssrc/test/pod_racing.nr—test-initializer,test-fail-too-many-pointssrc/utils/sponsored_fpc.ts—get-sponsored-fpc