APIs

Developer Docs

stx_signStructuredMessage API method

May 22, 2025

Disclaimer: Leather does not evaluate the content or validity of signed messages. Developers are responsible for defining and verifying structured message formats and their implications.

Request the signature of a structured message using the Stacks address of an account.

Method name

stx_signStructuredMessage

Parameters

  • message (string or object, required): The structured message to sign, usually a Clarity value or a hex-encoded string

  • domain (string or object, required): Domain tuple following SIP-018 that defines the signing context

Example request

try {
  // Request signature
  const response = await window.LeatherProvider.request("stx_signStructuredMessage", {
    message: "3e5f6a7b9d8c1f2e4a6b",
    domain: "2c26b46b68ffc68ff99b453c1d3041344b947b77"
  });

  console.log("Response:", response);
} catch (error) {
  console.error("Error signing structured message:", error);
}

Example response

{
  "jsonrpc": "2.0",
  "id": "a1b2c3d4-e5f6-7890-1234-56789abcdef0",
  "result": {
    "signature": "0x8d3340a7b071ba29fa210cd7e079edd44e004a8611132fcfa475244b00dcf7",
    "publicKey": "0x04bfcab890d2a5b3c1df8e47a9c2f7e5a1..."
  }
}

Notes

This method supports signing messages that follow the SIP-018 specification. It allows for greater context and security when working with structured, domain-aware message flows on the Stacks blockchain.