> For the complete documentation index, see [llms.txt](https://docs.xverse.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xverse.app/sats-connect/bitcoin-methods/signmessage.md).

# signMessage

You can request your user to sign a message with their wallet's Bitcoin addresses, by invoking the `signMessage` method.

<table><thead><tr><th width="215">Request parameters</th><th>Description</th></tr></thead><tbody><tr><td><code>address</code></td><td>a string representing the address to use to sign the message</td></tr><tr><td><code>message</code></td><td>a string representing the message to be signed by the wallet</td></tr><tr><td><code>protocol</code> <br>(<span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> optional)</td><td><p>By default, signMessage will use two type of signatures depending on the Bitcoin address used for signing:</p><ul><li><a href="https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm">ECDSA</a> signatures over the <a href="https://www.secg.org/sec2-v2.pdf">secp256k1 curve</a> when signing with the Bitcoin payment (<code>p2sh</code>) address</li><li><a href="https://bips.xyz/322">BIP322</a> signatures when signing with the Bitcoin Ordinals (<code>p2tr</code>) address or a Ledger-based Bitcoin payment address (<code>p2wpkh)</code> </li></ul><p><br>You have the option to specify your preferred signature type with the  <code>protocol</code> parameter:</p><ul><li><code>ECDSA</code> to request <a href="https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm">ECDSA</a> signatures over the <a href="https://www.secg.org/sec2-v2.pdf">secp256k1 curve</a> <br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> available for payment addresses only (<code>p2sh</code> and <code>p2wpkh</code>)</li><li><code>BIP322</code>  to request <a href="https://bips.xyz/322">BIP322</a> signatures <br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> available for all payment (<code>p2sh</code> and <code>p2wpkh</code>) &#x26; ordinals addresses (<code>p2tr</code>) </li></ul></td></tr></tbody></table>

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

try {
  const response = await request("signMessage", {
    address,
    message,
  });
  if (response.status === "success") {
    // handle success response
  } else {
    if (response.error.code === RpcErrorCode.USER_REJECTION) {
       // handle user request cancelation
    } else {
       // handle request error
    }
  }
} catch (err) {
  alert('Something Went Wrong');
}
```

The user will see a Bitcoin message signing request prompt in the wallet. Xverse browser extension UI shown as example:\
![](https://content.gitbook.com/content/33DLypUqgcjkBSmN0gZn/blobs/VwDABkTTgAWjOd5LYcmi/image.png)

The `signMessage` method returns a Promise that resolves to the `SignMessageResult` object:

<table><thead><tr><th width="162">Property</th><th>Description</th></tr></thead><tbody><tr><td><code>signature</code> </td><td>a string representing the signed message. </td></tr><tr><td><code>messageHash</code></td><td>a string representing the hash of the message</td></tr><tr><td><code>address</code></td><td> a string representing the address used for signing</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.xverse.app/sats-connect/bitcoin-methods/signmessage.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
