4

Is there a way to fetch all PDA's owned by a Solana program?

2 Answers 2

7

The Solana cookbook has a great article about this RPC call that solves your problem. Bear in mind that this is an expensive request for the RPC nodes to fulfill, so please be gentle!

https://solanacookbook.com/guides/get-program-accounts.html#facts

2
  • Is there a way to get this data via CLI?
    – ZeroNine
    Commented Sep 23, 2022 at 2:27
  • Not that I know of. You could always roll your own.
    – HelmetFace
    Commented Sep 23, 2022 at 3:33
4

adding to @HelmetFace answer, there are several constraints to keep in mind while using getProgramAccounts

  1. not paginated, so calls to programs with huge number of accounts might not complete, and can return truncated results. use filters where applicable....
  2. and filtering is a bit primitive ( uses memcmp to do byte wise comparison ) and not very expressive.

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.