Back to All

Reliable Solana getProgramAccounts ?

Hello!

Do anyone know why/how should I call getProgramAccounts() to retrieve all accounts from serum dex program?

This code takes almost a minute to return "{"jsonrpc":"2.0","id":"566965b3-7c1a-4338-b424-430b3240976e","error":{"code":-32603,"message":"Internal server error"}} " :

curl --location --request POST 'https://solana-mainnet.g.alchemy.com/v2/<api-key>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "method": "getProgramAccounts",
    "jsonrpc": "2.0",
    "params": [
        "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin",
        {
            "encoding": "jsonParsed",
            "commitment": "recent"
        }
    ],
    "id": "566965b3-7c1a-4338-b424-430b3240976e"
}'

I was also unlucky with the paginated query version from the main page on the solana documentation.. (I wasn't stopped by the problems in the example: 1. the script is javascript, not typescript, 2. the url is setup in a wrong variable, maybe there was some other problem too.. but these are what I retained in my mind).

ReadMe