# 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>
