Creating a wallet

How to set up a new wallet.

Background

A wallet enables you to store your account to sign transactions, encrypting your private key with a password.

Prerequisites

Method #01: Using the SDK

If the programming language of the SDK you are using allows client-side development, you will be able to create a wallet.

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

// replace with password
const password = new Password('password');

const wallet = SimpleWallet.create('wallet-name', password, NetworkType.TEST_NET);
const account = wallet.open(password);
console.log('Your new account address is:', account.address.pretty(), 'and its private key', account.privateKey);
// replace with password
const password = new nem2_sdk_1.Password('password');
const wallet = nem2_sdk_1.SimpleWallet.create('wallet-name', password, nem2_sdk_1.NetworkType.TEST_NET);
const account = wallet.open(password);
console.log('Your new account address is:', account.address.pretty(), 'and its private key', account.privateKey);
nem2-cli profile create --network TEST_NET --url http://api-xym-harvest-3-01.us-west-2.nemtech.network:3000 --password 12345678 --profile test_net_profile_2

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

// replace with password
const password = new Password('password');
// replace with private key
const privateKey = '0000000000000000000000000000000000000000000000000000000000000000';

const wallet = SimpleWallet.createFromPrivateKey('wallet-name', password, privateKey, NetworkType.TEST_NET);
const account = wallet.open(password);
console.log('Your account address is:', account.address.pretty(), 'and its private key', account.privateKey);
// replace with password
const password = new nem2_sdk_1.Password('password');
// replace with private key
const privateKey = '0000000000000000000000000000000000000000000000000000000000000000';
const wallet = nem2_sdk_1.SimpleWallet.createFromPrivateKey('wallet-name', password, privateKey, nem2_sdk_1.NetworkType.TEST_NET);
const account = wallet.open(password);
console.log('Your account address is:', account.address.pretty(), 'and its private key', account.privateKey);

Method #02: Using the CLI

In NEM2-CLI, wallets are named profiles.

Create a new wallet with the following command:

nem2-cli profile create --network TEST_NET --url http://api-xym-harvest-3-01.us-west-2.nemtech.network:3000 --password 12345678 --profile test_net_profile_2

If you already have a private key, you can store it as a profile.

nem2-cli profile import --private-key 0000000000000000000000000000000000000000000000000000000000000000 --network TEST_NET --url http://api-xym-harvest-3-01.us-west-2.nemtech.network:3000 --password 12345678 --profile test_net_profile