Keyring class

A manager for sr25519-based key pairs in the keyring.

The Keyring class provides a convenient interface to manage sr25519-based key pairs. It allows you to create key pairs from BIP39 mnemonics, add them to the keyring, retrieve key pairs by address or public key, and perform various operations on them.

Example usages for each function are provided below.

Constructors

Keyring()

Properties

addresses → List<String>
Get all addresses in the keyring.
no setter
all → List<KeyPair>
Get all KeyPairs in the keyring.
no setter
hashCode → int
The hash code for this object.
no setterinherited
keyPairType → KeyPairType
final
pairs → Pairs
final
publicKeys → List<List<int>>
Get all public keys in the keyring.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(KeyPair pair) → void
Add a KeyPair to the keyring.
clear() → void
Remove all key pairs from the keyring.
decodeAddress(String address) → Uint8List
Decode an SS58 address to its public key. The default SS58 address format used by the keyring is 42.
encodeAddress(List<int> key, [int ss58Format = 42]) → String
Encode a public key to an SS58 address. The default SS58 address format used by the keyring is 42.
fromMnemonic(String mnemonic, {String? password, bool addToPairs = false, KeyPairType? keyPairType}) → Future<KeyPair>
Create a new KeyPair from a BIP39 mnemonic and optionally add it to the keyring.
fromSeed(Uint8List seed, {bool addToPairs = false, KeyPairType? keyPairType}) → KeyPair
Create a new KeyPair from a Uint8List seed and optionally add it to the keyring.
fromUri(String uri, {String? password, bool addToPairs = false, KeyPairType? keyPairType}) → Future<KeyPair>
Create a new KeyPair from a BIP39 mnemonic and optionally add it to the keyring.
getByAddress(String address) → KeyPair
Get a KeyPair from the keyring by address. If the pair does not exist, it will throw an error.
getByPublicKey(List<int> publicKey) → KeyPair
Get a KeyPair from the keyring by public key.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(String address) → void
Remove a KeyPair from the keyring by address.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

ecdsa → Keyring
Create a new Keyring instance for sr25519.
no setter
ed25519 → Keyring
Create a new Keyring instance for ed25519.
no setter
sr25519 → Keyring
Create a new Keyring instance for sr25519.
no setter