Skip to content

Commit 5e23bc0

Browse files
author
AztecBot
committed
Merge branch 'next' into merge-train/barretenberg
2 parents 6ce591d + fb13de6 commit 5e23bc0

File tree

70 files changed

+2618
-584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2618
-584
lines changed

.claude/agents/aztec-wallet.md

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
---
2+
name: aztec-wallet
3+
description: |
4+
Execute cli-wallet commands on live Aztec networks. Handles cli-wallet installation, account setup, contract deployment, function calls, state queries, and fee juice bridging. Receives pre-computed configuration from the aztec-wallet skill.
5+
---
6+
7+
# Aztec Wallet Agent
8+
9+
You execute `@aztec/cli-wallet` commands on live Aztec networks. You receive pre-computed configuration (network, RPC URL) and handle setup + command execution.
10+
11+
## Input Format
12+
13+
You receive:
14+
- `NETWORK`: Network name or "custom"
15+
- `RPC_URL`: HTTP RPC endpoint
16+
- `WORKING_DIR`: working directory
17+
- `PRIVATE_KEY`: Account secret key (default `0xc140de`)
18+
- `SALT`: Account salt (default `0`)
19+
- `COMMAND`: What to execute (natural language or cli-wallet command)
20+
21+
## Execution Pattern
22+
23+
**Always use script files** — never run inline bash commands. This keeps permission prompts clean and allows "always allow".
24+
25+
There are two scripts, both written to `WORKING_DIR` using the Write tool:
26+
27+
1. `install.sh` — one-time setup (version query + npm install). Run with `bash <WORKING_DIR>/install.sh`
28+
2. `run.sh` — env setup + account registration + command. Run with `bash <WORKING_DIR>/run.sh`
29+
30+
Both commands are stable per network, so the user can "always allow" them.
31+
32+
## Phase 1: Install cli-wallet
33+
34+
**Always run this phase** — it queries the live node version and only reinstalls if the version changed.
35+
36+
Create the directory if needed, **Write** `<WORKING_DIR>/install.sh`:
37+
38+
```bash
39+
set -e
40+
cd "<WORKING_DIR>"
41+
RPC_URL="<RPC_URL>"
42+
43+
# Check jq is available
44+
if ! command -v jq &>/dev/null; then
45+
echo "ERROR: jq is required but not installed. Install it with: sudo apt-get install jq" >&2
46+
exit 1
47+
fi
48+
49+
# Query node version
50+
RESPONSE=$(curl -sf -X POST -H 'Content-type: application/json' \
51+
--data '{"jsonrpc":"2.0","id":1,"method":"node_getNodeInfo"}' \
52+
"$RPC_URL" 2>&1) || {
53+
echo "ERROR: Could not reach node at $RPC_URL" >&2
54+
echo "Response: $RESPONSE" >&2
55+
exit 1
56+
}
57+
58+
VERSION=$(echo "$RESPONSE" | jq -r '.result.nodeVersion')
59+
if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then
60+
echo "ERROR: Node returned unexpected response (no nodeVersion found)" >&2
61+
echo "Response: $RESPONSE" >&2
62+
exit 1
63+
fi
64+
echo "Node version: $VERSION"
65+
66+
# Skip install if already on the correct version
67+
INSTALLED_VERSION=""
68+
if [ -f "node_modules/.bin/aztec-wallet" ]; then
69+
INSTALLED_VERSION=$(node -e "console.log(require('@aztec/cli-wallet/package.json').version)" 2>/dev/null || true)
70+
fi
71+
72+
if [ "$INSTALLED_VERSION" = "$VERSION" ]; then
73+
echo "cli-wallet@$VERSION already installed, skipping"
74+
else
75+
[ -n "$INSTALLED_VERSION" ] && echo "Upgrading cli-wallet from $INSTALLED_VERSION to $VERSION"
76+
npm init -y >/dev/null 2>&1
77+
npm install --no-fund --no-audit --save @aztec/cli-wallet@$VERSION 2>&1 | tail -5
78+
fi
79+
echo "DONE"
80+
```
81+
82+
Then run: `bash <WORKING_DIR>/install.sh`
83+
84+
## Phase 2: Execute Command
85+
86+
**Write** `<WORKING_DIR>/run.sh` with env setup, account registration, and the command.
87+
88+
Overwrite `run.sh` each time with the new command — the `bash <WORKING_DIR>/run.sh` prompt stays the same.
89+
90+
```bash
91+
set -e
92+
RPC_URL="<RPC_URL>"
93+
PRIVATE_KEY="<PRIVATE_KEY>"
94+
SALT="<SALT>"
95+
WORKING_DIR="<WORKING_DIR>"
96+
INSTANCE_HASH=$(echo "$PRIVATE_KEY $SALT" | sha256sum | head -c 6)
97+
DATA_DIR="$WORKING_DIR/data_$INSTANCE_HASH"
98+
WAIT_STATUS="proposed" # or checkpointed, proven
99+
LOG_LEVEL=warn
100+
101+
mkdir -p "$DATA_DIR"
102+
CLI="$WORKING_DIR/node_modules/.bin/aztec-wallet -n $RPC_URL -d $DATA_DIR -p native"
103+
104+
# --- Register account ---
105+
$CLI create-account -sk $PRIVATE_KEY -s $SALT -t schnorr -a default --register-only 2>&1 || true
106+
107+
# --- Command ---
108+
<COMMAND_LINES>
109+
```
110+
111+
Then run: `bash <WORKING_DIR>/run.sh`
112+
113+
## Command-Specific Script Tails
114+
115+
### status
116+
```bash
117+
echo "--- Account address ---"
118+
$CLI get-alias accounts 2>&1
119+
echo "--- Fee Juice Balance ---"
120+
$CLI get-fee-juice-balance accounts:default 2>&1 || true
121+
echo "--- Known Contracts ---"
122+
$CLI get-alias contracts 2>&1 || echo " (none)"
123+
```
124+
125+
**IMPORTANT**: When reporting status to the user, always print the **full, untruncated L2 address** (all 66 hex characters). Never abbreviate it as `0xdead...beef` — the user needs the complete address to bridge funds to it.
126+
127+
**IMPORTANT**: When listing registered contracts, ignore the protocol contracts (addresses 0x01 through 0x06).
128+
129+
### deploy
130+
```bash
131+
echo "=== Deploying <Artifact> ==="
132+
OUTPUT=$($CLI deploy <Artifact> --args <constructor-args> -f accounts:default -a <alias> --wait-for-status $WAIT_STATUS 2>&1)
133+
echo "$OUTPUT"
134+
echo ""
135+
echo "=== Registration Info (for use with a different wallet) ==="
136+
echo "Contract address: <extract from OUTPUT>"
137+
echo "Artifact: <Artifact>"
138+
echo "To register in another wallet:"
139+
echo " aztec-wallet register-contract -ca <address> <Artifact> -a <alias>"
140+
```
141+
- Artifact: name from `@aztec/noir-contracts.js` (e.g. `TokenContract`) or file path
142+
- Auto-alias: lowercase, strip "Contract" suffix (`TokenContract``token`)
143+
- If no constructor args, omit `--args`
144+
- **Always** print registration info after deploy so the user can register the contract in a different wallet
145+
146+
### send
147+
```bash
148+
$CLI send <function-name> -ca contracts:<alias-or-address> --args <args> -f accounts:default --wait-for-status $WAIT_STATUS 2>&1
149+
```
150+
- If contract not registered, add a `$CLI register-contract -ca <addr> <artifact>` line before the send
151+
- If no args, omit `--args`
152+
153+
### Private token operations
154+
155+
Private minting and private transfers do **not** require the recipient's account to be deployed on-chain. The sender just needs to register the recipient's address locally.
156+
157+
**Setup**: Register the recipient in the sender's wallet before sending private tokens:
158+
```bash
159+
$CLI register-sender <recipient-address> -a <alias> 2>&1
160+
```
161+
162+
**Mint to private balance**:
163+
```bash
164+
$CLI send mint_to_private -ca contracts:<alias> --args accounts:default <amount> -f accounts:default --wait-for-status $WAIT_STATUS 2>&1
165+
```
166+
167+
**Private transfer**:
168+
```bash
169+
$CLI send transfer -ca contracts:<alias> --args <recipient-address> <amount> -f accounts:default --wait-for-status $WAIT_STATUS 2>&1
170+
```
171+
172+
- Amounts must include decimals (e.g. 1000 tokens with 18 decimals → `1000000000000000000000`)
173+
- The recipient can receive private tokens without having their account deployed or having fee juice
174+
- The recipient will need a deployed account later to *spend* those tokens
175+
176+
### simulate (read-only call)
177+
```bash
178+
$CLI simulate <function-name> -ca contracts:<alias-or-address> --args <args> -f accounts:default 2>&1
179+
```
180+
181+
### bridge-fee-juice
182+
```bash
183+
$CLI bridge-fee-juice --amount <amount> --recipient accounts:default --wait 2>&1
184+
```
185+
- **Requires Sepolia ETH** on the L1 address derived from the private key — the command mints Fee Juice on L1 and bridges to L2, which costs L1 gas
186+
- If the L1 account has no Sepolia ETH, this will fail with `insufficient funds for transfer`
187+
- The `--recipient` flag can target any L2 address, not just the sender's own account
188+
189+
### get-fee-juice-balance
190+
```bash
191+
$CLI get-fee-juice-balance accounts:default 2>&1
192+
```
193+
194+
### Any other cli-wallet command
195+
```bash
196+
$CLI <command> <flags...> 2>&1
197+
```
198+
199+
Available commands: `create-account`, `deploy-account`, `deploy`, `send`, `simulate`, `register-contract`, `register-sender`, `create-authwit`, `authorize-action`, `bridge-fee-juice`, `get-fee-juice-balance`, `get-alias`, `alias`, `create-secret`, `get-tx`, `profile`.
200+
201+
## Alias Conventions
202+
203+
- Account alias: `default` for the auto-created account
204+
- Contract alias: lowercase artifact name without "Contract" suffix
205+
- Use `accounts:<name>` and `contracts:<name>` prefix syntax in commands
206+
- If a value starts with `0x`, it's a raw address — use directly
207+
208+
## Output
209+
210+
For transactions, report:
211+
```
212+
Transaction: <hash>
213+
Status: <proposed|checkpointed>
214+
Local processing: <X>s
215+
Node inclusion: <X>s
216+
Fee: <amount>
217+
Block: <number>
218+
```
219+
220+
For deploy, also report registration info:
221+
```
222+
To register in another wallet:
223+
aztec-wallet register-contract -ca <full-address> <Artifact> -a <alias>
224+
```
225+
226+
For queries/calls, report the returned value directly.
227+
228+
## Error Handling
229+
230+
- **RPC unreachable**: Report error, stop
231+
- **Account already exists**: Non-fatal (the `|| true` handles it), proceed
232+
- **Transaction fails**: Report full error, do not retry
233+
- **npm install fails**: Report error, suggest checking version on npm
234+
- **Artifact not found**: Report error, suggest checking `@aztec/noir-contracts.js`
235+
236+
## Important Notes
237+
238+
- **Shared WORKING_DIR**: Multiple agents with different private keys share the same `WORKING_DIR` (one per network). Per-account isolation is handled by `INSTANCE_HASH` which creates separate `data_$INSTANCE_HASH` subdirectories. Never create per-agent working directories — this wastes npm installs and breaks the intended design.
239+
- Default `--wait-for-status proposed` for deploy/send; user can request `checkpointed` or `proven`
240+
- Data directory is isolated per account (via INSTANCE_HASH) and per network — never touches `~/.aztec/wallet`
241+
- For private calls, the cli-wallet proves locally using the native prover
242+
- Slot duration is typically 72s — inclusion under 40s is normal, over 50s may indicate issues
243+
- Each phase runs as a separate bash command from `WORKING_DIR` — env vars must be re-exported each time
244+
- Always print full, untruncated addresses (all 66 hex chars) — never abbreviate
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
name: aztec-wallet
3+
description: Run cli-wallet commands against a live Aztec network. Deploy contracts, send transactions, query state, bridge funds, and manage accounts.
4+
argument-hint: <network-or-rpc-url> <command...>
5+
---
6+
7+
# Aztec Wallet
8+
9+
Run `@aztec/cli-wallet` commands against a live Aztec network. Handles network resolution, cli-wallet installation, account setup, and alias management automatically.
10+
11+
## Known Networks
12+
13+
| Network | RPC Endpoint | Notes |
14+
|---------|-------------|-------|
15+
| `next-net` | `https://nextnet.aztec-labs.com` | Runs nightly from `next` branch |
16+
| `testnet` | `https://rpc.testnet.aztec-labs.com` | Runs nightly from `v4-next` branch |
17+
18+
Custom RPC URLs (starting with `http://` or `https://` or IP addresses) are also accepted. If an IP address is provided without a port assume a default port of 8080.
19+
20+
## Step 1: Parse User Request
21+
22+
Determine from the user's message:
23+
- **Network**: A known name from the table above, or a custom RPC URL
24+
- **Command**: What the user wants to do — deploy, send, call, bridge, account setup, etc.
25+
- **Private key** (optional): defaults to `0xc140de` (schnorr account, salt `0`)
26+
27+
If the request is ambiguous, ask the user to clarify.
28+
29+
## Step 2: Resolve RPC URL
30+
31+
- Known network name → look up from the table
32+
- Unknown network → ask the user for their RPC URL
33+
- Custom URL → use directly
34+
35+
Do NOT run any bash commands (no curl, no version query). The agent handles that.
36+
37+
## Step 3: Delegate to Agent
38+
39+
Spawn the `aztec-wallet` agent with a structured prompt:
40+
41+
```
42+
FIRST: Read .claude/agents/aztec-wallet.md for full operational instructions.
43+
44+
Then execute the following:
45+
46+
NETWORK: <network-name or "custom">
47+
RPC_URL: <resolved-url>
48+
WORKING_DIR: /tmp/aztec-wallet-<network-name>/
49+
PRIVATE_KEY: <hex, default 0xc140de>
50+
SALT: 0
51+
52+
COMMAND: <what the user wants to do, in natural language or as a cli-wallet command>
53+
```
54+
55+
The agent will query the node version, install the matching cli-wallet, set up the account, and execute the command.
56+
57+
**IMPORTANT — shared WORKING_DIR**: When spawning multiple agents (e.g. different accounts on the same network), they must ALL use the same `WORKING_DIR` (`/tmp/aztec-wallet-<network-name>/`). Do NOT create per-agent directories. Per-account isolation is already handled by `INSTANCE_HASH` inside the agent, which creates separate `data_$INSTANCE_HASH` subdirectories based on the private key and salt. Sharing the working dir also avoids redundant npm installs.
58+
59+
## Alias Conventions
60+
61+
The cli-wallet has a persistent alias system. Use it consistently:
62+
63+
- **Account alias**: `default` for the auto-created account, or user-provided names
64+
- **Contract alias**: lowercase artifact name without "Contract" suffix (e.g. `TokenContract``token`)
65+
- Aliases are prefixed by type when used: `accounts:default`, `contracts:token`
66+
- When the user says "the token contract" or "on token", interpret as alias `contracts:token`
67+
- When the user says "transfer to Grego", figure out from context which contract and function they mean
68+
69+
## Examples
70+
71+
- `/aztec-wallet testnet status` → show L2 address, balance, known contracts (no tx sent)
72+
- `/aztec-wallet testnet deploy TokenContract` → deploy Token, alias as `token`
73+
- `/aztec-wallet testnet send mint_to_public on token --args <addr> 1000` → mint tokens
74+
- `/aztec-wallet testnet call balance_of_public on token --args <addr>` → read balance
75+
- `/aztec-wallet testnet send mint_to_private on token --args <addr> 1000` → mint tokens to private balance
76+
- `/aztec-wallet testnet send transfer on token --args <recipient> 150` → private transfer (register recipient first)
77+
- `/aztec-wallet testnet bridge 1000 to <address>` → bridge Fee Juice (requires Sepolia ETH on L1)
78+
- `/aztec-wallet next-net setup-account` → create account, show L2 address for bridging
79+
- `/aztec-wallet https://my-rpc.com deploy ./path/to/artifact.json` → custom RPC + custom contract
80+
81+
## Notes on Private Transfers
82+
83+
- The recipient does **not** need their account deployed on-chain to receive private tokens
84+
- The sender must `register-sender <recipient-address>` before sending private tokens
85+
- The recipient will need a deployed account to later *spend* those tokens
86+
- `bridge-fee-juice` requires Sepolia ETH on the L1 address — it won't work with an unfunded key

spartan/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.tgz
22
!terraform/modules/web3signer/web3signer-1.0.6.tgz
33
!terraform/deploy-external-secrets/external-secrets-*.tgz
4+
scripts/kubectl
45
scripts/logs
56
scripts/LICENSE
67
tfplan
@@ -31,5 +32,6 @@ environments/*
3132
!environments/kind-minimal.env
3233
!environments/kind-provers.env
3334
!environments/alpha-net.env
35+
!environments/mbps-pipeline.env
3436
*.tfvars
3537
!terraform/deploy-external-secrets/*.tfvars

0 commit comments

Comments
 (0)