How to Create a New Account
This guide explains how to create a new account using Aztec.js.
Relevant imports
You will need to import these libraries:
create_account_imports
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
import { Fr, GrumpkinScalar, createPXEClient } from '@aztec/aztec.js';
Source code: yarn-project/end-to-end/src/composed/docs_examples.test.ts#L1-L4
Define arguments needed
define_account_vars
const PXE_URL = process.env.PXE_URL || 'http://localhost:8080';
const secretKey = Fr.random();
const signingPrivateKey = GrumpkinScalar.random();
const pxe = createPXEClient(PXE_URL);
Source code: yarn-project/end-to-end/src/composed/docs_examples.test.ts#L15-L20
Create the wallet with these args
create_wallet
const wallet = await getSchnorrAccount(pxe, secretKey, signingPrivateKey).waitSetup();
Source code: yarn-project/end-to-end/src/composed/docs_examples.test.ts#L22-L24
Now you have a new wallet in your PXE! To learn how to use this wallet to deploy a contract, read this guide.