unlockFromMnemonic method
Unlock a KeyPair
from a given BIP39 mnemonic.
This method unlocks the KeyPair
by adding the private key.
Example:
final mnemonic = "your mnemonic phrase"; // Replace with your actual mnemonic
final keyPair = await KeyPair.sr25519.fromMnemonic(mnemonic);
keyPair.lock();
keyPair.sign(message); // Throws an error
keyPair.unlockFromMnemonic(mnemonic);
keyPair.sign(message); // Works
Implementation
@override
Future<void> unlockFromMnemonic(String mnemonic, [String? password]) async {
final seed = await SubstrateBip39.ed25519.seedFromUri(mnemonic);
_unlock(sr25519.SecretKey.fromEd25519Bytes(seed));
}