This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Aztec Fee Payment — a Fee Payment Contract (FPC) for Aztec that sponsors transaction fees using internal balances. Includes a Noir smart contract and a TypeScript SDK (published as @defi-wonderland/aztec-fee-payment).
- Private FPC (
src/nr/private_contract/) — Bridge-based flow: users bridge FJ directly viaFeeJuicePortalto the FPC address, then callmintto convert the bridge claim into private FJ. Fully private, no owner, no off-chain agent.
The tech design document in docs/ is the source of truth for this project:
- Private FPC PRD:
docs/private-product-requirements.md
All code changes MUST stay aligned with this document. Two mandatory checks enforce this:
Before implementing any user-requested code change, launch a read-only general-purpose subagent that reads the doc and classifies the proposed change as:
- ALIGNED — explicitly described or directly implied by the spec
- CONTRADICTION — conflicts with a specific decision/requirement/constraint (must quote the section)
- EXTENSION — adds behavior, fields, endpoints, or flows not covered by the doc
If ALIGNED: proceed with implementation.
If CONTRADICTION or EXTENSION: use AskUserQuestion with options: (1) "Proceed and update docs after", (2) "Abort", (3) "Modify approach". Do NOT implement without asking.
Skip this check for: refactors with no behavior change, test-only changes, formatting, dependency bumps.
After any code change that affects contract logic, SDK public API, error codes, or security properties, launch a general-purpose subagent (with edit permissions) that:
- Reads the doc and identifies sections made outdated by the change
- Edits only affected sections (requirements tables, status fields, code examples, API specs, schemas, prose)
- Bumps the version in the Version History table (minor for features/behavior changes, patch for clarifications) with today's date
- Returns a summary of all doc edits — relay this summary to the user
- Node.js >= 22, Yarn 1.22.22 (corepack)
- Aztec CLI v4.2.0-aztecnr-rc.2:
curl -s install.aztec.network | NON_INTERACTIVE=1 BIN_PATH=$HOME/.aztec/bin bash -s
yarn install # Install dependencies (uses Yarn workspaces)
# Full rebuild (clean + compile Noir + generate TS bindings)
yarn ccc
# Individual steps
yarn compile # aztec compile (Noir contracts)
yarn codegen # aztec codegen target --outdir src/artifacts
# Build TS package (compile + codegen + tsc)
yarn build
# Tests — integration tests require a running Aztec local network
yarn test # all tests (Noir + JS)
yarn test:nr # Noir unit tests only (aztec test)
yarn test:js # JS integration tests
# Run a single test file
npx vitest run src/ts/test/private.test.ts
# Compute PrivateFPC address (no on-chain deployment needed)
yarn compute # Requires PRIVATE_FPC_SALT in .env
# Formatting
yarn lint:prettierTwo Noir packages (workspace defined in root Nargo.toml):
private_contract— Private FPC. Fully private (no public functions). Storage:balances: Owned<BalanceSet>only. Key functions:pay_fee()— Deducts max gas cost, no refundmint(amount, salt, leaf_index)— Proves priorFeeJuice.claimvia nullifier existence, credits FJ to claimerbalance_of(account)— Unconstrained view- Library methods:
derive_bridge_secret,get_bridge_gas_msg_hash,compute_feejuice_claim_nullifier
counter_contract— Test utility contract for benchmarks and integration tests
Published as @defi-wonderland/aztec-fee-payment with export paths:
.— Main:PrivateFPCContract,FPCFeePaymentMethod, gas utils, registration helper./artifacts— Generated contract bindings./fee-payment-methods—FPCFeePaymentMethod(no refund),PrivateMintAndPayFeePaymentMethod./utils— Gas calculation helpers (maxGasCostFor,maxFeesPerGasFromBaseFees),registerPrivateContract
- Integration tests (
vitest.config.ts) — Requires a running Aztec local network (start manually before running). 200s timeouts. Single fork, no parallelism. Must inline/@aztec/,/@noble/,/@scure/,/viem/inserver.deps.
- PrivateFPC is fully private (no public functions, no constructor) — no on-chain deployment needed
scripts/compute.ts— Computes the deterministic address from artifact + salt (PRIVATE_FPC_SALTenv var)
set_as_fee_payer()+end_setup()is the required FPC pattern for Aztec fee sponsorshipmintusesassert_nullifier_exists+compute_nullifier_existence_requestto prove a priorFeeJuice.claimin private- Commits use conventional commits (
@commitlint/config-conventional)
encodeEventLogdoes NOT exist in the bundled viem — useencodeEventTopics+encodeAbiParametersvi.mockfor classes must use actualclasssyntax in vitest v4- Aztec Schnorr signatures use random nonces (NOT deterministic)
- The vitest config requires a
@noble/hashes/utilsresolve alias pointing to the exact ESM file — without it, CI may resolve a nested version missing theanumberexport