fromMnemonic static method

Future<Ed25519HDKeyPair> fromMnemonic(
  1. String mnemonic, {
  2. int? account,
  3. int? change,
})

Creates and initializes the accountth SolanaWallet and the changeth account for the given bip39 mnemonic string of 12 words.

Omitting account or change means they will be null with the following rules of the meaning of null in this context.

If either account or change is null, and the other is not, then it will be taken to be zero.

If account and change are both null, then we derive the address that would be returned by using

solana-keygen pubkey prompt://

and passing the mnemonic seed phrase

Implementation

static Future<Ed25519HDKeyPair> fromMnemonic(
  String mnemonic, {
  int? account,
  int? change,
}) {
  final List<int> seed = bip39.mnemonicToSeed(mnemonic);

  return Ed25519HDKeyPair.fromSeedWithHdPath(
    seed: seed,
    hdPath: getHDPath(account, change),
  );
}