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.TEST_NET);
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.TEST_NET);
console.log('Your new account address is:', account.address.pretty(), 'and its private key', account.privateKey);
        final Account account = Account.generateNewAccount(NetworkType.TEST_NET);

        System.out.printf("Your new account address is: %s and its private key: %s",
            account.getAddress().plain(), account.getPrivateKey());

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

// replace with private key
const privateKey = '0000000000000000000000000000000000000000000000000000000000000000';

const account = Account.createFromPrivateKey(privateKey, NetworkType.TEST_NET);
console.log('Your account address is:', account.address.pretty(), 'and its private key', account.privateKey);
// replace with private key
const privateKey = '0000000000000000000000000000000000000000000000000000000000000000';
const account = nem2_sdk_1.Account.createFromPrivateKey(privateKey, nem2_sdk_1.NetworkType.TEST_NET);
console.log('Your account address is:', account.address.pretty(), 'and its private key', account.privateKey);
        // Replace with a private key
        final String privateKey = "0000000000000000000000000000000000000000000000000000000000000000";
        final Account account = Account.createFromPrivateKey(privateKey, NetworkType.TEST_NET);

        System.out.printf("Your account address is: %s and its private key: %s",
            account.getAddress().plain(), account.getPrivateKey());

Method #02: Using the CLI

nem2-cli account generate --network TEST_NET