Addresses
As mentioned in previous sections, the keyring not only has the ability to manage accounts (i.e. keypairs), but also allows you to add addresses/contacts as well as contracts to the keyring. This is very useful in the case where you are developing a wallet and want to save external addresses to interact with.
Here we will give an overview of working with addresses, the same concepts can be expanded to work with contracts.
#
Adding an addressFor accounts, we have the addUri(...)
endpoint that allows us to create and save an account. For addresses, we the keyring exposes saveAddress (address: string, meta: KeyringPair$Meta)
, which we can use to save any address -
From this point forward, the address is in your keyring and can be retrieved via the getAddresses()
interface. The same call can be used to update the meta for the address, for instance if we wish to change the name above, we can do -
And the already-saved address will be updated with the new metadata.
#
Removing an addressTo clear and address and remove it from the keyring, we can use the forgetAddress(address: string)
call, this mirrors the forgetAccount(address: string)
and forgetContract(address: string)
calls. For instance -
#
Retrieving previously-savedWith all interactions with the keyring, the information is persisted. In the next section we will take a look at retrieval of saved information, typically done on first init.