# getMnemonic

Returns the mnemonic

# Type

;() => string

# Return Value

A string encoding a BIP39 mnemonic.

# Description

You can set the mnemonic in the constructor of the Computer class. The mnemonic needs to have at least 12 words, otherwise an error is thrown. If the mnemonic property is left undefined a random mnemonic will be generated using the generateMnemonic of the bip39 library.

# Example

import { Computer } from '@bitcoin-computer/lib'
import { expect } from '../../utils'

describe('getMnemonic', () => {
  it('Should return the mnemonic', async () => {
    // Create wallet with a specific mnemonic
    const mnemonic = 'warm almost lobster swim situate hidden tiger ski whale donate sock number'
    const c = new Computer({ mnemonic })

    // Check mnemonic
    expect(c.getMnemonic()).eq(mnemonic)
  })
})

Sources