0

I am using the JS sdk and I am trying to get all accounts owned by a program already deserialized.

I can do it without Anchor but the result is not deserialized:

const accounts = await connection.getProgramAccounts(programID)

With Anchor, It feels like he wants me to add a filter no matter what (I don't want to filter).

const filtered = await program.account.baseAccount.all([])

the later gave me the error: RangeError: Trying to access beyond buffer length.

Thanks for the help,

1 Answer 1

3

Here is some more context on getProgramAccounts. There are some shortcomings to it. https://solanacookbook.com/guides/get-program-accounts.html#deep-dive

Despite its usefulness, getProgramAccounts is often misunderstood due to its current constraints. Many of the queries supported by getProgramAccounts require RPC nodes to scan large sets of data. These scans are both memory and resource intensive. As a result, calls that are too frequent or too large in scope can result in connection timeouts. Furthermore, at the time of this writing, the getProgramAccounts endpoint does not support pagination. If the results of a query are too large, the response will be truncated.

You can try third party API providers like https://www.conciselabs.io/ who are helping read decoded data reliably for a program.

Disclaimer: I work for this company.

2
  • Thanks, my dapp is not yet ready but I will definitely ask to join the beta when I will have something to show. Do you have some benchmarks, like being able to get X deserialized acounts in Y seconds ? Aug 29, 2022 at 22:12
  • 1
    yes. Here is thread with all the stuff - twitter.com/ConciseLabs/status/… Aug 30, 2022 at 4:47

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.