To get the balance of a specific token from a wallet, I use getTokenAccountsByOwner, but this is giving the balance for only one token, and I need to request for more than one token.

I was wondering if it is possible to get the balance of multiple tokens for a wallet. Or if I can do it via websocket.

1 Answer 1


That should give all the tokens for a given owner assuming you use the programId filter and set it to TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID, instead of using the mint filter.


to clarify, a couple methods get all tokens held for a given wallet address/any public key):

const tokenProgram = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")

getTokenAccountsByOwner(pubkey, {programId: tokenProgram})


import {TOKEN_PROGRAM_ID} from "@solana/spl-token"

getTokenAccountsByOwner(pubkey, {programId: TOKEN_PROGRAM_ID})

and vice verse with the respective token 2022 program id

  • With that 2 values is not working, but I used {"programId": "address_of_owner_program_of_the_tokens"}
    – KunLun
    Nov 27, 2023 at 7:12

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.