A Mnemonic wraps all properties required to compute BIP-39 seeds and convert between phrases and entropy.

Constructors

new Mnemonic()

new Mnemonic(
   guard, 
   entropy, 
   phrase, 
   password?, 
   wordlist?): Mnemonic

Parameters

ParameterTypeDescription
guardanyThe guard object.
entropystringThe entropy.
phrasestringThe mnemonic phrase.
password?null | stringThe password for the mnemonic.
wordlist?null | WordlistThe wordlist for the mnemonic.

Returns

Mnemonic

Source

wallet/mnemonic.ts:175

Properties

PropertyModifierTypeDescription
entropyreadonlystringThe underlying entropy which the mnemonic encodes.
passwordreadonlystringThe password used for this mnemonic. If no password is used this is the empty string (i.e. "") as per the
specification.
phrasereadonlystringThe mnemonic phrase of 12, 15, 18, 21 or 24 words.

Use the wordlist split method to get the individual words.
wordlistreadonlyWordlistThe wordlist for this mnemonic.

Methods

computeSeed()

computeSeed(): string

Returns the seed for the mnemonic.

Returns

string

The seed.

Source

wallet/mnemonic.ts:191


entropyToPhrase()

static entropyToPhrase(_entropy, wordlist?): string

Returns the phrase for mnemonic.

Parameters

ParameterTypeDescription
_entropyBytesLikeThe entropy for the mnemonic.
wordlist?null | WordlistThe wordlist for the mnemonic.

Returns

string

The mnemonic phrase.

Source

wallet/mnemonic.ts:248


fromEntropy()

static fromEntropy(
   _entropy, 
   password?, 
   wordlist?): Mnemonic

Create a new Mnemonic from the entropy.

The default password is the empty string and the default wordlist is the [English wordlist.

Parameters

ParameterTypeDescription
_entropyBytesLikeThe entropy for the mnemonic.
password?null | stringThe password for the mnemonic.
wordlist?null | WordlistThe wordlist for the mnemonic.

Returns

Mnemonic

The new Mnemonic object.

Source

wallet/mnemonic.ts:229


fromPhrase()

static fromPhrase(
   phrase, 
   password?, 
   wordlist?): Mnemonic

Creates a new Mnemonic for the phrase.

The default password is the empty string and the default wordlist is the English wordlist.

Parameters

ParameterTypeDescription
phrasestringThe mnemonic phrase.
password?null | stringThe password for the mnemonic.
wordlist?null | WordlistThe wordlist for the mnemonic.

Returns

Mnemonic

The new Mnemonic object.

Source

wallet/mnemonic.ts:206


isValidMnemonic()

static isValidMnemonic(phrase, wordlist?): boolean

Returns true if phrase is a valid BIP-39 phrase.

This checks all the provided words belong to the wordlist, that the length is valid and the checksum is correct.

Parameters

ParameterTypeDescription
phrasestringThe mnemonic phrase.
wordlist?null | WordlistThe wordlist for the mnemonic.

Returns

boolean

True if the phrase is valid.

Throws

If the phrase is invalid.

Source

wallet/mnemonic.ts:275


phraseToEntropy()

static phraseToEntropy(phrase, wordlist?): string

Returns the entropy for phrase.

Parameters

ParameterTypeDescription
phrasestringThe mnemonic phrase.
wordlist?null | WordlistThe wordlist for the mnemonic.

Returns

string

The entropy.

Source

wallet/mnemonic.ts:260