RAILGUN Wallets must be generated using a 12- or 24- word mnemonic.
In order to create a new RAILGUN wallet, you may first generate a mnemonic using ethers.js.

Example: Generate mnemonic using ethers.js

import { entropyToMnemonic, randomBytes } from 'ethers/lib/utils';
const mnemonic = entropyToMnemonic(randomBytes(16));
RAILGUN Wallets are created using an encryption key and mnemonic. They will be encrypted and stored into the LevelDOWN database, which you initialized in Start Railgun Engine.
You may provide an optional creationBlockNumberMap which contains the block numbers for each chain when the wallet was created. This mapping will optimize private balance scans, especially for newly created wallets.

Example: Create RAILGUN Wallet from mnemonic

import { createRailgunWallet } from '@railgun-community/wallet';
// Current block numbers for each chain when wallet was first created.
// If unknown, provide undefined.
const creationBlockNumberMap: MapType<number> = {
[NetworkName.Ethereum]: 15725700,
[NetworkName.Polygon]: 3421400,
const railgunWalletInfo = await createRailgunWallet(
const id = railgunWalletInfo.id;
After first load, Railgun Wallets can be reloaded instantly using function loadWalletByID. You will want to store the field railgunWallet.id and the encryptionKey in order to load it again. The railgunWallet.id field will be used to reference the wallet when scanning balances, requesting transaction history, or creating new transactions.

Example: Load stored RAILGUN Wallet by its ID

import { loadWalletByID } from '@railgun-community/wallet';
const railgunWalletInfo = await loadWalletByID(encryptionKey, id);