Creating an account

How to create a new Catapult account.

Prerequisites

Method #01: Using the SDK

Open a new file and run the following code snippet to create an account.

const account = Account.generateNewAccount(NetworkType.MIJIN_TEST);

console.log('Your new account address is:', account.address.pretty(), 'and its private key', account.privateKey);
const account = nem2_sdk_1.Account.generateNewAccount(nem2_sdk_1.NetworkType.MIJIN_TEST);
console.log('Your new account address is:', account.address.pretty(), 'and its private key', account.privateKey);
nem2-cli account generate --network MIJIN_TEST

If you already have a private key, you can use it to define a new Account object.

const privateKey = process.env.PRIVATE_KEY as string;
const account = Account.createFromPrivateKey(privateKey, NetworkType.MIJIN_TEST);

console.log('Your account address is:', account.address.pretty(), 'and its private key', account.privateKey);
const privateKey = process.env.PRIVATE_KEY;
const account = nem2_sdk_1.Account.createFromPrivateKey(privateKey, nem2_sdk_1.NetworkType.MIJIN_TEST);
console.log('Your account address is:', account.address.pretty(), 'and its private key', account.privateKey);

Method #02: Using the CLI

nem2-cli account generate --network MIJIN_TEST