I want to know for a given mint
what are all the token holders?
I know aboutgetTokenLargestAccounts
but want it without the top 20 cap?
1 Answer
Code copied from a discord message here.
What happens is
- You do the RPC call
getProgramAccounts
for the token program - then filter for accounts with the length of a token account
- then filter for accounts with the mint address / public key of your desired mint
"bytes": "token mint address here"
curl http://api.mainnet-beta.solana.com -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getProgramAccounts",
"params": [
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
{
"encoding": "jsonParsed",
"filters": [
{
"dataSize": 165
},
{
"memcmp": {
"offset": 0,
"bytes": "token mint address here"
}
}
]
}
]
}'
-
3Don't forget to mark as solved if the code actually works for you. I haven't actually run it but it looks approximately correct; the program Id and dataSize of the token account are both right, so is the offset.– Henry ECommented Jul 21, 2022 at 12:23