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-devnet.2-patch.0 @aztec/wallets@4.0.0-devnet.2-patch.0
Connect to the network
Create a node client and EmbeddedWallet to interact with the local network:
import { createAztecNodeClient, waitForNode } from "@aztec/aztec.js/node";
import { EmbeddedWallet } from "@aztec/wallets/embedded";
import { getInitialTestAccountsData } from "@aztec/accounts/testing";
const nodeUrl = "http://localhost:8080";
const node = createAztecNodeClient(nodeUrl);
// Wait for the network to be ready
await waitForNode(node);
// Create an EmbeddedWallet connected to the node
const wallet = await EmbeddedWallet.create(node);
Source code: docs/examples/ts/aztecjs_connection/index.ts#L1-L14
EmbeddedWallet 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 EmbeddedWallet 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#L16-L20
Load pre-funded accounts
The local network has accounts pre-funded with fee juice to pay for gas. Register them in your wallet:
const testAccounts = await getInitialTestAccountsData();
const [aliceAddress, bobAddress] = await Promise.all(
testAccounts.slice(0, 2).map(async (account) => {
return (await wallet.createSchnorrAccount(account.secret, account.salt, account.signingKey)).address;
}),
);
console.log(`Alice's address: ${aliceAddress.toString()}`);
console.log(`Bob's address: ${bobAddress.toString()}`);
Source code: docs/examples/ts/aztecjs_connection/index.ts#L22-L32
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#L34-L39
Next steps
- Create an account - Deploy new accounts on the network
- Deploy a contract - Deploy your smart contracts
- Send transactions - Execute contract functions