# getTokenLargestAccounts

The `getTokenLargestAccounts` RPC method in **CoinVera** returns the top 20 largest SPL token accounts for a given token mint. It’s primarily used to analyze **token distribution**, identify **major holders**, and power **top-holder dashboards**.

***

#### ✅ Common Use Cases

* **Token Distribution Analysis**\
  Understand how a token’s supply is distributed across wallets.
* **Identifying Whales**\
  Spot addresses holding large portions of a token supply.
* **Market Research & Risk Assessment**\
  Measure decentralization or the potential influence of top holders.
* **Explorer & Dashboard Integration**\
  Display the top token holders in user interfaces.

***

#### 🧾 Request Parameters

```ts
[
  mintAddress: string,         // Required – base-58 address of the SPL token mint
  options?: {
    commitment?: string        // Optional – "processed", "confirmed", or "finalized"
  }
]
```

* **mintAddress**: The SPL token mint for which to retrieve largest token accounts.
* **commitment**: Optional commitment level to specify the network state snapshot.

***

#### 📦 Response Structure

The result is an array of up to 20 token account objects:

```json
{
  "context": {
    "slot": 221446650
  },
  "value": [
    {
      "address": "AccountPubkeyHere",
      "amount": "500000000000",
      "decimals": 6,
      "uiAmount": 500000.0,
      "uiAmountString": "500000"
    },
    ...
  ]
}
```

Each entry includes:

* **address**: Base-58 public key of the token account.
* **amount**: Raw token balance (as a string).
* **decimals**: Token mint’s decimal precision.
* **uiAmount**: Balance as a float (optional, may be deprecated).
* **uiAmountString**: Balance as a string (preferred for display).

***

#### 🧪 Example

**Fetch Top 20 Largest Accounts for a Token**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTokenLargestAccounts",
  "params": [
    "So11111111111111111111111111111111111111112"
  ]
}
```

***

**Code Examples**

{% tabs %}
{% tab title="Nodejs" %}

```javascript
const fetch = require('node-fetch');

async function getTokenLargestAccounts(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getTokenLargestAccounts',
        "params": [
            "f68ejXhHX8M71pdnutQf8BMthpT4jJuhT7kHkdZpump",
            { "commitment": "confirmed" }
          ]
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

getTokenLargestAccounts(RPC_URL);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def get_token_largest_accounts(rpc_url):
    try:
        response = requests.post(
            rpc_url,
            headers={
                'Content-Type': 'application/json',
            },
            json={
                'jsonrpc': '2.0',
                'id': 1,
                'method': 'getTokenLargestAccounts',
                'params': [
                    'f68ejXhHX8M71pdnutQf8BMthpT4jJuhT7kHkdZpump',
                    {'commitment': 'confirmed'}
                ]
            }
        )
        
        data = response.json()
        
        # Print the exact full response
        print('Full RPC Response:')
        print(json.dumps(data, indent=2))
        
        return data
        
    except Exception as error:
        print(f'Error getting health: {error}')
        return None

# Example usage
RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key'
get_token_largest_accounts(RPC_URL)
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "context": {
      "slot": 355408555,
      "apiVersion": "2.2.7"
    },
    "value": [
      {
        "address": "DdDiTstikLPchipWjSQ9ZgJdE2wq99W2qjdGcJtSqJXc",
        "uiAmount": 999822991.855856,
        "decimals": 6,
        "amount": "999822991855856",
        "uiAmountString": "999822991.855856"
      },
      {
        "address": "AUSZfegoc2ZhkcMpU9PMcWpg7jLid1Vgp2yfxeEhXs23",
        "uiAmount": 177007.043244,
        "decimals": 6,
        "amount": "177007043244",
        "uiAmountString": "177007.043244"
      },
      {
        "address": "Fo8hU9VAMgQEXjJ3JxfJyrTh4PXkpqMW5eXxv3vPYZ2S",
        "uiAmount": 0.304141,
        "decimals": 6,
        "amount": "304141",
        "uiAmountString": "0.304141"
      },
      {
        "address": "HeTAA5GzNpa8Z1UFpk9sqZurHPJ6gpZuPCfoJHfcAfMG",
        "uiAmount": 0,
        "decimals": 6,
        "amount": "0",
        "uiAmountString": "0"
      },
      {
        "address": "B8TeUywdwHNGb6p9voiWcJSMYQ2eQB7ZszzLqhoNksbK",
        "uiAmount": 0,
        "decimals": 6,
        "amount": "0",
        "uiAmountString": "0"
      },
      {
        "address": "9XBsFrMwjMnXJE1sKM1waRtuULApmazNWFfZfPgWm9Qz",
        "uiAmount": 0,
        "decimals": 6,
        "amount": "0",
        "uiAmountString": "0"
      },
      {
        "address": "6qoLLeaYXr6x6bP2VbGPB9Y5kNmQ6MY2p7L6yiFUXhBJ",
        "uiAmount": 0,
        "decimals": 6,
        "amount": "0",
        "uiAmountString": "0"
      }
    ]
  }
}
```

***

#### 💡 Developer Tips

* **Fixed Result Size**\
  Always returns up to **20 largest accounts**—no support for pagination.
* **Token-Specific Query**\
  Only shows holders for the mint you provide. Use a valid SPL token mint.
* **`uiAmountString` Is Recommended**\
  It’s safer and more consistent for displaying token balances than `uiAmount`.
* **Avoid Excessive Polling**\
  While efficient, repeated queries in short intervals may add unnecessary load.
* **Commitment Level Matters**\
  Use `finalized` for the most stable snapshot of top token holders.

***

The `getTokenLargestAccounts` method is a simple yet powerful way to understand SPL token distribution and visualize key holders within the Solana ecosystem. It's ideal for dashboards, analytics tools, and smart contract tooling built on **CoinVera**.


---

# 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.coinvera.io/integration/solana/rpc/gettokenlargestaccounts.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.
