How to get compressed NFT metadata
Use getAsset to fetch cNFT images, attributes, and compression details. Same API as standard NFTs, just pass the asset ID instead of a mint.
How do I find the asset ID?
Compressed NFTs use asset IDs instead of mint addresses. These are derived from the Merkle tree and don't exist as on-chain accounts. Use getAssetsByOwner to list cNFTs in a wallet, or find IDs from DRiP, Helium, or other cNFT platforms.
Try it with any cNFT
Tip: Find cNFT asset IDs by querying getAssetsByOwner for a wallet that holds compressed NFTs.
Copy the code
// Get compressed NFT metadata by asset ID
// NOTE: Compressed NFTs use asset IDs, not mint addresses
import { Helius } from 'helius-sdk';
const helius = new Helius('YOUR_API_KEY');
async function getCompressedNft(assetId: string) {
const asset = await helius.getAsset({
id: assetId,
displayOptions: {
showCollectionMetadata: true
}
});
// Check if it's actually compressed
if (!asset.compression?.compressed) {
console.log('Note: This asset is not compressed');
}
return {
name: asset.content?.metadata?.name,
image: asset.content?.links?.image,
owner: asset.ownership?.owner,
// Compression-specific fields
tree: asset.compression?.tree,
leafId: asset.compression?.leaf_id,
dataHash: asset.compression?.data_hash
};
}
// Usage - Get a cNFT asset ID from your wallet
// You can find cNFT asset IDs via getAssetsByOwner
const cNft = await getCompressedNft('YOUR_CNFT_ASSET_ID');
console.log(`cNFT: ${cNft.name}`);
console.log(`Merkle Tree: ${cNft.tree}`);API Tips
- Asset ID vs Mint: Compressed NFTs don't have mint accounts. The asset ID is a virtual identifier derived from the Merkle tree.
- Compression fields: Look for
compression.compressed = trueto confirm it's a cNFT. The tree address, leaf ID, and data hash are all compression-specific. - Popular cNFT sources: DRiP (drip.haus), Helium Mobile, and various gaming projects use cNFTs.
Frequently Asked Questions
What is a compressed NFT (cNFT)?
Compressed NFTs use Solana state compression to store NFT data off-chain in a Merkle tree, reducing minting costs by up to 1000x. They have the same metadata as regular NFTs but use asset IDs instead of mint addresses.
How do I find a compressed NFT asset ID?
Use getAssetsByOwner to list all cNFTs in a wallet. The asset ID is returned in the response. You can also find asset IDs from platforms like DRiP (drip.haus) or Helium.
Can I use the same API for regular and compressed NFTs?
Yes, getAsset works for both. For compressed NFTs, pass the asset ID instead of a mint address. Check compression.compressed in the response to identify cNFTs.