注意: 此页面尚未翻译成中文。以下内容为英文原版。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 encrypted JSON wallets.
Extends
BaseWallet
Constructors
new Wallet()
key
, optionally connected to provider
.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | SigningKey | The private key. |
provider ? | null | Provider | The provider to connect to. |
Returns
Wallet
Overrides
BaseWallet.constructor
Source
wallet/wallet.ts:34Properties
Property | Modifier | Type | Description | Inherited from |
---|---|---|---|---|
#address | private | string | The wallet address. | BaseWallet.#address |
#signingKey | private | SigningKey | The signing key used for signing payloads. | BaseWallet.#signingKey |
provider | readonly | null | Provider | The provider this signer is connected to. | BaseWallet.provider |
Accessors
address
Returns
string
Source
wallet/base-wallet.ts:71privateKey
Returns
string
Source
wallet/base-wallet.ts:91signingKey
Returns
SigningKey
Source
wallet/base-wallet.ts:81Methods
connect()
Parameters
Parameter | Type | Description |
---|---|---|
provider | null | Provider | The provider to connect to. |
Returns
Wallet
The connected wallet.
Overrides
BaseWallet.connect
Source
wallet/wallet.ts:49encrypt()
password
.
If progressCallback
is specified, it will receive periodic updates as the encryption process progresses.
Parameters
Parameter | Type | Description |
---|---|---|
password | string | Uint8Array | The password to encrypt the wallet with. |
progressCallback ? | ProgressCallback | An optional callback to keep the user informed. |
Returns
Promise
<string
>
The encrypted JSON wallet.
Source
wallet/wallet.ts:62encryptSync()
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.
Parameters
Parameter | Type | Description |
---|---|---|
password | string | Uint8Array | The password to encrypt the wallet with. |
Returns
string
The encrypted JSON wallet.
Source
wallet/wallet.ts:79getAddress()
Parameters
Parameter | Type | Description |
---|---|---|
_zone ? | string | The zone (optional). |
Returns
Promise
<string
>
The wallet address.
Inherited from
BaseWallet.getAddress
Source
wallet/base-wallet.ts:103signMessage()
Parameters
Parameter | Type | Description |
---|---|---|
message | string | Uint8Array | The message to sign. |
Returns
Promise
<string
>
The signed message.
Inherited from
BaseWallet.signMessage
Async
Source
wallet/base-wallet.ts:161signMessageSync()
message
signed with this wallet.
Parameters
Parameter | Type | Description |
---|---|---|
message | string | Uint8Array | The message to sign. |
Returns
string
The serialized signature.
Inherited from
BaseWallet.signMessageSync
Source
wallet/base-wallet.ts:173signTransaction()
Parameters
Parameter | Type | Description |
---|---|---|
tx | QuaiTransactionRequest | The transaction request. |
Returns
Promise
<string
>
The signed transaction.
Inherited from
BaseWallet.signTransaction
Source
wallet/base-wallet.ts:123signTypedData()
Parameters
Parameter | Type | Description |
---|---|---|
domain | TypedDataDomain | The domain of the typed data. |
types | Record <string , TypedDataField []> | The types of the typed data. |
value | Record <string , any > | The value of the typed data. |
Returns
Promise
<string
>
The signed typed data.
Inherited from
BaseWallet.signTypedData
Async
Source
wallet/base-wallet.ts:186fromEncryptedJson()
json
with password
.
If progress
is provided, it is called periodically during decryption so that any UI can be updated.
Parameters
Parameter | Type | Description |
---|---|---|
json | string | The JSON data to decrypt. |
password | string | Uint8Array | The password to decrypt the JSON data. |
progress ? | ProgressCallback | An optional callback to keep the user informed. |
Returns
Promise
<Wallet
>
The decrypted wallet.
Source
wallet/wallet.ts:111fromEncryptedJsonSync()
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.
Parameters
Parameter | Type | Description |
---|---|---|
json | string | The JSON data to decrypt. |
password | string | Uint8Array | The password to decrypt the JSON data. |
Returns
QuaiHDWallet
| Wallet
The decrypted wallet.