PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, September 25, 2022

[FIXED] How can I get a list of Tokens in a Solana Wallet?

 September 25, 2022     api, blockchain, node.js, solana     No comments   

Issue

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'));

Solution

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')));


Answered By - Jon C
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing