🔴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).
message
a utf-8 string representing the message to be signed by the wallet
publicKey
a string representing the public key of the address used for signing the message
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:

The stx_signMessage
method returns a 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:
signature
a string representing the signed message
publicKey
a string representing the public key of the address used for signing, as a hex-encoded string
Last updated