4

I'm trying to get list of owned tokens from a wallet address. In the solana web3 documentation, there is a property of Connecton called getTokenAccountsByOwner, but I'm getting type error: mintAddress.toBase58 is not a function.

Here's the code I use:

const solanaWeb3 = require('@solana/web3.js');
const { Connection, programs } = require('@metaplex/js');
const axios = require('axios');

..

console.log(solanaConnection.getTokenLargestAccounts('2MTPtFo78QzWJaK9PGk9pZm9dFrVVSBGCRWPpND25GAe'));
1

1 Answer 1

1

It looks like there are some bits mixed around between your question and your code, since the question references getTokenAccountsByOwner but then the code shows getTokenLargestAccounts.

Either way, you're passing in a string, when you should be passing in a PublicKey. You can instead try:

console.log(solanaConnection.getTokenLargestAccounts(new PublicKey('2MTPtFo78QzWJaK9PGk9pZm9dFrVVSBGCRWPpND25GAe')));
2

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.