8

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 1

12

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"
            }
          }
        ]
      }
    ]
  }'
1
  • 2
    Don'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 E
    Jul 21, 2022 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.