Is there a way to fetch all PDA's owned by a Solana program?
2 Answers
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
adding to @HelmetFace answer, there are several constraints to keep in mind while using getProgramAccounts
- not paginated, so calls to programs with huge number of accounts might not complete, and can return truncated results. use filters where applicable....
- and filtering is a bit primitive ( uses memcmp to do byte wise comparison ) and not very expressive.