randomSeedPhrase

Generates a random BIP39 mnemonic seed phrase. By default produces a 24-word phrase (256 bits of entropy). Can optionally generate a 12-word phrase (128 bits).


Usage

import { randomSeedPhrase } from '@stacks/wallet-sdk';

// Generate a 24-word seed phrase (default)
const phrase = randomSeedPhrase();
// "warrior volume sport ... figure cake since"

// Generate a 12-word seed phrase
const shortPhrase = randomSeedPhrase(128);

Notes

  • Uses @scure/bip39 under the hood with the English wordlist.

  • The returned string is a space-separated list of BIP39 mnemonic words.

  • The deprecated alias generateSecretKey still works but should be replaced with randomSeedPhrase.

Reference Linkarrow-up-right


Signature


Returns

string

A space-separated BIP39 mnemonic phrase.


Parameters

entropy (optional)

  • Type: 128 | 256

  • Default: 256

The number of bits of entropy. 256 produces a 24-word phrase, 128 produces a 12-word phrase.

Last updated

Was this helpful?