Mnemonic
Utility functions for generating and working with BIP-39 mnemonics.
Examples
Below are some examples demonstrating common usages of the Mnemonic module:
Generating a Random Mnemonic
Random mnemonics can be generated using Mnemonic.random:
import { Mnemonic } from 'ox'
const mnemonic = Mnemonic.random(Mnemonic.english)
'buyer zoo end danger ice capable shrug naive twist relief mass bonus'Converting to Private Key
Mnemonics can be converted to a private key using Mnemonic.toPrivateKey:
import { Mnemonic } from 'ox'
const privateKey = Mnemonic.toPrivateKey('buyer zoo end danger ice capable shrug naive twist relief mass bonus')
'0x...'Converting to HD Key
Mnemonics can be converted to a HD Key using Mnemonic.toHdKey:
import { Mnemonic } from 'ox'
const hdKey = Mnemonic.toHdKey('buyer zoo end danger ice capable shrug naive twist relief mass bonus')Converting to Seed
Mnemonics can be converted to a master seed using Mnemonic.toSeed:
import { Mnemonic } from 'ox'
const mnemonic = 'buyer zoo end danger ice capable shrug naive twist relief mass bonus'
const seed = Mnemonic.toSeed(mnemonic)
Uint8Array [...64 bytes]Functions
| Name | Description |
|---|---|
Mnemonic.path | Creates an Ethereum-based BIP-44 HD path. |
Mnemonic.random | Generates a random mnemonic. |
Mnemonic.toHdKey | Converts a mnemonic to a HD Key. |
Mnemonic.toPrivateKey | Converts a mnemonic to a private key. |
Mnemonic.toSeed | Converts a mnemonic to a master seed. |
Mnemonic.validate | Checks if a mnemonic is valid, given a wordlist. |

