0

I'm working on a project where I need to fetch detailed metadata from the Solana blockchain using Web3.js. I'm looking to obtain the following information for a given token: Name, Symbol, Market Cap, Number of Holders, Official Website, Twitter and telegram

I've been trying to use the following code, but it's not working:

import  { Connection, PublicKey } from '@solana/web3.js';
import pkg from '@metaplex-foundation/mpl-token-metadata';

const { Metadata } = pkg;
const SESSION_HASH = 'QNDEMO' + Math.ceil(Math.random() * 1e9);

const connection = new Connection(`url`, {
  wsEndpoint: `url`,
  httpHeaders: {"x-session-hash": SESSION_HASH}
 });

let tokenmetaPubkey = await Metadata.getPDA(mintAddress);
const mintAddress = new PublicKey("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8");
const tokenmeta = await Metadata.load(connection, tokenmetaPubkey);

console.log(tokenmeta)

1 Answer 1

0

You can use GeckoTerminal APIs to fetch all details by passing the mint address. Additionally, for retrieving holders, you need to use the Helius API. However, you'll need to purchase premium RPC access for fetching a big amount of holders.

https://apiguide.geckoterminal.com/

https://www.helius.dev/blog/how-to-get-token-holders-on-solana

Edited:

If you want to fetch Metadata before listing then you just get the name symbol using metaplex.

https://developers.metaplex.com/token-metadata/getting-started/js

2
  • Thanks for your answers, but I need to retrieve the token data before it's listed on CoinGecko, similar to how solscan.io obtains the data directly from the blockchain Commented Mar 24 at 0:40
  • chec k the edited comment again, secondly if you want to fetch before listing then you don't fetch the marketcap from this
    – Bobz
    Commented Mar 24 at 14:40

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.