Skip to main content
The Quai HD wallet is a BIP44-compliant hierarchical deterministic wallet used for managing a set of addresses in the Quai ledger. This is the easiest way to manage the interaction of managing accounts and addresses on the Quai network, however, if your use case requires a single address Quai address, you can use the Wallet class. The Quai HD wallet supports:
  • Adding accounts to the wallet heierchy
  • Generating addresses for a specific account in any Zone
  • Signing and sending transactions for any address in the wallet
  • Signing and verifying EIP1193 typed data for any address in the wallet.
  • Serializing the wallet to JSON and deserializing it back to a wallet instance.

Example

Extends

Constructors

new QuaiHDWallet()

Create a QuaiHDWallet instance.

Parameters

Returns

QuaiHDWallet

Overrides

AbstractHDWallet<NeuteredAddressInfo>.constructor

Source

wallet/quai-hdwallet.ts:69

Methods

addAddress()

Adds an address to the wallet.

Parameters

Returns

NeuteredAddressInfo The added address info.

Overrides

AbstractHDWallet.addAddress

Source

wallet/quai-hdwallet.ts:228

connect()

Connects the wallet to a provider.

Parameters

Returns

void

Inherited from

AbstractHDWallet.connect

Source

wallet/abstract-hdwallet.ts:240

getAddressInfo()

Gets the address info for a given address.

Parameters

Returns

null | NeuteredAddressInfo The address info or null if not found.

Overrides

AbstractHDWallet.getAddressInfo

Source

wallet/quai-hdwallet.ts:350

getAddressesForAccount()

Gets the addresses for a given account.

Parameters

Returns

NeuteredAddressInfo[] The addresses for the account.

Overrides

AbstractHDWallet.getAddressesForAccount

Source

wallet/quai-hdwallet.ts:409

getAddressesForZone()

Gets the addresses for a given zone.

Parameters

Returns

NeuteredAddressInfo[] The addresses for the zone.

Overrides

AbstractHDWallet.getAddressesForZone

Source

wallet/quai-hdwallet.ts:397

getNextAddress()

Promise that resolves to the next address for the specified account and zone.

Parameters

Returns

Promise<NeuteredAddressInfo> The next neutered address information.

Overrides

AbstractHDWallet.getNextAddress

Source

wallet/quai-hdwallet.ts:273

getNextAddressSync()

Synchronously retrieves the next address for the specified account and zone.

Parameters

Returns

NeuteredAddressInfo The next neutered address information.

Overrides

AbstractHDWallet.getNextAddressSync

Source

wallet/quai-hdwallet.ts:284

getPrivateKey()

Returns the private key for a given address. This method should be used with caution as it exposes the private key to the user.

Parameters

Returns

string The private key.

Overrides

AbstractHDWallet.getPrivateKey

Source

wallet/quai-hdwallet.ts:365

sendTransaction()

Send a transaction.

Parameters

Returns

Promise<TransactionResponse> A promise that resolves to the transaction response.

Throws

If the provider is not set.

Source

wallet/quai-hdwallet.ts:103

serialize()

Serializes the QuaiHDWallet state into a format suitable for storage or transmission. This method extends the serialization from the parent class (AbstractHDWallet) and includes additional QuaiHDWallet-specific data, such as the addresses.

Returns

SerializedQuaiHDWallet An object representing the serialized state of the QuaiHDWallet, including addresses and other inherited properties from the parent wallet.

Overrides

AbstractHDWallet.serialize

Example

Source

wallet/quai-hdwallet.ts:137

signMessage()

Sign a message.

Parameters

Returns

Promise<string> A promise that resolves to the signed message.

Overrides

AbstractHDWallet.signMessage

Source

wallet/quai-hdwallet.ts:120

signTransaction()

Sign a transaction.

Parameters

Returns

Promise<string> A promise that resolves to the signed transaction.

Overrides

AbstractHDWallet.signTransaction

Source

wallet/quai-hdwallet.ts:89

signTypedData()

Signs typed data using the private key associated with the given address.

Parameters

Returns

Promise<string> A promise that resolves to the signed data in string format.

Throws

If the address does not correspond to a valid HD node or if signing fails.

Source

wallet/quai-hdwallet.ts:211

xPub()

Returns the extended public key of the root node of the BIP44 HD wallet.

Returns

string The extended public key.

Source

wallet/quai-hdwallet.ts:79

createRandom()

Creates a random HD wallet.

Type parameters

Parameters

Returns

T The created instance.

Inherited from

AbstractHDWallet.createRandom

Source

wallet/abstract-hdwallet.ts:195

deserialize()

Deserializes the given serialized HD wallet data into an instance of QuaiHDWallet.

Parameters

Returns

Promise<QuaiHDWallet> A promise that resolves to an instance of QuaiHDWallet.

Overrides

AbstractHDWallet.deserialize

Async

Throws

If validation of the serialized wallet data fails or if deserialization fails.

Static

Source

wallet/quai-hdwallet.ts:181

fromMnemonic()

Creates an HD wallet from a mnemonic.

Type parameters

Parameters

Returns

T The created instance.

Inherited from

AbstractHDWallet.fromMnemonic

Source

wallet/abstract-hdwallet.ts:180

fromPhrase()

Creates an HD wallet from a phrase.

Type parameters

Parameters

Returns

T The created instance.

Inherited from

AbstractHDWallet.fromPhrase

Source

wallet/abstract-hdwallet.ts:219