Creating addresses

Generating an NGNT address

To receive NGNT, one needs an address. An NGNT address is also a regular Ethereum address. You can receive ETH, NGNT & all other ERC 20 tokens with the same address.

In the Ethereum world term "account" is used interchangeably with "address".

We prefer to use ethers.js for all account/address generation needs.

Generating an address with a seed phrase

const ethers = require('ethers');
const mnemonic = <seed phrase here>; 
// you can generate random seed phrase with await ethers.HDNode.entropyToMnemonic(ethers.utils.randomBytes(16));
const wallet = ethers.Wallet.fromMnemonic(mnemonic);
const address = wallet.address;

Generating multiple addresses with the same seed phrase

Here's how to use web3 to generate multiple addresses with the same mnemonic seed phrase.

Getting multiple addresses from the same seed phrase is useful when the app developer intends to assign addresses to individual users. There'll be no need to manage multiple private keys or seeds per user address.

To do this, we'll need to combine the seed phrase with something called the derivation path. For the purpose of this guide, we should treat the derivation path as an index. We will increment the last digit of the derivation path to create new address with the same phrase.

First address derivation path = m/44'/60'/0'/0/0
Second address derivation path = m/44'/60'/0'/0/1
Third address derivation path = m/44'/60'/0'/0/2
Fourth address derivation path = m/44'/60'/0'/0/3

...and so on

As we can see, the last character of the derivation path acts very similarly to the an array's index.

Ethers.js lets you generate different addresses using the same seed phrase with multiple derivation paths.

It is useful to store derivation paths (or the index that is the last character) in your application's database along with the account/address. This allows you to derivePath to get the addressNode which can be used to sign transactions on behalf of that address.

Last updated

Was this helpful?