Creating Accounts
This guide shows you how to create and deploy a new account on Aztec.
Prerequisites
- Connected to a network with a
TestWalletinstance - Understanding of account concepts
Install dependencies
yarn add @aztec/aztec.js@4.0.0-nightly.20260204 @aztec/test-wallet@4.0.0-nightly.20260204
Create a new account
Using the wallet from the connection guide, call createSchnorrAccount to create a new account with a random secret and salt:
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());
Source code: docs/examples/ts/aztecjs_connection/index.ts#L39-L46
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.
Save the secret and salt values securely. You need both to recover access to your account. If you lose them, you will permanently lose access to the account and any assets it holds.
Deploy the account
New accounts must be deployed before they can send transactions. Deployment requires paying fees.
Using the Sponsored FPC
If your account doesn't have Fee Juice, use the Sponsored Fee Payment Contract:
// Additional imports needed for account deployment examples
import { AztecAddress } from "@aztec/aztec.js/addresses";
import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing";
import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC";
import { getContractInstanceFromInstantiationParams } from "@aztec/stdlib/contract";
// Set up the Sponsored FPC payment method (see fees guide for details)
const sponsoredFPCInstance = await getContractInstanceFromInstantiationParams(
SponsoredFPCContract.artifact,
{ salt: new Fr(0) },
);
await wallet.registerContract(
sponsoredFPCInstance,
SponsoredFPCContract.artifact,
);
const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(
sponsoredFPCInstance.address,
);
// newAccount is the account created in the previous section
const deployMethod = await newAccount.getDeployMethod();
await deployMethod.send({
from: AztecAddress.ZERO,
fee: { paymentMethod: sponsoredPaymentMethod },
});
Source code: docs/examples/ts/aztecjs_connection/index.ts#L48-L74
See the guide on fees for setting up the Sponsored FPC.
Using Fee Juice
If your account already has Fee Juice (for example, bridged from L1):
// newAccount is the account created in the previous section
const deployMethodFeeJuice = await newAccount.getDeployMethod();
await deployMethodFeeJuice.send({
from: AztecAddress.ZERO,
});
Source code: docs/examples/ts/aztecjs_connection/index.ts#L76-L82
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:
const metadata = await wallet.getContractMetadata(newAccount.address);
console.log("Account deployed:", metadata.isContractInitialized);
Source code: docs/examples/ts/aztecjs_connection/index.ts#L84-L87
Next steps
- Deploy contracts with your new account
- Send transactions from an account
- Learn about account abstraction
- Implement authentication witnesses