import * as web3 from "@solana/web3.js"; import * as metadata from "./metadata"; // see metadata.ts const tokenAddress = new web3.PublicKey( "CxkKDaBvtHqg8aHBVY8E4YYBsCfJkJVsTAEdTo5k4SEw" ); (async () => { // Connect to cluster var connection = new web3.Connection( web3.clusterApiUrl("mainnet-beta"), "confirmed" ); // get metadata account that holds the metadata information const m = await metadata.getMetadataAccount(tokenAddress); console.log("metadata acc: ", m); // get the account info for that account const accInfo = await connection.getAccountInfo(m); console.log(accInfo); // finally, decode metadata console.log(metadata.decodeMetadata(accInfo!.data)); })();