spark_signMessage

This method is coming ๐Ÿ”œ

Use the spark_signMessage method to request a signature from the userโ€™s Spark identity key. This is typically used for authentication, verification, or dApp interactions that require proof of wallet ownership on Spark.

Parameters

Request parameters
Description

message

a string representing the message to be signed by the Spark identity key

compact

โ„น๏ธ Optional - defaults to false if true, the signature is returned in compact format instead of DER.

Example

import { request } from "sats-connect";

try {
  const response = await request("spark_signMessage", {
    message: "Log in to example.com at 2025-09-08T12:00Z",
    compact: true, // optional, defaults to false
  });

  if ("result" in response) {
    console.log("Signature:", response.result.signature);
  } else {
    console.error("Signing failed:", response.error.message);
  }
} catch (error) {
  console.error("Unexpected error:", error);
}

What spark_signMessage does

When called, this method:

  1. Prompts the user in their Xverse wallet to review the message being signed.

  2. Signs the message using their Spark identity key.

  3. Returns the signature in either DER or compact format.

The spark_signMessage method returns a Promise that resolves to the SparksignMessageResult object:

Property
Description

signature

a Uint8Array representing the ECDSA signare (DER or compact format)

Last updated