# signMultipleMessages

{% hint style="info" %}
This is an Xverse custom method. It can only be invoked for users using the [Xverse wallet](https://www.xverse.app/).
{% endhint %}

You can request your user to sign **multiple messages** with their wallet's Bitcoin addresses, by invoking the `signMultipleMessages` method.

This enables your app to prompt users to sign **batches of messages in a single step**, instead of requiring multiple individual [`signMessage`](/sats-connect/bitcoin-methods/signmessage.md) calls and multiple wallet popups.

***

### Request parameters

`signMultipleMessages` expects the request payload to be an **array of message objects matching the schema below:**

* `address` *(required)*: a string representing the address to use to sign the message
* `message` *(required)*: a string representing the message to be signed by the wallet
* `protocol` *(optional)*: the signature protocol to use for this message (`ECDSA` or `BIP322`)

#### `protocol` *(optional)*

By default, `signMultipleMessages` will use two type of signatures depending on the Bitcoin address used for signing:

* [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm) signatures over the [secp256k1 curve](https://www.secg.org/sec2-v2.pdf) when signing with the Bitcoin payment (`p2sh`) address
* [BIP322](https://bips.xyz/322) signatures when signing with the Bitcoin Ordinals (`p2tr`) address or a Ledger-based Bitcoin payment address (`p2wpkh`)

You have the option to specify your preferred signature type with the `protocol` parameter:

* `ECDSA` to request [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm) signatures over the [secp256k1 curve](https://www.secg.org/sec2-v2.pdf)\
  \&#xNAN;*Available for payment addresses only (`p2sh` and `p2wpkh`)*
* `BIP322` to request [BIP322](https://bips.xyz/322) signatures\
  \&#xNAN;*Available for all payment (`p2sh` and `p2wpkh`) & ordinals addresses (`p2tr`)*

***

### Usage example

```typescript
import { request, RpcErrorCode } from "sats-connect";

try {
  const response = await request("signMultipleMessages", [
    {
      address,
      message: "Message #1 to sign",
    },
    {
      address,
      message: "Message #2 to sign",
      protocol: "ECDSA",
    },
    {
      address,
      message: "Message #3 to sign",
      protocol: "BIP322",
    },
  ]);

  if (response.status === "success") {
    // handle success response
    // response.result
  } else {
    if (response.error.code === RpcErrorCode.USER_REJECTION) {
      // handle user request cancelation
    } else {
      // handle request error
    }
  }
} catch (err) {
  alert("Something Went Wrong");
}

```

***

### Wallet prompt

The user will see a **single message signing request** prompt in the wallet, guiding them through the batch of messages to review and sign:

* *Messages 1/N* stepper
* *Summary screen with Cancel / Sign all*
* Option to review each message individually using **← / →**

<figure><img src="/files/1ZTY0LNfQxX1gx2yVqEK" alt=""><figcaption></figcaption></figure>

***

### Response format

The `signMultipleMessages` method returns a Promise that resolves to an array of `SignMessageResult` objects.

* The array is returned **in the same order** as the request payload.
* Each item corresponds to the signed result for the message at the same index.

Each item in the response array contains:

* `signature`: a string representing the signed message
* `messageHash`: a string representing the hash of the message


---

# 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.xverse.app/sats-connect/bitcoin-methods/signmultiplemessages.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.
