1

How do I get all token balances for a specific mint? I want a list of all owners and their balance.

I would also like to do this at a historical point in time using a snapshot.

1 Answer 1

1

This is a very tricky problem with a few solutions.

Note that this is impossible using the normal JSON RPC API, since no historical account data is served through the RPC.

If you want to get the current owners and balances for a mint, you can do getProgramAccountshttps://docs.solana.com/api/http#getprogramaccounts with the following params:

"params": [
      "<TOKEN_PROGRAM_ID_GOES_HERE>",
      {
        "filters": [
          {
            "dataSize": 165
          },
          {
            "memcmp": {
              "offset": 0,
              "bytes": "<MINT_AS_BASE_58_GOES_HERE>"
            }
          }
        ]
      }
    ]

To do it from a snapshot, you can hack solana-ledger-tool to do something similar. I have a branch which searches through all programs at a snapshot, which you could certainly hack to work with tokens too: https://github.com/joncinque/solana/tree/lt-gpa

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.