Skip to main content

Generate a BIP39 Seed and Mnemonic

Run the Example

You can create a new BIP39 seed with an associated mnemonic phrase in the available languages by running the following command from within the client crate. You can also provide a passphrase to protect the seed.

cargo run --example cli bip39-generate  --passphrase "optional-passphrase" --lang "english" --vault-path "vault-path-0" --record-path "record-path-0"

Expected Output

[2022-06-28T14:01:49Z INFO  cli] BIP39 Mnemonic: canyon situate farm wedding cluster budget truck bag goose obtain surround soda cable galaxy spoil utility tip remember scan danger cat lawsuit staff riot

Example Code

client/examples/cli/main.rs
async fn command_generate_bip39(passphrase: Option<String>, language: MnemonicLanguage, location: VaultLocation) {
let client = Client::default();
let (vault_path, record_path) = (location.vault_path, location.record_path);

let output_location =
stronghold::Location::generic(vault_path.as_bytes().to_vec(), record_path.as_bytes().to_vec());

let bip39_procedure = BIP39Generate {
passphrase,
language,
output: output_location,
};

let result = client.execute_procedure(bip39_procedure).unwrap();

info!("BIP39 Mnemonic: {}", result);
}