> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Wallet

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](https://en.bitcoin.it/wiki/BIP_0039) mnemonics and encrypted JSON wallets.

## Extends

* `BaseWallet`

## Constructors

### new Wallet()

```ts theme={null}
new Wallet(key, provider?): Wallet
```

Create a new wallet for the private `key`, optionally connected to `provider`.

#### Parameters

| Parameter   | Type                                                        | Description                 |
| :---------- | :---------------------------------------------------------- | :-------------------------- |
| `key`       | `string` \| [`SigningKey`](/sdk/content/classes/SigningKey) | The private key.            |
| `provider`? | `null` \| [`Provider`](/sdk/content/interfaces/Provider)    | The provider to connect to. |

#### Returns

[`Wallet`](/sdk/content/classes/Wallet)

#### Overrides

`BaseWallet.constructor`

#### Source

[wallet/wallet.ts:34](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/wallet.ts#L34)

## Properties

| Property      | Modifier   | Type                                                     | Description                                | Inherited from           |
| :------------ | :--------- | :------------------------------------------------------- | :----------------------------------------- | :----------------------- |
| `#address`    | `private`  | `string`                                                 | The wallet address.                        | `BaseWallet.#address`    |
| `#signingKey` | `private`  | [`SigningKey`](/sdk/content/classes/SigningKey)          | The signing key used for signing payloads. | `BaseWallet.#signingKey` |
| `provider`    | `readonly` | `null` \| [`Provider`](/sdk/content/interfaces/Provider) | The provider this signer is connected to.  | `BaseWallet.provider`    |

## Accessors

### address

```ts theme={null}
get address(): string
```

The address of this wallet.

#### Returns

`string`

#### Source

[wallet/base-wallet.ts:71](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/base-wallet.ts#L71)

***

### privateKey

```ts theme={null}
get privateKey(): string
```

The private key for this wallet.

#### Returns

`string`

#### Source

[wallet/base-wallet.ts:91](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/base-wallet.ts#L91)

***

### signingKey

```ts theme={null}
get signingKey(): SigningKey
```

The [**SigningKey**](/sdk/content/classes/SigningKey) used for signing payloads.

#### Returns

[`SigningKey`](/sdk/content/classes/SigningKey)

#### Source

[wallet/base-wallet.ts:81](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/base-wallet.ts#L81)

## Methods

### connect()

```ts theme={null}
connect(provider): Wallet
```

Connects the wallet to a provider.

#### Parameters

| Parameter  | Type                                                     | Description                 |
| :--------- | :------------------------------------------------------- | :-------------------------- |
| `provider` | `null` \| [`Provider`](/sdk/content/interfaces/Provider) | The provider to connect to. |

#### Returns

[`Wallet`](/sdk/content/classes/Wallet)

The connected wallet.

#### Overrides

`BaseWallet.connect`

#### Source

[wallet/wallet.ts:49](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/wallet.ts#L49)

***

### encrypt()

```ts theme={null}
encrypt(password, progressCallback?): Promise<string>
```

Resolves to a [JSON Keystore Wallet](json-wallets) encrypted with `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`](/sdk/content/type-aliases/ProgressCallback) | An optional callback to keep the user informed. |

#### Returns

`Promise`\<`string`>

The encrypted JSON wallet.

#### Source

[wallet/wallet.ts:62](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/wallet.ts#L62)

***

### encryptSync()

```ts theme={null}
encryptSync(password): string
```

Returns a [JSON Keystore Wallet](json-wallets) encrypted with `password`.

It is preferred to use the [async version](encrypt) instead, which allows a
[**ProgressCallback**](/sdk/content/type-aliases/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:79](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/wallet.ts#L79)

***

### getAddress()

```ts theme={null}
getAddress(_zone?): Promise<string>
```

Returns the address of this wallet.

#### Parameters

| Parameter | Type     | Description          |
| :-------- | :------- | :------------------- |
| `_zone`?  | `string` | The zone (optional). |

#### Returns

`Promise`\<`string`>

The wallet address.

#### Inherited from

`BaseWallet.getAddress`

#### Source

[wallet/base-wallet.ts:103](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/base-wallet.ts#L103)

***

### signMessage()

```ts theme={null}
signMessage(message): Promise<string>
```

Signs a message.

#### 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:161](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/base-wallet.ts#L161)

***

### signMessageSync()

```ts theme={null}
signMessageSync(message): string
```

Returns the signature for `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:173](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/base-wallet.ts#L173)

***

### signTransaction()

```ts theme={null}
signTransaction(tx): Promise<string>
```

Signs a transaction.

#### Parameters

| Parameter | Type                     | Description              |
| :-------- | :----------------------- | :----------------------- |
| `tx`      | `QuaiTransactionRequest` | The transaction request. |

#### Returns

`Promise`\<`string`>

The signed transaction.

#### Inherited from

`BaseWallet.signTransaction`

#### Source

[wallet/base-wallet.ts:123](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/base-wallet.ts#L123)

***

### signTypedData()

```ts theme={null}
signTypedData(
   domain, 
   types, 
value): Promise<string>
```

Signs typed data.

#### Parameters

| Parameter | Type                                                                               | Description                   |
| :-------- | :--------------------------------------------------------------------------------- | :---------------------------- |
| `domain`  | [`TypedDataDomain`](/sdk/content/interfaces/TypedDataDomain)                       | The domain of the typed data. |
| `types`   | `Record`\<`string`, [`TypedDataField`](/sdk/content/interfaces/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:186](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/base-wallet.ts#L186)

***

### fromEncryptedJson()

```ts theme={null}
static fromEncryptedJson(
   json, 
   password, 
progress?): Promise<Wallet>
```

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.

#### Parameters

| Parameter   | Type                                                             | Description                                     |
| :---------- | :--------------------------------------------------------------- | :---------------------------------------------- |
| `json`      | `string`                                                         | The JSON data to decrypt.                       |
| `password`  | `string` \| `Uint8Array`                                         | The password to decrypt the JSON data.          |
| `progress`? | [`ProgressCallback`](/sdk/content/type-aliases/ProgressCallback) | An optional callback to keep the user informed. |

#### Returns

`Promise`\<[`Wallet`](/sdk/content/classes/Wallet)>

The decrypted wallet.

#### Source

[wallet/wallet.ts:111](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/wallet.ts#L111)

***

### fromEncryptedJsonSync()

```ts theme={null}
static fromEncryptedJsonSync(json, password): QuaiHDWallet | Wallet
```

Creates a **Wallet** by decrypting the `json` with `password`.

The [**fromEncryptedJson**](/sdk/content/classes/Wallet#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`](/sdk/content/classes/QuaiHDWallet) | [`Wallet`](/sdk/content/classes/Wallet)

The decrypted wallet.

#### Source

[wallet/wallet.ts:134](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/wallet/wallet.ts#L134)
