Account & Program
getProgramAccounts
Returns all accounts owned by a program
Parameters
Program public key (base-58 encoded)
Response
Array of account information objects
Account public key (base-58 encoded)
Code Examples
Basic Request
Request with Filters
Using web3.js
Notes
- Returns all accounts owned by a specific program
- Filters can be applied to narrow down results
- Account data can be sliced to reduce response size
- The response is immediate as it reads from the current state
- Different encodings can be specified for account data
Best Practices
- Use filters to efficiently query specific accounts
- Consider using dataSlice to reduce response size
- Cache results when appropriate to reduce RPC load
- Handle large result sets with pagination
- Use appropriate encoding based on your needs
Common Errors
Code | Message | Solution |
---|---|---|
-32601 | Method not found | Verify you’re connected to a Solana RPC node |
-32602 | Invalid params | Check programId and config parameters |
-32007 | Account information unavailable | Node may be bootstrapping or syncing |
Use Cases
-
Program Account Analysis
-
Program Account Monitoring
-
Program Account Pagination