fromUri method
Future<KeyPair>
fromUri(
- String uri, {
- String? password,
- bool addToPairs = false,
- KeyPairType? keyPairType,
Create a new KeyPair from a BIP39 mnemonic and optionally add it to the keyring.
This method generates a key pair from the provided uri.
uri: The BIP39 mnemonic phrase used to derive the key pair.addToPairs: If set totrue, the key pair will be added to the keyring, defaults tofalse.
Example:
final keyring = Keyring();
// final uri = '//Alice';
final keyPair = await keyring.fromUri(uri);
Implementation
Future<KeyPair> fromUri(
String uri, {
String? password,
bool addToPairs = false,
KeyPairType? keyPairType,
}) async {
late KeyPair pair;
switch (keyPairType ?? this.keyPairType) {
case KeyPairType.ed25519:
pair = await KeyPair.ed25519.fromUri(uri, password);
break;
case KeyPairType.ecdsa:
pair = await KeyPair.ecdsa.fromUri(uri, password);
break;
default:
pair = await KeyPair.sr25519.fromUri(uri, password);
}
if (addToPairs) {
pairs.add(pair);
}
return pair;
}