Where to get Solana token metadata

By RoaringCrypto · Info · 5 min Read

TLDR; Token metadata is stored in a number of places and often requires an off-chain call to an ipfs endpoint.

1. What is Token Metadata?

Token metadata is information about a token that is stored on-chain and off-chain. Whilst some people include the supply and decimals in the definition of metadata, it typically refers to the following data:

  1. Token Name
  2. Token Symbol
  3. Image URI
  4. Any Social media urls / handles plus a website for the token.
  5. A more in depth description of the token.

2. How to get Token Metadata?

In short, when a token is created, some data (stored in binary format) is also sent to a PDA (Program Derived Address) elsewhere on the Solana chain which also contains a URL. When followed, this url links to another bit of data which is located on ipfs and JSON encoded. It's this final bit of JSON data that is the most useful as it contains social data and the token image URL.

Lets follow an example:

The Ghilbli token with mint 4TBi66vi32S7J8X1A6eWfaLHYmUXu7CStcEmsJQdpump. If you clicked the dexscreener URL, you will see it has an image icon and social accounts.

Note

Some of this social data changes over time and is sometimes only uploaded to certian platforms like dexsccreener. However, for this article we will explain the data we can get the instant the token is created as pumpfun creators have the option to include additional information on token creation.

If we visit this token mint on SolScan and go to the metadata section, we can see the following data:

{
    "key": 4,
    "updateAuthority": "TSLvdd1pWpHVjahSpsvCXUbgwsL3JAcvokwaKt1eokM",
    "mint": "4TBi66vi32S7J8X1A6eWfaLHYmUXu7CStcEmsJQdpump",
    "data": {
        "name": "Ghiblification",
        "symbol": "Ghibli",
        "uri": "https://ipfs.io/ipfs/Qmau6oU1DX5uUGHxS4uoEXrjxzxM2MtPFM9eAFPvpseFCT",
        "sellerFeeBasisPoints": 0,
        "creators": [
            {
                "address": "Dn1d8qhJhfYzd4BwwcUhzfB4veMkTRBsKc7os2kvMRVW",
                "verified": 0,
                "share": 100
            }
        ]
    },
    "primarySaleHappened": 0,
    "isMutable": 0,
    "editionNonce": 255,
    "tokenStandard": 2
}

Ok great, now we have name and symbol along with some other information. This data came from the token PDA at address GwsrCq757Aep6879K2X8jEW8wJazS4YcCC7HiFie8DFo. This can be proven by going to that address separately and seeing what data it holds. Here is the SolScan account data. This is only useful if you want to programatically get this data.

The address can be computed using functions available in multiple solana libraries. See one for Golang or the example below using the @metaplex-foundation/js library for javascript

import { Metaplex } from "@metaplex-foundation/js";

const metadata = await metaplex.nfts().findByMint({ mintAddress: mint });

Now we have this data we can follow the url field:

https://ipfs.io/ipfs/Qmau6oU1DX5uUGHxS4uoEXrjxzxM2MtPFM9eAFPvpseFCT

This then takes to the additional JSON data stored in ipfs... and bingo, we have more useful data like description, the image, and a social account. (Sure the "social account" here is actuall an x search but its usually populated by the actual creator's social media)

{
    "name": "Ghiblification",
    "symbol": "Ghibli",
    "description": "Ghiblify everyone",
    "image": "https://ipfs.io/ipfs/QmT7pkJ1aTLRqWEVY8jY33k2YxacHYeiMb76iUGf6F6PuX",
    "showName": true,
    "createdOn": "https://pump.fun",
    "twitter": "https://x.com/search?q=ghibli"
}

3. Get Metadata with SolanaStreaming

All this data is available from within the SolanaStreaming websocket data. When listening to the NewPairs subscription which streams new token pairs created live, it also includes social data (if there is any), token name, symbol and image url.

Get started for free and get your free api key.