|
| 1 | +--- |
| 2 | +name: aztec-node-rpc |
| 3 | +description: Fetch data from an Aztec node over JSON-RPC — block numbers, blocks, checkpoints, txs, node info, fees, config, and admin/debug operations. Use whenever you need to query a live Aztec node (public testnet/mainnet gateways, drpc, or a node inside the k8s clusters) or a locally running node. Covers endpoints, auth, namespaces/methods, and a health-check helper. |
| 4 | +argument-hint: [endpoint or network, e.g. "testnet block number" or "mainnet node info"] |
| 5 | +--- |
| 6 | + |
| 7 | +# Query an Aztec node over JSON-RPC |
| 8 | + |
| 9 | +An Aztec node exposes a JSON-RPC HTTP API. Use this skill to fetch chain/tx/node data from a |
| 10 | +live network or a local node, and to run admin/debug operations. |
| 11 | + |
| 12 | +## First: health-check the endpoint |
| 13 | + |
| 14 | +Before anything else, confirm the endpoint answers. The canonical liveness call is |
| 15 | +`aztec_getBlockNumber` (POST to `/`): |
| 16 | + |
| 17 | +```bash |
| 18 | +curl -s -X POST <URL> -H 'content-type: application/json' \ |
| 19 | + -d '{"jsonrpc":"2.0","method":"aztec_getBlockNumber","params":[],"id":1}' |
| 20 | +# -> {"jsonrpc":"2.0","id":1,"result":2445} |
| 21 | +``` |
| 22 | + |
| 23 | +Or use the helper (auto-falls back to the legacy `node_` namespace, e.g. for drpc): |
| 24 | + |
| 25 | +```bash |
| 26 | +.claude/skills/aztec-node-rpc/check-rpc.sh https://v5.testnet.rpc.aztec-labs.com |
| 27 | +# -> OK https://v5.testnet.rpc.aztec-labs.com (aztec_getBlockNumber) block=2445 |
| 28 | +``` |
| 29 | + |
| 30 | +## Wire format |
| 31 | + |
| 32 | +- **Transport**: HTTP POST to path `/`, JSON-RPC 2.0. |
| 33 | +- **Method name**: `<namespace>_<method>`, e.g. `aztec_getBlock`, `aztecAdmin_getConfig`. |
| 34 | +- **Ports** (for a node you run or port-forward): main API on **8080**, admin API on **8880**. |
| 35 | +- Batch requests are supported (array of request objects). |
| 36 | + |
| 37 | +```bash |
| 38 | +curl -s -X POST http://localhost:8080/ -H 'content-type: application/json' \ |
| 39 | + -d '{"jsonrpc":"2.0","method":"aztec_getBlock","params":[42],"id":1}' |
| 40 | +``` |
| 41 | + |
| 42 | +## Namespaces |
| 43 | + |
| 44 | +Registered by `registerAztecNodeRpcHandlers` (yarn-project/aztec-node/src/aztec-node/register_node_rpc_handlers.ts). |
| 45 | + |
| 46 | +| Namespace | Server (port) | Auth | Purpose | |
| 47 | +|---|---|---|---| |
| 48 | +| `aztec` (alias `node`) | main (8080) | none | main read/query + `sendTx` | |
| 49 | +| `p2p` | main (8080) | none | peer/mempool introspection | |
| 50 | +| `aztecDebug` (alias `nodeDebug`) | main (8080) | none | debug ops; only if node started with debug enabled | |
| 51 | +| `aztecAdmin` (alias `nodeAdmin`) | admin (8880) | API key | node config / lifecycle control | |
| 52 | +| `prover` | admin (8880) | API key | prover-node ops (only on a prover node) | |
| 53 | + |
| 54 | +> **Legacy aliases**: `node_*`, `nodeDebug_*`, `nodeAdmin_*` are pre-v5 aliases kept for |
| 55 | +> back-compat. Most public nodes accept the new `aztec_*` names; **drpc only accepts the |
| 56 | +> legacy `node_*` names** (see Endpoints). When `aztec_*` returns `-32601 method is not |
| 57 | +> available`, retry with `node_*`. |
| 58 | +
|
| 59 | +See `references/methods.md` for the full per-namespace method list. Commonly used `aztec_*` |
| 60 | +methods: `getBlockNumber`, `getCheckpointNumber`, `getBlock`, `getBlocks`, `getBlockData`, |
| 61 | +`getChainTips`, `getNodeInfo`, `getNodeVersion`, `getChainId`, `getL1ContractAddresses`, |
| 62 | +`getProtocolContractAddresses`, `getL1Constants`, `getSyncedL2SlotNumber`, |
| 63 | +`getWorldStateSyncStatus`, `sendTx`, `getTxReceipt`, `getTxEffect`, `getTxByHash`, |
| 64 | +`getPendingTxs`, `getPublicStorageAt`, `getContract`, `getCurrentMinFees`, |
| 65 | +`getValidatorsStats`, `simulatePublicCalls`. |
| 66 | + |
| 67 | +## Endpoints |
| 68 | + |
| 69 | +### Public gateways (Kong `key-auth`) |
| 70 | + |
| 71 | +Hosted at `*.rpc.aztec-labs.com`. Auth is either the header `x-aztec-api-key: <key>` **or** |
| 72 | +the key as the first URL path segment (`https://host/<key>` — Kong copies it into the header, |
| 73 | +then strips it before proxying). |
| 74 | + |
| 75 | +| Network / rollup | Hosts | Auth | |
| 76 | +|---|---|---| |
| 77 | +| testnet v5 (canonical) | `v5.testnet.rpc.aztec-labs.com`, `canonical.testnet.rpc.aztec-labs.com` | keyless OK (rate-limited) | |
| 78 | +| testnet v4 | `v4.testnet.rpc.aztec-labs.com`, `testnet.rpc.aztec-labs.com` | keyless OK | |
| 79 | +| mainnet v5 (canonical) | `v5.mainnet.rpc.aztec-labs.com`, `canonical.mainnet.rpc.aztec-labs.com` | **key required** | |
| 80 | +| mainnet v4 | `v4.mainnet.rpc.aztec-labs.com` | **key required** | |
| 81 | + |
| 82 | +Testnet gateways allow keyless use; mainnet requires a consumer key. |
| 83 | + |
| 84 | +```bash |
| 85 | +# testnet — no key |
| 86 | +curl -s -X POST https://v5.testnet.rpc.aztec-labs.com/ -H 'content-type: application/json' \ |
| 87 | + -d '{"jsonrpc":"2.0","method":"aztec_getBlockNumber","params":[],"id":1}' |
| 88 | + |
| 89 | +# mainnet — key from the secrets file (see below) |
| 90 | +. ~/.claude/secrets/aztec-rpc.env |
| 91 | +curl -s -X POST https://v5.mainnet.rpc.aztec-labs.com/ -H 'content-type: application/json' \ |
| 92 | + -H "x-aztec-api-key: ${AZTEC_MAINNET_GATEWAY_KEY}" \ |
| 93 | + -d '{"jsonrpc":"2.0","method":"aztec_getBlockNumber","params":[],"id":1}' |
| 94 | +``` |
| 95 | + |
| 96 | +### drpc (third-party load balancer) |
| 97 | + |
| 98 | +`https://lb.drpc.live/aztec-mainnet/<key>` and `https://lb.drpc.live/aztec-testnet/<key>` |
| 99 | +(key is a URL path segment). **drpc only whitelists the legacy `node_*` namespace** — use |
| 100 | +`node_getBlockNumber`, `node_getNodeInfo`, etc. `aztec_*` methods return `-32601`. |
| 101 | + |
| 102 | +```bash |
| 103 | +. ~/.claude/secrets/aztec-rpc.env |
| 104 | +curl -s -X POST "$AZTEC_DRPC_TESTNET_URL" -H 'content-type: application/json' \ |
| 105 | + -d '{"jsonrpc":"2.0","method":"node_getBlockNumber","params":[],"id":1}' |
| 106 | +``` |
| 107 | + |
| 108 | +### Nodes inside the k8s clusters (kubectl port-forward) |
| 109 | + |
| 110 | +Two GKE clusters (GCP project `testnet-440309`). Contexts: `aztec-gke-public`, `aztec-gke-private`. |
| 111 | + |
| 112 | +| Cluster (context) | Namespaces of interest | |
| 113 | +|---|---| |
| 114 | +| `aztec-gke-public` | `testnet`, `testnet-rpc`, `mainnet` (public/standby), `mainnet-rpc` | |
| 115 | +| `aztec-gke-private` | `next-net`, `mainnet` (ignition — active) | |
| 116 | + |
| 117 | +Every node exposes the main API on **8080** and admin on **8880**. Service names follow |
| 118 | +`<namespace>-<role>[-aztec-node]`: |
| 119 | + |
| 120 | +| Service (svc/…) | Role | |
| 121 | +|---|---| |
| 122 | +| `<ns>-rpc-aztec-node` | public-facing RPC node (LoadBalancer) | |
| 123 | +| `<ns>-validator`, `<ns>-validator-ha-1` | validator/sequencer node | |
| 124 | +| `<ns>-prover-node` | prover node | |
| 125 | +| `<ns>-p2p-bootstrap-node` | p2p bootstrap node | |
| 126 | +| `<ns>-fisherman-aztec-node` | fisherman node (mainnet) | |
| 127 | +| `testnet-rpc-v5-aztec-node`, `mainnet-rpc-canonical-aztec-node` | dedicated RPC upstreams (behind Kong) in the `*-rpc` namespaces | |
| 128 | + |
| 129 | +List what's actually deployed: |
| 130 | +`kubectl --context <ctx> -n <ns> get svc | grep -E 'aztec-node|validator|prover|bootstrap'` |
| 131 | + |
| 132 | +Port-forward and query: |
| 133 | + |
| 134 | +```bash |
| 135 | +kubectl --context aztec-gke-public -n testnet port-forward svc/testnet-rpc-aztec-node 18080:8080 & |
| 136 | +PF=$! |
| 137 | +curl -s --retry 15 --retry-connrefused --retry-delay 1 -X POST http://localhost:18080/ \ |
| 138 | + -H 'content-type: application/json' \ |
| 139 | + -d '{"jsonrpc":"2.0","method":"aztec_getBlockNumber","params":[],"id":1}' |
| 140 | +kill $PF |
| 141 | +``` |
| 142 | + |
| 143 | +For the **admin API** (port 8880) forward `svc/<name>-admin` on `18880:8880` and send the |
| 144 | +namespace's admin key as `x-api-key`. The key lives in a k8s secret: |
| 145 | + |
| 146 | +```bash |
| 147 | +kubectl --context <ctx> -n <ns> get secret aztec-admin-api-key -o jsonpath='{.data.key}' | base64 -d |
| 148 | +``` |
| 149 | + |
| 150 | +## Admin & debug APIs |
| 151 | + |
| 152 | +- **Admin** (`aztecAdmin_*`, port 8880, needs API key): `getConfig`, `setConfig`, `pauseSync`, |
| 153 | + `resumeSync`, `pauseSequencer`, `resumeSequencer`, `rollbackTo`, `startSnapshotUpload`, |
| 154 | + `getSlashOffenses`, `reloadKeystore`. Auth header: `x-api-key: <key>` or `Authorization: Bearer <key>`. |
| 155 | +- **Debug** (`aztecDebug_*`, port 8080, only if the node runs with debug on): `mineBlock`, |
| 156 | + `prove`, `warpL2TimeAtLeastTo`, `warpL2TimeAtLeastBy`, `registerContractFunctionSignatures`. |
| 157 | + Typically only enabled on local/sandbox nodes. |
| 158 | + |
| 159 | +For a node you start locally, `aztec start --node ...` prints the admin API key on first boot |
| 160 | +(persisted under the data dir); pass `--admin-port` / `--port` to change ports. |
| 161 | + |
| 162 | +## Secrets |
| 163 | + |
| 164 | +API keys are **not** stored in this skill. They live in `~/.claude/secrets/aztec-rpc.env` |
| 165 | +(chmod 600) and are `source`d as shown above: |
| 166 | + |
| 167 | +- `AZTEC_MAINNET_GATEWAY_KEY` — mainnet public-gateway consumer key (internal/test consumer, |
| 168 | + GCP secret `mainnet-rpc-consumer-client1`, project `testnet-440309`). |
| 169 | +- `AZTEC_DRPC_MAINNET_URL` / `AZTEC_DRPC_TESTNET_URL` — full drpc URLs with the key embedded. |
| 170 | + |
| 171 | +To (re)issue or inspect gateway consumer keys: `spartan/scripts/create_api_key.sh`, and |
| 172 | +`gcloud secrets list --filter=rpc-consumer` (annotation `client_name` labels each consumer). |
| 173 | +Refresh the stored mainnet key with: |
| 174 | +`gcloud secrets versions access latest --secret=mainnet-rpc-consumer-client1 --project=testnet-440309` |
0 commit comments