# getLargestAccounts

The `getLargestAccounts` RPC method returns the top 20 accounts on the Solana network ranked by lamport balance. This data is often used for insights into wealth concentration, circulating supply dynamics, and network analytics. Keep in mind that results may be **cached by the RPC node for up to two hours**, so they may not always reflect real-time state.

***

#### ✅ Common Use Cases

* **Network Health Monitoring**: Gauge SOL concentration and decentralization by analyzing top account balances.
* **Economic & Wealth Distribution Analysis**: Understand how SOL is distributed across the network.
* **Identifying Whales**: Detect high-balance accounts that may influence token movement or governance.

***

#### 🛠 Request Parameters

This method optionally accepts a configuration object:

| Parameter    | Type                | Description                                                                                                                                                                                                       |
| ------------ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `commitment` | `string` (optional) | Commitment level to query (e.g., `processed`, `confirmed`, `finalized`). Defaults to the node’s setting.                                                                                                          |
| `filter`     | `string` (optional) | <p>Filters results by account type:<br>• <code>"circulating"</code> – Accounts contributing to circulating supply<br>• <code>"nonCirculating"</code> – Locked or reserved accounts<br>• Omit for all accounts</p> |

***

#### 📦 Response Structure

The response includes a `context` object and a `value` array of account entries:

```json
{
  "context": {
    "slot": 251998990
  },
  "value": [
    {
      "address": "4Nd1mQY...ABC123",
      "lamports": 1200000000000
    },
    ...
  ]
}
```

* `address` (string): Base-58 encoded public key.
* `lamports` (u64): Account balance in lamports (1 SOL = 1,000,000,000 lamports).

***

#### 📘 Examples

1. **Get the Largest Accounts Without Filters**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getLargestAccounts"
}
```

2. **Get Top 20 Circulating Supply Accounts**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getLargestAccounts",
  "params": [{ "filter": "circulating" }]
}
```

***

**Code Examples**

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

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

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

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

getLargestAccounts(RPC_URL);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def get_largest_accounts(rpc_url):
    try:
        response = requests.post(
            rpc_url,
            headers={
                'Content-Type': 'application/json',
            },
            json={
                'jsonrpc': '2.0',
                'id': 1,
                'method': 'getLargestAccounts',
                'params': [{'filter': 'circulating'}]
            }
        )
        
        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_largest_accounts(RPC_URL)
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "jsonrpc": "2.0",
  "result": {
    "context": { "slot": 54 },
    "value": [
      {
        "address": "99P8ZgtJYe1buSK8JXkvpLh8xPsCFuLYhz9hQFNw93WJ",
        "lamports": 999974
      },
      {
        "address": "uPwWLo16MVehpyWqsLkK3Ka8nLowWvAHbBChqv2FZeL",
        "lamports": 42
      }
    ]
  },
  "id": 1
}
```

***

#### 💡 Developer Tips

* **Caching Warning**: Results may be cached for up to 2 hours — use with awareness for time-sensitive operations.
* **Result Limit**: Only the top 20 accounts are returned. Use external analytics or archival nodes for broader analysis.
* **Filter Definitions May Vary**: The meaning of `"circulating"` and `"nonCirculating"` is node-specific and may differ slightly between providers.


---

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