im using python and the RPC API, which based on my research only has the GPA (get program accounts) in terms of getting a list of owned tokens.

how can i do this without using GPA due to its various shortcomings?

1 Answer 1


I haven't used Python to interact with the Solana blockchain but for the RPC API you could use getTokenAccountsByOwner for getting all the token accounts but i am not sure in your question token addresses means the mint address of a token or the tokenAccount address's of the user.

You could use the various API services as well like helius and many more

  • I'm not sure what to pass to the opts for getTokenAccountsByOwner. would i pass the wallet that minted them? in terms of a verification system, the idea would be to pass your public key to the program and it would return a number of how many of x token you have.
    – Morgandril
    Commented Jan 18, 2023 at 15:28
  • you just need to pass the user's address rest are optional
    – Pratik.js
    Commented Jan 18, 2023 at 15:56
  • No, either mint or programId is required. hence my question.
    – Morgandril
    Commented Jan 18, 2023 at 18:50
  • ahh sorry, you have to pass the TOKEN_PROGRAM_ID
    – Pratik.js
    Commented Jan 19, 2023 at 6:12
  • But this will give the list of token accounts you need to do a RPC call again. this one docs.solana.com/developing/clients/… to get the balance or no of tokens in it
    – Pratik.js
    Commented Jan 19, 2023 at 6:13

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.