Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Install the required tools:

```bash
# Install Aztec CLI
bash -i <(curl -s https://install.aztec.network)
bash -i <(curl -sL https://install.aztec.network)
aztec-up 3.0.0-devnet.6-patch.1

# Install Nargo via noirup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Before working with devnet, ensure you have:
2. Aztec CLI installed:

```sh
bash -i <(curl -s https://install.aztec.network)
bash -i <(curl -sL https://install.aztec.network)
```

3. The devnet version installed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Docker needs to be running in order to install the local network. Find instructi
Run:

```bash
bash -i <(curl -s https://install.aztec.network)
bash -i <(curl -sL https://install.aztec.network)
```

Once the installation is complete, install the specific version:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,58 +23,35 @@ yarn add @aztec/aztec.js@#include_version_without_prefix @aztec/test-wallet@#inc

Create a node client and TestWallet to interact with the local network:

```typescript
import { createAztecNodeClient, waitForNode } from "@aztec/aztec.js/node";
import {
TestWallet,
registerInitialLocalNetworkAccountsInWallet,
} from "@aztec/test-wallet/server";
#include_code connect_to_network /docs/examples/ts/aztecjs_connection/index.ts typescript

const nodeUrl = "http://localhost:8080";
const node = createAztecNodeClient(nodeUrl);
:::note About TestWallet
`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.

// Wait for the network to be ready
await waitForNode(node);
**Why use it for testing?** It starts instantly, requires no setup, and provides deterministic behavior—ideal for automated tests and rapid iteration.

// Create a TestWallet connected to the node
const wallet = await TestWallet.create(node);
```

`TestWallet` is a development wallet that handles account management and transaction signing locally, suitable for testing and development.
**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:

```typescript
const nodeInfo = await node.getNodeInfo();
console.log("Connected to local network version:", nodeInfo.nodeVersion);
console.log("Chain ID:", nodeInfo.l1ChainId);
```
#include_code verify_connection /docs/examples/ts/aztecjs_connection/index.ts typescript

### Load pre-funded accounts

The local network has accounts pre-funded with fee juice to pay for gas. Register them in your wallet:

```typescript
const [alice, bob] = await registerInitialLocalNetworkAccountsInWallet(wallet);

console.log(`Alice's address: ${alice.toString()}`);
console.log(`Bob's address: ${bob.toString()}`);
```
#include_code load_accounts /docs/examples/ts/aztecjs_connection/index.ts typescript

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:

```typescript
import { getFeeJuiceBalance } from "@aztec/aztec.js/utils";

const aliceBalance = await getFeeJuiceBalance(alice, node);
console.log(`Alice's fee juice balance: ${aliceBalance}`);
```
#include_code check_fee_juice /docs/examples/ts/aztecjs_connection/index.ts typescript

## Next steps

Expand Down
41 changes: 6 additions & 35 deletions docs/docs-developers/docs/aztec-js/how_to_create_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,9 @@ yarn add @aztec/aztec.js@#include_version_without_prefix @aztec/test-wallet@#inc

## Create a new account

Use the wallet's `createSchnorrAccount` method to create a new account with a random secret and salt:
Using the [`wallet` from the connection guide](./how_to_connect_to_local_network.md), call `createSchnorrAccount` to create a new account with a random secret and salt:

```typescript
import { Fr } from "@aztec/aztec.js/fields";

const secret = Fr.random();
const salt = Fr.random();
const newAccount = await wallet.createSchnorrAccount(secret, salt);
console.log("New account address:", newAccount.address.toString());
```
#include_code create_account /docs/examples/ts/aztecjs_connection/index.ts typescript

The secret is used to derive the account's encryption keys, and the salt ensures address uniqueness. The signing key is automatically derived from the secret.

Expand All @@ -45,47 +38,25 @@ New accounts must be deployed before they can send transactions. Deployment requ

If your account doesn't have Fee Juice, use the [Sponsored Fee Payment Contract](./how_to_pay_fees.md#sponsored-fee-payment-contracts):

```typescript
import { AztecAddress } from "@aztec/aztec.js/addresses";

const deployMethod = await newAccount.getDeployMethod();
await deployMethod
.send({
from: AztecAddress.ZERO,
fee: { paymentMethod: sponsoredPaymentMethod },
})
.wait();
```
#include_code deploy_account_sponsored_fpc /docs/examples/ts/aztecjs_connection/index.ts typescript

:::info
See the [guide on fees](./how_to_pay_fees.md#sponsored-fee-payment-contracts) for setting up `sponsoredPaymentMethod`.
See the [guide on fees](./how_to_pay_fees.md#sponsored-fee-payment-contracts) for setting up the Sponsored FPC.
:::

### Using Fee Juice

If your account already has Fee Juice (for example, [bridged from L1](./how_to_pay_fees.md#bridge-fee-juice-from-l1)):

```typescript
import { AztecAddress } from "@aztec/aztec.js/addresses";

const deployMethod = await newAccount.getDeployMethod();
await deployMethod
.send({
from: AztecAddress.ZERO,
})
.wait();
```
#include_code deploy_account_fee_juice /docs/examples/ts/aztecjs_connection/index.ts typescript

The `from: AztecAddress.ZERO` is required because there's no existing account to send from—the transaction itself creates the account.

## Verify deployment

Confirm the account was deployed successfully:

```typescript
const metadata = await wallet.getContractMetadata(newAccount.address);
console.log("Account deployed:", metadata.isContractInitialized);
```
#include_code verify_account_deployment /docs/examples/ts/aztecjs_connection/index.ts typescript

## Next steps

Expand Down
Loading
Loading