When interacting with Ethereum, it is necessary to use a private key authenticate actions by signing a payload.
Wallets are the simplest way to expose the concept of an Externally Owner Account (EOA) as it wraps a private key and supports high-level methods to sign common types of interaction and send transactions.
The class most developers will want to use is Wallet, which can load a private key directly or from any common wallet format.
The HDNodeWallet can be used when it is necessary to access low-level details of how an HD wallets are derived, exported or imported.
The BaseWallet is a stream-lined implementation of a Signer that operates with a private key.
It is preferred to use the Wallet class, as it offers additional functionality and simplifies loading a variety of JSON formats, Mnemonic Phrases, etc.
This class may be of use for those attempting to implement a minimal Signer.
The wallet address.
The private key for this wallet.
The SigningKey used for signing payloads.
Creates a new BaseWallet for privateKey, optionally connected to provider.
If provider is not specified, only offline methods can be used.
Returns the signature for message signed with this wallet.
The default derivation path for Ethereum HD Nodes. (i.e. "m/44'/60'/0'/0/0")
Returns the BIP-32 path for the acount at index.
This is the pattern used by wallets like Ledger.
There is also an alternate pattern used by some software.
Returns the path using an alternative pattern for deriving accounts, at index.
This derivation path uses the index component rather than the account component to derive sequential accounts.
This is the pattern used by wallets like MetaMask.
A HDNodeVoidWallet cannot sign, but provides access to the children nodes of a BIP-32 HD wallet addresses.
The can be created by using an extended xpub key to fromExtendedKey or by nuetering a HDNodeWallet.
The chaincode, which is effectively a public key used to derive children.
The depth of this wallet, which is the number of components in its path.
The extended key.
This key will begin with the prefix xpub and can be used to reconstruct this neutered key to derive its children addresses.
The fingerprint.
A fingerprint allows quick qay to detect parent and child nodes, but developers should be prepared to deal with collisions as it is only 4 bytes.
The child index of this wallet. Values over 2 ** 31 indicate the node is hardened.
The parent node fingerprint.
The derivation path of this wallet.
Since extended keys do not provider full path details, this may be null, if instantiated from a source that does not enocde it.
The compressed public key.
Return the child for index.
Return the signer for path from this node.
Returns true if this wallet has a path, providing a Type Guard that the path is non-null.
The chaincode, which is effectively a public key used to derive children.
The depth of this wallet, which is the number of components in its path.
The extended key.
This key will begin with the prefix xpriv and can be used to reconstruct this HD Node to derive its children.
The fingerprint.
A fingerprint allows quick qay to detect parent and child nodes, but developers should be prepared to deal with collisions as it is only 4 bytes.
The child index of this wallet. Values over 2 ** 31 indicate the node is hardened.
The mnemonic used to create this HD Node, if available.
Sources such as extended keys do not encode the mnemonic, in which case this will be null.
The parent fingerprint.
The derivation path of this wallet.
Since extended keys do not provider full path details, this may be null, if instantiated from a source that does not enocde it.
The compressed public key.
Creates an HD Node from a seed.
Creates an HD Node from a mnemonic phrase.
Create am HD Node from mnemonic.
Creates a new random HDNode.
Creates a new HD Node from extendedKey.
If the extendedKey will either have a prefix or xpub or xpriv, returning a neutered HD Node (HDNodeVoidWallet) or full HD Node ([[HDNodeWallet) respectively.
Return the child for index.
Return the HDNode for path from this node.
Resolves to a JSON Keystore Wallet encrypted with password.
If progressCallback is specified, it will receive periodic updates as the encryption process progreses.
Returns a JSON Keystore Wallet encryped with password.
It is preferred to use the async version instead, which allows a ProgressCallback to keep the user informed.
This method will block the event loop (freezing all UI) until it is complete, which may be a non-trivial duration.
Returns true if this wallet has a path, providing a Type Guard that the path is non-null.
Returns a neutered HD Node, which removes the private details of an HD Node.
A neutered node has no private key, but can be used to derive child addresses and other public data about the HD Node.
The JSON Wallet formats allow a simple way to store the private keys needed in Ethereum along with related information and allows for extensible forms of encryption.
These utilities facilitate decrypting and encrypting the most common JSON Wallet formats.
The data stored within a JSON Crowdsale wallet is fairly minimal.
The parameters to use when encrypting a JSON Keystore Wallet.
The contents of a JSON Keystore Wallet.
Before Ethereum launched, it was necessary to create a wallet format for backers to use, which would be used to receive ether as a reward for contributing to the project.
The Crowdsale Wallet format is now obsolete, but it is still useful to support and the additional code is fairly trivial as all the primitives required are used through core portions of the library.
Resolves to the decrypted JSON Keystore Wallet json using the password.
If provided, progress will be called periodically during the decrpytion to provide feedback, and if the function returns false will halt decryption.
The progressCallback will always receive 0 before decryption begins and 1 when complete.
Returns the account details for the JSON Keystore Wallet json using password.
It is preferred to use the async version instead, which allows a ProgressCallback to keep the user informed as to the decryption status.
This method will block the event loop (freezing all UI) until decryption is complete, which can take quite some time, depending on the wallet paramters and platform.
Resolved to the JSON Keystore Wallet for account encrypted with password.
The options can be used to tune the password-based key derivation function parameters, explicitly set the random values used and provide a ProgressCallback to receive periodic updates on the completion status..
Return the JSON Keystore Wallet for account encrypted with password.
The options can be used to tune the password-based key derivation function parameters, explicitly set the random values used. Any provided ProgressCallback is ignord.
Returns true if json is a valid JSON Crowdsale wallet.
Returns true if json is a valid JSON Keystore Wallet.
A Mnemonic wraps all properties required to compute link-bip39 seeds and convert between phrases and entropy.
The underlying entropy which the mnemonic encodes.
The password used for this mnemonic. If no password is used this is the empty string (i.e. "") as per the specification.
The mnemonic phrase of 12, 15, 18, 21 or 24 words.
Use the wordlist split method to get the individual words.
Create a new Mnemonic from the entropy.
The default password is the empty string and the default wordlist is the English wordlists.
Creates a new Mnemonic for the phrase.
The default password is the empty string and the default wordlist is the English wordlists.
Returns the seed for the mnemonic.
Returns the phrase for mnemonic.
Returns true if phrase is a valid link-bip39 phrase.
This checks all the provided words belong to the wordlist, that the length is valid and the checksum is correct.
A Wallet manages a single private key which is used to sign transactions, messages and other common payloads.
This class is generally the main entry point for developers that wish to use a private key directly, as it can create instances from a large variety of common sources, including raw private key, BIP-39 mnemonics and encrypte JSON wallets.
Create a new wallet for the privateKey, optionally connected to provider.
Creates a HDNodeWallet for phrase.
Creates a new random HDNodeWallet using the avavilable cryptographic random source.
If there is no crytographic random source, this will throw.
Creates a Wallet by decrypting the json with password.
The fromEncryptedJson method is preferred, as this method will lock up and freeze the UI during decryption, which may take some time.
Creates (asynchronously) a Wallet by decrypting the json with password.
If progress is provided, it is called periodically during decryption so that any UI can be updated.
Resolves to a JSON Keystore Wallet encrypted with password.
If progressCallback is specified, it will receive periodic updates as the encryption process progreses.
Returns a JSON Keystore Wallet encryped with password.
It is preferred to use the async version instead, which allows a ProgressCallback to keep the user informed.
This method will block the event loop (freezing all UI) until it is complete, which may be a non-trivial duration.