Since addresses of token accounts do not necessarily need to be PDAs following a seed pattern that makes it easy to find them again by deriving the PDA using the pattern information, I wonder how tools like the Token Program CLI actually find the correct token account for an owner/mint pair. Are these tools actually fetching through all accounts of type Account
owned by the Token Program and compare the fields owner
and mint
with the search parameter?
Add a comment
|
1 Answer
The actual cli function calls the getTokenAccountsByOwner rpc method. The rpc indexes token accounts to allow this function to be easily called.
More generally though the getProgramAccounts can be called to return all accounts owned by a program with given filters.