πŸ”΄stx_getAccounts

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.

No request parameters are required:

import {Wallet} from "sats-connect";

try {

  const response = await Wallet.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 Promise 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 fieldDescription

address

the user’s connected Stacks wallet address

publicKey

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

gaiaHubUrl

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 Gaia protocol reference.

gaiaAppKey

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

You can use these addresses to make further Stacks requests such as signing a message, signing a transaction, etc.

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