# stx\_signMessage

You can request your user to sign a message with arbitrary (unstructured) data, using their wallet's Stacks address, by invoking the `stx_signMessage` method.

This can be used to authenticate the ownership of an address or to signal a decision (e.g. agree to Terms of Services).&#x20;

<table><thead><tr><th width="270">Request parameters</th><th>Description</th></tr></thead><tbody><tr><td><code>message</code></td><td>a utf-8 string representing the message to be signed by the wallet</td></tr><tr><td><code>publicKey</code></td><td>a string representing the public key of the address used for signing the message</td></tr></tbody></table>

```typescript
   import { request } from "sats-connect";
   
   const message = "Hello World 123";
   const publickey = "publickey"
   const response = await request('stx_signMessage', {
        message,
        publicKey,
    })
    if (response.status === "success") {
      console.log(response);
      alert(response.result.signature);
    }
```

The user will see a Stacks message signing request prompt in the wallet. Xverse browser extension UI shown as example:

<figure><img src="/files/PI7Gj9A2U2wSq0Ils9AF" alt=""><figcaption></figcaption></figure>

The `stx_signMessage` method returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves if the user approves the request. The message is then hashed using **sha256** before being signed with **secp256k1,** and the method returns the `SignStxMessageResult` 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>publicKey</code></td><td> a string representing the public key of the address used for signing, as a hex-encoded string</td></tr></tbody></table>


---

# 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/stacks-methods/stx_signmessage.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.
