Skip to main content

ElvWallet

Constructor

new ElvWallet()

Create a new ElvWallet connected to the given provider

NOTE: It is recommended to initialize wallets from the ElvClient, not using this constructor

AddAccount

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

NameTypeRequiredDescription
accountNamestring

Name of account to save in wallet. Account will be saved in the wallet if provided.

privateKeystring

Private key to use

AddAccountFromEncryptedPK

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

NameTypeRequiredDescription
accountNamestring

Name of account to save in wallet. Account will be saved in the wallet if provided.

encryptedPrivateKeystring

Encrypted private key to decrypt

AddAccountFromMnemonic

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

NameTypeRequiredDescription
accountNamestring

Name of account to save in wallet. Account will be saved in the wallet if provided.

mnemonicstring

Mnemonic from which to generate a private key

GenerateEncryptedPrivateKey

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

NameTypeRequiredDescription
accountNamestring

Saved account to encrypt the private key of

signerstring

Signer to encrypt the private key of

passwordstring

Password to encrypt the private key with

GenerateMnemonic

GenerateMnemonic() → string

Generate a mnemonic that can be used to initialize a private key

Returns: Space-separated list of random words

GetAccount

GetAccount({ accountName }) → Signer | undefined

Get the signer of a previously saved account by name

Returns: Signer of the saved account, if it exists

Parameters

NameTypeRequiredDescription
accountNamestring

Name of the account

GetAccountBalance

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

NameTypeRequiredDescription
accountNamestring

Saved account to query the account balance of

signerSigner

Signer to query the account balance of

RemoveAccount

RemoveAccount({ accountName })

Remove a previously saved account from this wallet

Parameters

NameTypeRequiredDescription
accountNamestring

Name of the account to delete