79598791

Date: 2025-04-29 16:11:44
Score: 1
Natty:
Report link

You can get the metadata in the structured format.

export async function getMeta(conn: Connection, token: string) {
  try {
    const metaplex = Metaplex.make(conn);
    const mintAddress = new PublicKey(token);
    const metadataAccount = metaplex.nfts().pdas().metadata({ mint: mintAddress });

    const metadataAccountInfo = await conn.getAccountInfo(metadataAccount);

    if (metadataAccountInfo) {
      const meta = await metaplex.nfts().findByMint({ mintAddress: mintAddress });
      return new TokenMeta({
        address: meta.metadataAddress.toBase58(),
        mintAddress: token,
        mint: meta.mint,
        updateAuthorityAddress: meta.updateAuthorityAddress.toBase58(),
        json: meta.json ? JSON.stringify(meta.json) : "",
        jsonLoaded: meta.jsonLoaded,
        name: meta.name,
        symbol: meta.symbol,
        uri: meta.uri,
        isMutable: meta.isMutable,
        primarySaleHappened: meta.primarySaleHappened,
        sellerFeeBasisPoints: meta.sellerFeeBasisPoints,
        editionNonce: meta.editionNonce,
        creators: meta.creators,
        tokenStandard: meta.tokenStandard,
        collection: meta.collection,
        collectionDetails: meta.collectionDetails,
        uses: meta.uses,
        compression: meta.compression,
      });
    }
  } catch (err) {
    G.log("❗ get meta failed", err);
  }
  return null;
}

I hope you to please remember that getting the metadata with metaplex takes some delays.
So while managing the result of the metadata you would rather to set some delays or retry when it returned the value of undefined or null.

I can provide more code if you want because I have built the pump.fun trading bot on Solana.

Thank you.
Reasons:
  • Blacklisted phrase (0.5): Thank you
  • RegEx Blacklisted phrase (1): I hope you to please
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: JordanGrit0408