Skip to main content

How to Create a New Account

This guide explains how to create a new account using Aztec.js.

To do this from the CLI, go here.

Relevant imports

You will need to import these libraries:

create_account_imports
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
import { GrumpkinScalar, createPXEClient } from '@aztec/aztec.js';
Source code: /yarn-project/end-to-end/src/docs_examples.test.ts#L1-L4 (aztec-packages-v0.24.0)

Define arguments needed

define_account_vars
const PXE_URL = process.env.PXE_URL || 'http://localhost:8080';
const encryptionPrivateKey = GrumpkinScalar.random();
const signingPrivateKey = GrumpkinScalar.random();
const pxe = createPXEClient(PXE_URL);
Source code: /yarn-project/end-to-end/src/docs_examples.test.ts#L13-L18 (aztec-packages-v0.24.0)

Create the wallet with these args

create_wallet
const wallet = await getSchnorrAccount(pxe, encryptionPrivateKey, signingPrivateKey).waitDeploy();
Source code: /yarn-project/end-to-end/src/docs_examples.test.ts#L20-L22 (aztec-packages-v0.24.0)

Now you have a new wallet in your PXE! To learn how to use this wallet to deploy a contract, read this guide.