1

I am using connection.getTokenLargestAccounts(new PublicKey(tokenAddress)); method to fetch the owners of a token. Calling this function like below, on an array of NFT address on mainnet-beta via Quicknode RPC endpoint.

const largestAcc = await connection.getTokenLargestAccounts(tokenAddress); 

On doing above, I am running into this error:

"failed to get token largest accounts: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA excluded from account secondary indexes; this RPC method unavailable for key"

I am not calling getLargetstTokenAccount for TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA, but still getting the above error. Can anyone explain the root cause of this error, and how can it be fixed?

1 Answer 1

2

getTokenLargestAccounts requires an index on part of the token program, which is TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA.

This error is telling you that your node is not configured to serve any calls that require an index on the token program, ie. getTokenLargestAccounts, getTokenAccountsByOwner.

To fix this, you'll need to use another node or configure your existing node to also index token accounts by passing --account-index spl-token-mint. Note that this consumes much more RAM, so watch that the machine doesn't run out of memory!

You can find more info at https://docs.solana.com/running-validator/validator-start#account-indexing

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.