getLargestAccounts

Explore the getLargestAccounts RPC method β€” including its use cases, code examples, request parameters, response structure, and developer tips.

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)

Filters results by account type: β€’ "circulating" – Accounts contributing to circulating supply β€’ "nonCirculating" – Locked or reserved accounts β€’ Omit for all accounts


πŸ“¦ Response Structure

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

{
  "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

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getLargestAccounts"
}
  1. Get Top 20 Circulating Supply Accounts

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

Code Examples

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

Example Response

{
  "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.

Last updated