Search code examples
typescriptsolanasolana-web3js

Get the list of assets associated to a Solana wallet address


I am using web3 sdk of Solana to query balances or make transactions. Now I would like to know if it's possible to achieve one of the following actions:

  1. Get a list of the assets from a provided wallet address.
  2. Get a wallet address from a provided nft address. This one will be better if both are possible.

Solution

  • Absolutely, to answer your questions:

    1. getTokenAccountsByOwner, where the owner is the wallet address: https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getTokenAccountsByOwner
    2. getTokenLargestAccounts will give the holders for the nft: https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getTokenLargestAccounts