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. STACKS METHODS

stx_signMessage

Previousstx_getAccountsNextstx_signStructuredMessage

Last updated 1 month ago

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).

Request parameters
Description

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:

Property
Description

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

The stx_signMessage method returns a 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:

🔴
Promise