Generating Mnemonics
newMnemonic() for producing a fresh BIP-39 recovery phrase to back a new HD account before it is created.
newMnemonic() produces a fresh BIP-39 recovery phrase for backing a new HD account. Generate the phrase, show it to the user to write down, then pass it to accounts.create as the account's secret.
Usage
import { newMnemonic } from "wative-core";
const phrase = newMnemonic();
// e.g. "legal winner thank year wave sausage worth useful legal winner thank yellow"Signature
newMnemonic(): stringTakes no arguments and returns a 12-word English BIP-39 mnemonic as a single space-separated string.
Entropy
The phrase is drawn from 16 bytes (128 bits) of entropy from the platform CSPRNG (crypto.getRandomValues), encoded to 12 words. The source is resolved per-runtime, so the function is isomorphic — it works the same in Node, the browser, and Edge runtimes.
The returned phrase is the only way to recover the account's keys. Capture it once, offer it to the user to record offline, and do not log or persist it in plaintext. Once the account exists, the phrase is available only through dumpMnemonic() on the unlocked account.
Backing a new HD account
Pass the phrase as the secret to accounts.create. A valid mnemonic is inferred as an HD account, so opts.kind is optional.
import { Workspace, newMnemonic } from "wative-core";
const ws = await Workspace.open({ path: "./my-wallet", password: "wsp-pwd" });
const phrase = newMnemonic();
const acc = await ws.accounts.create("Desk", "wsp-pwd", phrase);
acc.organizationType; // "HD"
acc.dumpMnemonic(); // === phrase (account must be unlocked)accounts.create validates the mnemonic checksum before sealing it. A malformed phrase is rejected with INVALID_MNEMONIC at create time rather than failing later at unlock.
Once the account exists, derive more wallets with deriveWallets(n) — see HD Accounts.