# stx\_signStructuredMessage

You can request your user to sign a message with structured data, using their wallet's Stacks address, by invoking the `stx_signStructuredMessage` method.

The structured data implementation makes the message easier to read and allows you facilitates the interaction with ClarityValue in your application. It follows the [SIP-018](https://github.com/MarvinJanssen/sips/blob/feat/signed-structured-data/sips/sip-018/sip-018-signed-structured-data.md) Signed Structured Data specification, a standard way to represent information in human-readable format in applications and smart contracts in order to produce signatures that are straightforward and inexpensive to verify. For developers familiar with Ethereum, this design is similar to [EIP-712](https://eips.ethereum.org/EIPS/eip-712).

<table><thead><tr><th width="270">Request parameters</th><th>Description</th></tr></thead><tbody><tr><td><code>message</code></td><td>a string representing the message, as a <a href="https://github.com/hirosystems/stacks.js/blob/fe831cf28d71de9410c81cfabe256fd511e9aa4d/packages/transactions/src/clarity/clarityValue.ts">ClarityValue</a> serialized in hexadecimal format.<br></td></tr><tr><td><code>domain</code></td><td>a string representing the domain, as a <a href="https://github.com/hirosystems/stacks.js/blob/fe831cf28d71de9410c81cfabe256fd511e9aa4d/packages/transactions/src/clarity/clarityValue.ts">ClarityValue</a> serialized in hexadecimal format.</td></tr></tbody></table>

To convert Clarity values to their hex representation, you can use the { cvToHex, stringAsciiCV, tupleCV, uintCV } helpers from `@stacks/transactions` package.

```typescript
   import { cvToHex, stringAsciiCV, tupleCV, uintCV } from "@stacks/transactions";
   import { request } from "sats-connect";
   
   const response = await request("stx_signStructuredMessage", {
      message: cvToHex(tupleCV({ hello: stringAsciiCV("world") })).slice(2), // remove 0x,
      domain: cvToHex(
        tupleCV({
          name: stringAsciiCV("sats-connect-example"),
          version: stringAsciiCV("1.2.3"),
          "chain-id": uintCV(chainIds[network]),
        })
      ).slice(2),
    });
    if (response.status === "success") {
      alert("Success! Check the console for the response.");
      console.log(response.result);
    } else {
      console.error(
        "Something went wrong. Check the console for the response."
      );
      console.error(response);
    }
```

The user will see a Stacks structured message signing request prompt in the wallet.&#x20;

The `stx_signStructuredMessage` 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 `SignStxStructuredMessageResult` 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>
