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_getAccounts

Previousrunes_rbfOrderNextstx_signMessage

Last updated 5 months ago

Your application can request to connect to the user’s Stacks wallet with the stx_getAccounts method, which prompts them to share their Stacks address.

Your app must have first and obtained

No request parameters are required:

import { request } from "sats-connect";

try {

  const response = await request("stx_getAccounts", {});

    if (response.status === "success") {
      alert("Success getting accounts. Check console for results.");
      console.log("Accounts:", response.result);
    } else {
      alert("Error getting accounts. Check console for details.");
      console.error(response);
    }
}

The stx_getAccounts method returns a that resolves if the user approves the connection request. The user will see a Connection Request prompt in their wallet. The prompt will display:

  • your app logo, if it is specified in your app manifest

  • the Stacks wallet addresses that your app required

Once resolved, the method returns GetAccountsResult: an array of the user’s wallet address objects, defined as:

address field
Description

address

the user’s connected Stacks wallet address

publicKey

A hex string representing the bytes of the public key of the account.

network

string - the network where the address is being used:

  • mainnet for Stacks Mainnet

  • testnet for Stacks Testnet

gaiaHubUrl

gaiaAppKey

a string representing the user's hex-encoded Gaia app key

If the user declines the request or closes the pop-up, the promise will reject (throw when awaited).

a string representing the user's Gaia hub URL. The Gaia storage system allows you to store private app data off the blockchain and still access it securely with Stacks applications. For more information about the Gaia storage system, see the .

You can use these addresses to make further Stacks requests such as , , etc.

πŸ”΄
connected to the wallet
account read permissions.
Promise
signing a message
signing a transaction
ℹ️
Gaia protocol reference