ElvWallet
Constructor
Create a new ElvWallet connected to the given provider
NOTE: It is recommended to initialize wallets from the ElvClient, not using this constructor
AddAccount
accountName, // optional
privateKey
}) → Signer
Add an account from a private key (Ethereum keystore format)
Returns: Signer with the private key, connected to the provider
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
accountName | string | Name of account to save in wallet. Account will be saved in the wallet if provided. | |
privateKey | string | ✓ | Private key to use |
AddAccountFromEncryptedPK
accountName, // optional
encryptedPrivateKey
}) → Promise.<Signer>
Add an account from an encrypted private key (Ethereum keystore format)
Returns: Signer with the decrypted private key, connected to the provider
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
accountName | string | Name of account to save in wallet. Account will be saved in the wallet if provided. | |
encryptedPrivateKey | string | ✓ | Encrypted private key to decrypt |
AddAccountFromMnemonic
accountName, // optional
mnemonic
}) → Signer
Generate a private key from the given mnemonic
Returns: Signer with the generated private key, connected to the provider
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
accountName | string | Name of account to save in wallet. Account will be saved in the wallet if provided. | |
mnemonic | string | ✓ | Mnemonic from which to generate a private key |
GenerateEncryptedPrivateKey
accountName, // optional
signer, // optional
password
}) → Promise.<string>
Generate the encrypted private key (Ethereum keystore format) of the signer's private key The private key to decrypt can be specified either by passing the signer object, or by passing the account name of a saved account
Note: Either the signer OR the account name should be specified
Returns: The encrypted private key (in Ethereum keystore format)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
accountName | string | Saved account to encrypt the private key of | |
signer | string | Signer to encrypt the private key of | |
password | string | ✓ | Password to encrypt the private key with |
GenerateMnemonic
Generate a mnemonic that can be used to initialize a private key
Returns: Space-separated list of random words
GetAccount
Get the signer of a previously saved account by name
Returns: Signer of the saved account, if it exists
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
accountName | string | ✓ | Name of the account |
GetAccountBalance
accountName, // optional
signer // optional
}) → number
Get the balance of the account. The account to query can be specified either by passing the signer object, or by passing the account name of a saved account
Note: Either the signer OR the account name should be specified
Returns: Account balance of the specified account, in ETH
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
accountName | string | Saved account to query the account balance of | |
signer | Signer | Signer to query the account balance of |
RemoveAccount
Remove a previously saved account from this wallet
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
accountName | string | ✓ | Name of the account to delete |