🟠signMessage

You can request your user to sign a message with their wallet's Bitcoin addresses, by invoking the signMessage method.

Request parameters
Description

address

a string representing the address to use to sign the message

message

a string representing the message to be signed by the wallet

protocol (ℹī¸ optional)

By default, signMessage will use two type of signatures depending on the Bitcoin address used for signing:

  • ECDSA signatures over the secp256k1 curve when signing with the Bitcoin payment (p2sh) address

  • BIP322 signatures when signing with the Bitcoin Ordinals (p2tr) address or a Ledger-based Bitcoin payment address (p2wpkh)

You have the option to specify your preferred signature type with the protocol parameter:

  • ECDSA to request ECDSA signatures over the secp256k1 curve ℹī¸ available for payment addresses only (p2sh and p2wpkh)

  • BIP322 to request BIP322 signatures ℹī¸ available for all payment (p2sh and p2wpkh) & ordinals addresses (p2tr)

import {
  request,
  BitcoinNetworkType,
  RpcErrorCode,
} from "sats-connect";

try {
  const response = await request("signMessage", {
    address,
    message,
  });
  if (response.status === "success") {
    // handle success response
  } else {
    if (response.error.code === RpcErrorCode.USER_REJECTION) {
       // handle user request cancelation
    } else {
       // handle request error
    }
  }
} catch (err) {
  alert('Something Went Wrong');
}

The signMessage method returns a Promise that resolves to the SignMessageResult object:

Property
Description

signature

a string representing the signed message.

messageHash

a string representing the hash of the message

address

a string representing the address used for signing

Last updated