Connect to Local Network
This guide shows you how to connect your application to the Aztec local network and interact with the network.
Prerequisites
- Running Aztec local network (see Quickstart) on port 8080
- Node.js installed
- TypeScript project set up
Install dependencies
yarn add @aztec/aztec.js@4.0.0-nightly.20260204 @aztec/test-wallet@4.0.0-nightly.20260204
Connect to the network
Create a node client and TestWallet to interact with the local network:
import { createAztecNodeClient, waitForNode } from "@aztec/aztec.js/node";
import {
TestWallet,
registerInitialLocalNetworkAccountsInWallet,
} from "@aztec/test-wallet/server";
const nodeUrl = "http://localhost:8080";
const node = createAztecNodeClient(nodeUrl);
// Wait for the network to be ready
await waitForNode(node);
// Create a TestWallet connected to the node
const wallet = await TestWallet.create(node);
Source code: docs/examples/ts/aztecjs_connection/index.ts#L1-L16
TestWallet is a simplified wallet for local development that implements the same Wallet interface used in production. It handles key management, transaction signing, and proof generation in-process without external dependencies.
Why use it for testing? It starts instantly, requires no setup, and provides deterministic behavior—ideal for automated tests and rapid iteration.
Production wallets (like browser extensions or mobile apps) implement the same interface but store keys securely, may require user confirmation for transactions, and typically run in a separate process. Code written against TestWallet works with any Wallet implementation, so your application logic transfers directly to production.
Verify the connection
Get node information to confirm your connection:
const nodeInfo = await node.getNodeInfo();
console.log("Connected to local network version:", nodeInfo.nodeVersion);
console.log("Chain ID:", nodeInfo.l1ChainId);
Source code: docs/examples/ts/aztecjs_connection/index.ts#L18-L22
Load pre-funded accounts
The local network has accounts pre-funded with fee juice to pay for gas. Register them in your wallet:
const [aliceAddress, bobAddress] =
await registerInitialLocalNetworkAccountsInWallet(wallet);
console.log(`Alice's address: ${aliceAddress.toString()}`);
console.log(`Bob's address: ${bobAddress.toString()}`);
Source code: docs/examples/ts/aztecjs_connection/index.ts#L24-L30
These accounts are pre-funded with fee juice (the native gas token) at genesis, so you can immediately send transactions without needing to bridge funds from L1.
Check fee juice balance
Verify that an account has fee juice for transactions:
import { getFeeJuiceBalance } from "@aztec/aztec.js/utils";
const aliceBalance = await getFeeJuiceBalance(aliceAddress, node);
console.log(`Alice's fee juice balance: ${aliceBalance}`);
Source code: docs/examples/ts/aztecjs_connection/index.ts#L32-L37
Next steps
- Create an account - Deploy new accounts on the network
- Deploy a contract - Deploy your smart contracts
- Send transactions - Execute contract functions