Solana getTokenLargestAccounts & RugCheck getTokenReport Developer Guide
Learn how to fetch the 20 largest holders of a Solana token with a getTokenLargestAccounts RPC call. Then get the same list — owning wallets included — from a full RugCheck token report, and decide which method fits your application best.
Reference documentation: getTokenLargestAccounts
Before We Begin
Before reading this guide, you should be familiar with fetching single and multiple accounts on Solana, as well as optimizing RPC calls with byte slicing. Our developer guides for getAccountInfo and getMultipleAccounts will help you learn these skills, if you need.
Our free API keys are sufficient to complete this guide. You can get one by logging in to FluxRPC, navigating to the API Keys page, and selecting "Create API Key". For this guide, you will need to create a FluxRPC API key as well as a RugCheck API key — the banners at the top of this guide will tell you if you are missing one.
There is no need to copy-paste them: just navigate back to this page while logged in, and we will automatically use the keys from your account in every example below.
In this guide, we will accomplish the following:
- Learn how to fetch the accounts that hold the biggest amount of a given token via RPC
- Learn how to use the RugCheck report API to do the same thing
- Discuss when we might use each optimally
Fetching the Biggest Holders via RPC
Sometimes, you need to know who is holding the most tokens, for a given mint. For example, to check if there are only a few accounts holding the majority of a token, ready to sell them all off at the expense of any new people buying the token. Or to detect major changes to who is holding a token. It's a useful signal for trading bots in general.
In principle, you could run a getProgramAccounts call, with a memcmp filter for the mint, and a dataSlice extracting the token balance. This would get you all accounts that hold a given token, and then you could order them. This would be very time consuming (we won't even include the RPC call for this, it's really a waste of your bandwidth). So as a shortcut, the getTokenLargestAccounts RPC call was conceived — you specify a mint and it returns the 20 accounts holding the largest amount of tokens:
curl "https://eu.fluxrpc.com?key=<Your-API-Key>" -s -X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenLargestAccounts",
"params": ["FLUXBmPhT3Fd1EDVFdg46YREqHBeNypn1h4EbnTzWERX"]
}'
The result will be an array of token accounts and their balances. Note that these are token accounts — the owning wallet is in the account data for each. If you want the owning wallet for these, getMultipleAccounts with dataSlice is the way to go, as we discussed in the getMultipleAccounts developer guide. Just modify the example there to slice out the owning wallet (bytes 32-63 of a token account) instead of the balance.
The advantage of doing this via RPC is that it's the fastest method. The disadvantage is that if you want to know the owning wallets, you have to fetch that separately.
Fetching the Biggest Holders via RugCheck
An occasionally useful trick, is that full RugCheck reports (the getTokenReport endpoint — not the summaries) contain the top holders of the token in question. Moreover, they also contain the owning wallets already. So, if you are already requesting a RugCheck report for a token, you do not need to separately call getTokenLargestAccounts or getMultipleAccounts to fetch this information, saving 2 RPC calls and some bandwidth! (RugCheck API calls are rate-limited, but do not cost your account bandwidth.)
The advantages here are that this costs 0 bandwidth, and contains additional information. The disadvantage is that it is often slower, and the information may be served from cache (which may be up to 10 minutes old).
The example below will apply both methods, and print the results of each for you to compare.
import requests
import json
RPC_APIKey = "<Your-API-Key>"
rugCheck_APIKey = "{{RUGCHECK_API_KEY}}"
RPCRegion = "eu"
mintPubKey = "FLUXBmPhT3Fd1EDVFdg46YREqHBeNypn1h4EbnTzWERX" # Change this to another token, if you wish!
def fetchTokenLargestAccounts(mint):
headers = {'content-type': 'application/json'}
url = "https://" + RPCRegion + ".fluxrpc.com?key=" + RPC_APIKey
data = {
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenLargestAccounts",
"params": [
mint
]
}
response = requests.post(url, data=json.dumps(data), headers=headers)
return response
def fetchRugCheckReport(tokenMint):
headers = {'content-type': 'application/json', 'X-API-KEY': rugCheck_APIKey}
url = "https://api.rugcheck.xyz/v1/tokens/" + str(tokenMint) + "/report"
response = requests.get(url, headers=headers)
return response
# Fetch the top holders via RPC
response = fetchTokenLargestAccounts(mintPubKey)
if response.status_code != 200:
raise Exception("RPC returned HTTP error code " + str(response.status_code))
responseJSON = json.loads(response.text)
print("Top holders according to RPC call:")
for i in responseJSON["result"]["value"]:
account = i["address"]
balance = i["amount"]
print(str(account) + ": " + str(balance))
# Fetch the RugCheck report
report = fetchRugCheckReport(mintPubKey)
if report.status_code != 200:
raise Exception("RugCheck returned HTTP error code " + str(report.status_code))
print()
print("Top holders according to RugCheck:")
reportJSON = json.loads(report.text)
for i in reportJSON["topHolders"]: # Extract & print top holders
account = i["address"]
owner = i["owner"] # We can get the owner of the token account too!
balance = i["amount"]
print(str(account) + " (owned by " + str(owner) + "): " + str(balance))
Output may differ
The output of each may be slightly different due to RugCheck's caching!
This is also a good example of how to fetch and parse a full RugCheck report to do something useful — in this case, a slightly unexpected alternative to the getTokenLargestAccounts RPC call.
Which Method Should You Use?
The best method depends on whether speed is an important factor for your application, and whether it is making a RugCheck API call anyway for the token report:
- RPC (getTokenLargestAccounts) is the fastest, and the data is fresh. But you only get token accounts — resolving the owning wallets costs you a second RPC call, and both calls count toward your bandwidth.
- RugCheck (getTokenReport) costs 0 bandwidth, and the
topHolderslist already includes the owning wallets — plus the percentage of supply each one holds, and whether RugCheck considers them an insider. But it is often slower, and may be served from a cache that is up to 10 minutes old.
Next Steps
The RugCheck report contains a lot of information, and if you dig through it, you'll find other ways to reduce the number of RPC calls a Solana trading bot needs to make. If you want report data for many tokens at once, our bulkTokenSummary guide shows how to fetch report summaries for up to 255 tokens in a single API call.