# 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="https://content.gitbook.com/content/33DLypUqgcjkBSmN0gZn/blobs/xiryGw5yjRoQyOX9mB5x/image.png" 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>
