Sats Connect - Wallet API for Bitcoin & Stacks
  • Introduction
  • Wallet Providers
    • getInfo
    • getProviders & getProviderById
  • Connecting to the wallet
    • Connect to Xverse Wallet
    • Disconnect from Xverse Wallet
    • Connect to other wallets
      • Manage a user's default wallet
    • [Legacy âš ī¸] getAccounts
  • Wallet Methods
    • request methods
    • wallet_getAccount
    • wallet_getNetwork
    • wallet_changeNetwork
    • Xverse Custom Methods
  • Xverse Wallet Permissions
  • Xverse Wallet events
  • BITCOIN METHODS
    • 🟠getAddresses
    • 🟠signMessage
    • 🟠signPsbt
    • 🟠sendTransfer
    • 🟠signMultipleTransactions
    • 🟠getBalance
    • 🎨createInscription
    • 🎨createRepeatInscriptions
    • 🎨ord_getInscriptions
    • 🎨ord_sendInscriptions
    • 🔲runes_getBalance
    • 🔲runes_transfer
    • 🔲Mint Runes
      • runes_estimateMint
      • runes_mint
    • 🔲Etch Runes
      • runes_estimateEtch
      • runes_etch
    • 🔲runes_getOrder
    • 🔲Speed up a Rune Mint or Etch order
      • 🔲runes_estimateRbfOrder
      • 🔲runes_rbfOrder
  • STACKS METHODS
    • 🔴stx_getAccounts
    • 🔴stx_signMessage
    • 🔴stx_signStructuredMessage
    • 🔴stx_transferStx
    • 🔴stx_signTransaction
    • 🔴stx_callContract
    • 🔴stx_deployContract
  • GUIDES
    • Verify Bitcoin message signatures
    • Creating Bitcoin PSBTs
    • 📱Mobile Integration
    • Next.js support
  • RESOURCES
    • App Template
    • Demo App
    • Changelog
    • Github Issues
    • Developer forum
    • BIP322
Powered by GitBook
On this page
  1. BITCOIN METHODS

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

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

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

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

PreviousgetAddressesNextsignPsbt

Last updated 5 months ago

protocol ( optional)

signatures over the when signing with the Bitcoin payment (p2sh) address

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

ECDSA to request signatures over the available for payment addresses only (p2sh and p2wpkh)

BIP322 to request signatures available for all payment (p2sh and p2wpkh) & ordinals addresses (p2tr)

The user will see a Bitcoin message signing request prompt in the wallet. Xverse browser extension UI shown as example:

🟠
â„šī¸
ECDSA
secp256k1 curve
BIP322
â„šī¸
ECDSA
secp256k1 curve
â„šī¸
BIP322