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

Your app must have first [connected to the wallet](https://docs.xverse.app/sats-connect/connecting-to-the-wallet/connect-to-xverse-wallet) and obtained [account read permissions.](https://docs.xverse.app/sats-connect/xverse-wallet-permissions)&#x20;

No request parameters are required:

{% code fullWidth="false" %}

```typescript
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);
    }
}
```

{% endcode %}

The method returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves to return `GetAccountsResult`: an array of the user’s wallet `address` objects, defined as:

<table><thead><tr><th width="162">address field</th><th>Description</th></tr></thead><tbody><tr><td><code>address</code> </td><td>the user’s connected Stacks wallet address</td></tr><tr><td><code>publicKey</code></td><td>A hex string representing the bytes of the public key of the account. </td></tr><tr><td><code>network</code></td><td><p>string - the network where the address is being used:</p><ul><li><code>mainnet</code> for Stacks Mainnet</li><li><code>testnet</code> for Stacks Testnet</li></ul></td></tr><tr><td><code>gaiaHubUrl</code></td><td>a string representing the user's Gaia hub URL. <br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> 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 <a href="https://docs.stacks.co/stacks-in-depth/gaia">Gaia protocol reference</a>.</td></tr><tr><td><code>gaiaAppKey</code></td><td> a string representing the user's hex-encoded Gaia app key</td></tr></tbody></table>

You can use these addresses to make further Stacks requests such as [signing a message](https://docs.xverse.app/sats-connect/stacks-methods/stx_signmessage), [signing a transaction](https://docs.xverse.app/sats-connect/stacks-methods/stx_signtransaction), etc.

If your app has not yet obtained [account read permissions](https://docs.xverse.app/sats-connect/xverse-wallet-permissions), the `stx_getAccounts`  will prompt the user with a *Connection Request* 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

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xverse.app/sats-connect/stacks-methods/stx_getaccounts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
