# @compass/wallet

This package provides an easy to use wallet class for signing messages and sending transactions with a connected wallet. The wallet class requires an address to initialize and provides methods for signing and transactions.

### Usage

```javascript
import Wallet from "@compass/wallet";
```

### API Reference

#### `class Wallet`

Main class of the module, representing a wallet instance.

**`constructor(address: string)`**

Create a new wallet instance.

* `address` (required, string): The address of the wallet.

Returns a new wallet instance.

**`wallet.signMessage(message: string)`**

Sign a message with the wallet.

* `message` (required, string): Message to sign.

Returns a Promise that resolves with the signed message.

**`wallet.signTypedData(domain: any, types: any, value: any)`**

Sign typed data with the wallet. (v4)

* `domain` (required, any): The domain of the typed data.
* `types` (required, any): The types of the typed data.
* `value` (required, any): The value of the typed data.

Returns a Promise that resolves with the signed typed data.

**`wallet.sendTransaction(transaction: any)`**

Send a transaction with the wallet.

* `transaction` (required, any): Transaction to send.

Returns a Promise that resolves with the transaction receipt.

### Examples

To create a new wallet instance:

```javascript
import Wallet from "@compass/wallet";

export default function() {
    const address = '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B';
    const wallet = new Wallet(address);
    return { wallet };
}
```

To sign a message with the wallet:

```javascript
import Wallet from "@compass/wallet";

export default async function() {
    const address = '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B';
    const wallet = new Wallet(address);
    const message = 'Hello, World!';
    const signedMessage = await wallet.signMessage(message);
    return { signedMessage };
}
```

To sign typed data with the wallet:

```javascript
import Wallet from "@compass/wallet";

export default async function() {
    const address = '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B';
    const wallet = new Wallet(address);
    const domain = {/* ... */};
    const types = {/* ... */};
    const value = {/* ... */};
    const signedData = await wallet.signTypedData(domain, types, value);
    return { signedData };
}
```

To send a transaction with the wallet:

```javascript
import Wallet from "@compass/wallet";

export default async function() {
    const address = '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B';
    const wallet = new Wallet(address);
    const transaction = {/* ... */};
    const transactionReceipt = await wallet.sendTransaction(transaction);
    return { transactionReceipt };
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.compass.art/automations/custom-actions/compass-wallet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
