I am trying to get all NFT's from a solana wallet. I am using Connection.getTokenAccountsByOwner
method in the solana-web3.js API.
Error reads:
Error: failed to get token accounts owned by account <wallet key>: Invalid param: unrecognized Token program id
Reproduce:
async function getCollection(pk){
try {
//connect to solana cluster
var connection = new web3.Connection(
web3.clusterApiUrl('devnet'),
'confirmed',
);
//get token accounts from wallet
const nfts = await connection.getTokenAccountsByOwner(pk, {programId: pk})
console.log(nfts);
} catch (error) {
console.log("Error getting NFT:" + error);
}
}
I do not understand exactly what the 'filter' parameter {programId: publicKey}
is for. I want to access all NFT's in the account, not just ones I know the mint or program ID of.
I believe this is possible. Any help would be greatly appreciated!