services
Get a key

library / Use cases / UC0019

NFT marketplace data

An NFT page reads a mint, its metadata account, its holder and its recent history. A Node script finds NFT-shaped mints in a marketplace program's transactions and decodes the metadata. Listing data needs more than these reads.

By Carbium · Commerce and marketplaces · UC0019 · updated 2026-11-22

01

What an NFT page reads

An NFT page shows a name, an image, a creator, a collection, a holder and some history. On Solana those come from different accounts, and the NFT's own mint holds almost none of it. The mint account records a supply of 1 and 0 decimals. A separate metadata account, owned by the Token Metadata program, holds the name, symbol, URI, seller fee and creators. The holder is the owner of the token account that carries the 1. The history is the list of transactions that touched the mint.

A marketplace repo from GitHub adds one more source, the marketplace program's own accounts, where listings and bids sit in a layout that program defines. The chain reads here are the same whichever marketplace program is behind the page. The program-specific part starts at listings and bids.

The metadata account sits at a derived address, built from the seeds metadata, the Token Metadata program id and the mint, under that program. A collection NFT is a mint with its own metadata account, and each item points to it through a collection field with a verified flag. A wallet can own more than one token account for one mint, so a holder check sums the amounts over its accounts.

02

The reads and their cost

The script makes four kinds of call. getSignaturesForAddress lists the newest transactions of a marketplace program. getTransaction reads each one with jsonParsed encoding, which puts the token balances after the transaction in meta.postTokenBalances. A balance of 1 at 0 decimals is an NFT-shaped mint, and its owner field names the wallet that held it after that transaction. Then getMultipleAccounts reads the mint and the metadata account together, and getTokenAccountsByOwner with a mint filter checks whether that wallet still holds the NFT.

CallCellsIn one script run
getSignaturesForAddress50one per program
getTransaction50up to 6 per program
getMultipleAccounts10 per pubkey2 pubkeys, 20 cells per NFT
getTokenAccountsByOwnerits own classone per NFT

Each call is charged in cells when it is admitted, and each class has its own rate per plan. Bursts are absorbed up to 1,024 cells or one second of the class's rate, whichever is larger. At 6 signatures per program the transaction reads cost at most 300 cells and the signature list 50, so both sit inside that burst. On Business and Pro the two methods differ, and getTransaction has the lower rate of the two. A page that fetches transactions on every view should size itself against the getTransaction rate.

Mainnet carries v1 transactions. When maxSupportedTransactionVersion is absent or 0, getTransaction and getBlock reply -32015 with no charge for a v1 transaction or a block that holds one, so the script sets it to 1.

03

A script in one file

Run it with no argument to read two public marketplace programs, Magic Eden v2 and Tensor swap, or pass one or more program ids. For each program it takes the newest 6 signatures, reads the successful transactions, collects the NFT-shaped mints, and prints the on-chain data of up to 3 NFTs: supply, decimals, holder, name, symbol, seller fee, creator count, collection and URI. It reads CARBIUM_KEY, sends every call to the RPC endpoint and exits with a message when the key is unset. It signs and sends nothing.

main.ts
// UC0019 · NFT marketplace data// https://carbium.sh/library/usecase/nft-marketplace-data// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only: finds NFT-shaped mints in a marketplace program's newest transactions and reads each one's on-chain data.import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, getAddressDecoder, getAddressEncoder, getProgramDerivedAddress } from "@solana/kit";const key = process.env.CARBIUM_KEY;if (!key) { console.error("Set CARBIUM_KEY to your Carbium API key."); process.exit(1); }const url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";const programs = process.argv.length > 2 ? process.argv.slice(2) : [  "M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K", "TSWAPaqyCSx2KABk68Shruf4rp7CxcNi8hAsbdwmHbN"];// One client, reused for every call.const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));const METADATA = address("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");const enc = getAddressEncoder();type Nft = { mint: string; holder: string; signature: string };type Parsed = { parsed: { info: { tokenAmount: { amount: string } } } };// Newest transactions of a program: a token balance of 1 at 0 decimals is an NFT-shaped mint.async function findNfts(program: string): Promise<Nft[]> {  const sigs = await rpc.getSignaturesForAddress(address(program), { limit: 6, commitment: "confirmed" }).send();  const txs = await Promise.allSettled(sigs.filter((s) => s.err === null).map(async (s) => ({    signature: s.signature,    tx: await rpc.getTransaction(s.signature, { commitment: "confirmed", encoding: "jsonParsed", maxSupportedTransactionVersion: 1 }).send(),  })));  const found = new Map<string, Nft>();  for (const r of txs) {    if (r.status === "rejected") { console.error("  getTransaction failed:", String(r.reason)); continue; }    for (const b of r.value.tx?.meta?.postTokenBalances ?? []) {      if (b.owner && b.uiTokenAmount.decimals === 0 && b.uiTokenAmount.amount === "1" && !found.has(b.mint)) {        found.set(b.mint, { mint: b.mint, holder: b.owner, signature: r.value.signature });      }    }  }  return [...found.values()];}// Token Metadata layout: key, update authority, mint, then name, symbol and uri as length-prefixed strings padded with NULs.function parseMetadata(b: Buffer) {  let p = 65;  const text = () => { const n = b.readUInt32LE(p); const s = b.toString("utf8", p + 4, p + 4 + n).replace(/\0+$/, ""); p += 4 + n; return s; };  const name = text(), symbol = text(), uri = text();  const feeBps = b.readUInt16LE(p); p += 2;  let creators = 0;  if (b[p++] === 1) { creators = b.readUInt32LE(p); p += 4 + creators * 34; }  p += 2;                   // primary sale flag, mutable flag  p += b[p] === 1 ? 2 : 1;  // edition nonce, an optional byte  p += b[p] === 1 ? 2 : 1;  // token standard, an optional byte  const collection = b[p] === 1 ? { verified: b[p + 1] === 1, mint: getAddressDecoder().decode(b.subarray(p + 2, p + 34)) } : null;  return { name, symbol, uri, feeBps, creators, collection };}async function readNft(n: Nft) {  const mint = address(n.mint);  const [pda] = await getProgramDerivedAddress({ programAddress: METADATA, seeds: ["metadata", enc.encode(METADATA), enc.encode(mint)] });  const [accounts, held] = await Promise.all([    rpc.getMultipleAccounts([mint, pda], { commitment: "confirmed", encoding: "base64" }).send(),    rpc.getTokenAccountsByOwner(address(n.holder), { mint }, { commitment: "confirmed", encoding: "jsonParsed" }).send(),  ]);  const [mintAcc, metaAcc] = accounts.value;  const raw = mintAcc ? Buffer.from(mintAcc.data[0], "base64") : null;  const holds = held.value.reduce((s, v) => s + BigInt((v.account.data as unknown as Parsed).parsed.info.tokenAmount.amount), 0n) > 0n;  console.log(`  mint ${n.mint}  supply ${raw?.readBigUInt64LE(36)}  decimals ${raw?.[44]}`);  console.log(`    holder ${n.holder} (after ${n.signature.slice(0, 12)}), still holds: ${holds}`);  if (!metaAcc) { console.log("    no Token Metadata account (a Token-2022 mint can keep metadata in the mint)"); return; }  const m = parseMetadata(Buffer.from(metaAcc.data[0], "base64"));  console.log(`    ${m.name} [${m.symbol}] fee ${m.feeBps} bps, ${m.creators} creators, collection ${m.collection ? `${m.collection.mint} verified ${m.collection.verified}` : "none"}`);  console.log(`    uri ${m.uri}`);}let shown = 0;for (const program of programs) {  if (shown >= 3) break;  console.log(`program ${program}`);  let nfts: Nft[];  try { nfts = await findNfts(program); } catch (e) { console.error("  read failed:", String(e)); continue; }  console.log(`  ${nfts.length} NFT-shaped mints in its newest transactions`);  for (const n of nfts.slice(0, 3 - shown)) {    try { await readNft(n); shown++; } catch (e) { console.error(`  ${n.mint} failed:`, String(e)); }  }}

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts [program ...]

The metadata account is parsed by hand. Name, symbol and URI are length-prefixed strings padded with NUL bytes. After them come the seller fee in basis points, an optional creator list of 34 bytes per creator, two flags, two optional bytes, and the optional collection. The script does not fetch the URI. Each call settles on its own, so one failed transaction read prints a line and the run goes on. To read the metadata of many known mints at once, Bulk NFT metadata reader covers that job.

04

Reading the answer

  • Name, symbol and seller fee: printed as stored. The fee is a number of basis points the metadata declares. What a marketplace does with it is that program's own rule.
  • URI: printed and never fetched. The image and attributes live in the JSON behind it, on a host you did not choose. Fetch it from your backend, cache it, and keep arbitrary hosts out of the page.
  • Collection: a verified flag of false means the item names a collection that never signed for it. Show a collection badge only for verified items.
  • Holder: the owner in the transaction is the wallet that held the NFT after it. For a listed NFT that can be an escrow owned by the marketplace program, and the still-holds line then reads true for the escrow. The seller is found in the listing account.
  • Token-2022 mints: a mint can keep its name and URI inside itself when its metadataPointer extension names the mint. Then no Token Metadata account exists, and the script says so.
05

Keeping the page current

A page that reads on load needs no more than that. Cache each mint's result briefly so a burst of views shares one set of reads.

To get pushes, subscribe with `logsSubscribe`, which streams transaction logs for all addresses or by mention. A mentions filter takes one address, so a subscription follows one wallet, one mint or one program account. Opening costs 5, 25 or 200 credits by filter weight and then 20 credits per MiB sent. Mentions is the 25 weight and all logs the 200 weight. Each plan caps sockets and subscriptions per account, with 5 sockets on Free. When a notification arrives, fetch the transaction by signature using the script's call instead of parsing log text. If your server only needs pushes and you would rather not keep a socket alive, see Address transaction webhooks.

06

Where it ends

  • Listings and prices: the script reads neither. A listing is an account of the marketplace program, a sale is a transaction on it, and the price sits in that program's instruction data or in the lamport changes of the transaction. Decoding them takes that program's layout, and Anchor instruction decoder shows the method for programs built with Anchor.
  • Collection listing: getTokenLargestAccounts and getProgramAccountsV2 are among eight methods that answer -32601, and -32601 is final. The script lists no collection, so build your own index from the transactions you read. For one wallet, read getTokenAccountsByOwner under both token programs and keep the accounts with an amount of 1 at 0 decimals.
  • Batches: getMultipleAccounts takes up to 300 pubkeys at 10 cells each, and the 1,024-cell burst caps a call at 100 pubkeys below Pro. A JSON-RPC post can carry up to 100 calls.
  • History: getSignaturesForAddress reaches back 30 days at most, from Carbium's own address index, and an empty page past that is the index's age limit. Its pages reach below the validator's ledger floor, so getTransaction can answer null for an older signature it lists. The script skips null.
  • Computed values: floor price, rarity rank and sales volume are not chain fields. They come from an index you build, and the script computes none of them.
  • Snapshot: every number is the state at the confirmed commitment at the moment of the read.
07

When it goes wrong

what goes wrongwhat to do
getTransaction answers -32015 for a recent signature.The transaction is v1 and the call left out maxSupportedTransactionVersion. Pass 1 together with an encoding.
getTransaction returns null for a signature that getSignaturesForAddress just listed.The address index reaches below the validator's ledger floor, so an older signature can list and still have no transaction. Treat null as missing and test the code on the newest signatures.
The metadata read returns no account for an NFT.Check the seed order: the word metadata, the Token Metadata program id, then the mint. A Token-2022 mint can hold its metadata in the mint, so read the mint's extensions before concluding it has none.
A page names a program escrow as the holder of a listed NFT.Treat the escrow as its own holder kind and read the marketplace program's listing account for the seller.
getTokenLargestAccounts answers -32601 and the client retries it.-32601 is final. Remove the call and use the owner-side reads, getTokenAccountsByOwner with a mint filter or a program filter.
A listing page reads dozens of transactions per view and gets 429.Cache per mint, read only what the view shows, wait the retry-after value and retry once.
08

Questions

How do I list every NFT a wallet owns?

Call getTokenAccountsByOwner once per token program, keep the accounts with an amount of 1 at 0 decimals, then read their metadata accounts in batches with getMultipleAccounts. A mint with a larger supply is a fungible token.

How do I tell an escrow holder from a seller wallet?

Read the holder address with getAccountInfo and check its owner. A wallet is owned by the System program, while an escrow is often a program-derived address of the marketplace. The seller itself is in the marketplace's listing account.

Can I read many mints' metadata in one request?

Derive each metadata address locally and send them to getMultipleAccounts, which takes up to 300 pubkeys but caps a call at 100 below Pro. A JSON-RPC batch of up to 100 calls is the other route.

Do I need a marketplace program's source to show an NFT page?

No. The mint, the metadata account and the token accounts are standard. You need the program's layout only for listings, bids and sale prices.