Account Store¶
Class Name | AccountStore |
---|---|
Implements | KeyStoreInterface |
Extends | Logger |
Source | account-store.ts |
The AccountStore implements the KeyStoreInterface and is a wrapper for a storage, where evan.network account ids are stored. The default AccountStore takes an account –> private key mapping as a pojo as its arguments and uses this to perform lookups, when the getPrivateKey function is called. This lookup needs to be done, when transactions are signed by the InternalSigner (see Signer).
Note that the return value of the getPrivateKey function is a promise. This may not be required in the default AccountStore, but this allows you to implement own implementations of the KeyStoreInterface, which may enforce a more strict security behavior or are able to access other sources for private keys.
constructor¶
new AccountStore(options);
Creates a new AccountStore instance.
Parameters¶
options
-AccountStoreOptions
: options for AccountStore constructor.accounts
-any
: object with accountid/privatekey mappinglog
-Function
(optional): function to use for logging:(message, level) => {...}
logLevel
-LogLevel
(optional): messages with this level will be logged withlog
logLog
-LogLogInterface
(optional): container for collecting log messageslogLogLevel
-LogLevel
(optional): messages with this level will be pushed tologLog
Returns¶
AccountStore
instance
getPrivateKey¶
accountStore.getPrivateKey(accountId);
get private key for given account
Parameters¶
accountId
-string
: eth accountId
Returns¶
Promise resolves to string
: private key for this account
Example¶
const privateKey = await runtime.accountStore.getPrivateKey('0x0000000000000000000000000000000000000002');