# wallet\_getAccount

## Fetch the user's Xverse wallet account

Your app can fetch the user's active Xverse account with the `wallet_getAccount` method.&#x20;

The 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;

* You can optionally specify which wallet addresses you require: Bitcoin ordinals address, Bitcoin payment address, Spark, Starknet or Stacks address, using the optional `addresses` request parameter.

<table><thead><tr><th width="205">request parameters</th><th>Description</th></tr></thead><tbody><tr><td><code>addresses</code><br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> Optional</td><td><p>an array of strings used to specify which address(es) to request from the user's Xverse wallet account:</p><ul><li><code>'ordinals'</code> is preferably used to manage the user’s ordinals</li><li><code>'payment'</code> is preferably used to manage the user’s bitcoin</li><li><code>'stacks'</code> is used to interact with the stacks ecosystem</li><li><code>'spark'</code> is used to interact with the Spark ecosystem</li><li><code>'starknet'</code> is used to interact with the Starknet ecosystem</li></ul><p></p><p>Example: <code>['ordinals', 'payment', 'stacks']</code> <br>Will default to <code>['ordinals', 'payment', 'stacks', 'spark','starknet']</code> if not specified.</p></td></tr></tbody></table>

{% code fullWidth="false" %}

```typescript
import Wallet from 'sats-connect';

const response = await Wallet.request('wallet_getAccount', null);

if (response.status === 'error') {
  console.error(response.error);
  return;
}

console.log(response.result);
```

{% endcode %}

The `wallet_getAccount` method attempts to fetch the user's active Xverse account directly. You can use it to  grant your connected user a smooth experience, without connection popups.&#x20;

## :white\_check\_mark: getAccount Result - account is connected

If your user has already [connected their active Xverse account to your app](https://docs.xverse.app/sats-connect/connecting-to-the-wallet/connect-to-xverse-wallet), and granted your app the necessary account read [permissions](https://docs.xverse.app/sats-connect/xverse-wallet-permissions) -> the method successfully returns `getAccountResult`:&#x20;

* The account id&#x20;
* The wallet type (software or hardware)
* an array of the user’s wallet address objects, defined as:&#x20;

```typescript
type address = {
    address: string;
    publicKey: string;
    purpose: "payment" | "ordinals" | "stacks" | "spark" | "starknet";
    addressType: "p2tr" | "p2wpkh" | "p2sh" | "stacks" | "spark" | "starknet";
}
```

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

Currently, you can retrieve two types of Bitcoin addresses, the user's Bitcoin payment address and the Ordinals address which is a taproot address.

An example response:

{% code title="wallet\_getAccount response" %}

```typescript
{
  walletType: "software",
  id: "dj0f7g5xtdakgecvf45dvssu66",
  addressses: [
    {
      address: "tb1pzwa68q3udj0f7g5xtdakgecvf45dvssu66ry7y3at22w7vus20vq3sgw62",
      publicKey: "b9907521ddb85e0e6a37622b7c685efbdc8ae53a334928adbd12cf204ad4e717",
      purpose: "ordinals",
      addressType: "p2tr",
      network: 'mainnet'
    },
    {
      address: "2NBfRKCUpafbatj5gV9T82uau3igdSf9BXJ",
      publicKey: "02818b7ff740a40f311d002123087053d5d9e0e1546674aedb10e15a5b57fd3985",
      purpose: "payment",
      addressType: "p2sh",
      network: 'mainnet'
    }
  ]
}
```

{% endcode %}

Where:

<table><thead><tr><th width="162">address field</th><th>Description</th></tr></thead><tbody><tr><td><code>walletType</code></td><td><p>string - the type of wallet used for the account</p><ul><li><code>ledger</code> if the user's account is using a Ledger device</li><li><code>software</code> otherwise</li></ul></td></tr><tr><td><code>address</code> </td><td>string - the user’s connected wallet address</td></tr><tr><td><code>publicKey</code></td><td>A hex string representing the bytes of the public key of the account. You can use this to construct partially signed Bitcoin transactions (PSBT).</td></tr><tr><td><code>purpose</code></td><td><p>string - The purpose of the address:</p><ul><li><code>ordinals</code> is preferably used to manage the user’s ordinals</li><li><code>payment</code> is preferably used to manage the user’s bitcoin</li><li><code>stacks</code> is used to interact with the stacks ecosystem</li></ul></td></tr><tr><td><code>addressType</code></td><td><p>string - the address’s format:</p><ul><li><code>P2TR</code> for ordinals</li><li><code>P2SH</code> for payment</li><li><code>P2WPKH</code> for payment using Ledger</li><li><code>stacks</code> for Stacks</li><li><code>spark</code> for Spark</li><li><code>starknet</code> for Starknet</li></ul></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 Bitcoin Mainnet | Spark Mainnet | Stacks Mainnet | Starknet Mainnet</li><li><code>Regtest</code> for Bitcoin Regtest | Spark Regtest | Stacks Testnet | Starknet Sepolia</li><li><code>Testnet</code> for Bitcoin Testnet | Spark Regtest | Stacks Testnet | Starknet Sepolia</li><li><code>Signet</code> for Bitcoin Signet | Spark Regtest | Stacks Testnet | Starknet Sepolia</li></ul></td></tr></tbody></table>

## :x: getAccount Result - account is not connected

If your user has not [connected their active Xverse account to your app](https://docs.xverse.app/sats-connect/connecting-to-the-wallet/connect-to-xverse-wallet) yet, and your app does not the necessary account read [permissions](https://docs.xverse.app/sats-connect/xverse-wallet-permissions) -> the method will throw with an access denied error\
\
You can use the [`connect`](https://docs.xverse.app/sats-connect/connecting-to-the-wallet/connect-to-xverse-wallet) or [`wallet_requestPermissions`](https://docs.xverse.app/sats-connect/xverse-wallet-permissions) methods to request a connection to your user's active Xverse account.
