SolanaWallet.fromMnemonic constructor

SolanaWallet.fromMnemonic(
  1. String mnemonic
)

Creates and initializes a new SolanaWallet for the given bip39 mnemonic string of 12 words

Implementation

factory SolanaWallet.fromMnemonic(String mnemonic) {
  // Create the seed
  List<int> seedBytes = bip39.mnemonicToSeed(mnemonic);
  // Create a private key from the seed
  PrivateKey privateKey = PrivateKey(seedBytes.sublist(0, 32));
  // Build the key pair
  KeyPair keyPair = ed25519.newKeyPairFromSeedSync(privateKey);
  // Finally, create a new wallet
  return SolanaWallet._fromKeyPair(keyPair);
}