Skip to main content

Method Signature

align.blockchain.wallets.createFromMnemonic(
  mnemonic: string
): Promise<Wallet>

Parameters

mnemonic
string
required
12 or 24-word BIP-39 recovery phrase, space-separated

Returns

address
string
The wallet’s public address (e.g., 0x...)
privateKey
string
The wallet’s private key
mnemonic
string
The mnemonic phrase used

Examples

import Align from "@tolbel/align";

const align = new Align({
  apiKey: process.env.ALIGN_API_KEY!,
  environment: "sandbox",
});

const mnemonic = "witch collapse practice feed shame open despair creek road again ice least";

const wallet = await align.blockchain.wallets.createFromMnemonic(mnemonic);

console.log(`Address: ${wallet.address}`);
// Address: 0x742d35Cc6634C0532925a3b844Bc9e7595f0aB42

HD Wallet Recovery

Mnemonics generate deterministic wallets - the same mnemonic always produces the same wallet:
// These will produce identical wallets
const wallet1 = await align.blockchain.wallets.createFromMnemonic(mnemonic);
const wallet2 = await align.blockchain.wallets.createFromMnemonic(mnemonic);

console.log(wallet1.address === wallet2.address); // true

Error Handling

import { AlignValidationError } from "@tolbel/align";

try {
  const wallet = await align.blockchain.wallets.createFromMnemonic(
    "invalid mnemonic phrase"
  );
} catch (error) {
  if (error instanceof AlignValidationError) {
    console.error("Invalid mnemonic:", error.errors);
    // [{ message: "Invalid mnemonic phrase" }]
  }
}
Security: Never share your mnemonic phrase. Anyone with access to it has full control of your wallet and funds.

Create Wallet

Create new random wallet

From Private Key

Import from private key