[SOLVED] [Solana API] Getting Metadata for Fungible Token & NFT

Hello, I do have a question about getting metadata for fungible tokens and NFT and how to differentiate those two from metadata.

When I query the portfolio of a Solana Account, I get the following results:

{
“tokens”: [
{
“associatedTokenAddress”: “3Ws33UgketGZfLwGGPEg1sD1uH1ZjJrXmPVxjRoqTc7C”,
“mint”: “DWMReZQxRDjPKxnCnbXn6e4hTqQ8gs7jzR4nMWZGxfA”,
“amountRaw”: “5”,
“amount”: “5”,
“decimals”: “0”
},
{
“associatedTokenAddress”: “9R5xbsE9TfhAq1rsKoMo9riitJvkiX1gUxDTpUjUN5M7”,
“mint”: “CTtAWM28Vid6y9USt13jqjhpCL5SkW1aDztuc9jekaFD”,
“amountRaw”: “1”,
“amount”: “1”,
“decimals”: “0”
},
{
“associatedTokenAddress”: “552bwnuy1JDB4g4kpgUtXMNTBF3BEAqDGtXkkrdrM31k”,
“mint”: “DomrvXriy3Mncv7bP8LX8rhZjWRGgZGcs9dws8HnMedx”,
“amountRaw”: “1”,
“amount”: “1”,
“decimals”: “0”
}
],
“nfts”: [
{
“associatedTokenAddress”: “4BaK2BieESfiVxzXuKwfQXV9zfpEK9AG782WtQJUsmJL”,
“mint”: “E9GsTE8EChwkyMUBBY2Mp2nygbZz4j5UaHSooXhJu8Tf”,
“amountRaw”: “1”,
“amount”: “1”,
“decimals”: “0”
}
],
“nativeBalance”: {
“lamports”: “147945720”,
“solana”: “0.14794572”
}
}

Obviously, this result only tells me limited info about fungible tokens and nft.
To get more info to know what this account is actually holding, I tried the following url:

  1. For Fungible Token:
    https://solana-gateway.moralis.io/nft/mainnet/DWMReZQxRDjPKxnCnbXn6e4hTqQ8gs7jzR4nMWZGxfA/metadata

{
“mint”: “DWMReZQxRDjPKxnCnbXn6e4hTqQ8gs7jzR4nMWZGxfA”,
“standard”: “metaplex”,
“name”: “Magiceden”,
“symbol”: “NFTNOTIF”,
“metaplex”: {
“metadataUri”: “https://juptechpromotion.net/meta.json?q=085b5dea6362eaa8f5f7e93ba5ea8152”,
“updateAuthority”: “11X9tANzt8wd4dae4evom2zC6RxeL4fe1j7dm3M28PA”,
“sellerFeeBasisPoints”: 100,
“primarySaleHappened”: 0,
“owners”: [
{
“address”: “11X9tANzt8wd4dae4evom2zC6RxeL4fe1j7dm3M28PA”,
“verified”: 1,
“share”: 100
}
],
“isMutable”: true,
“masterEdition”: false
}
}

  1. For NFT:
    https://solana-gateway.moralis.io/nft/mainnet/E9GsTE8EChwkyMUBBY2Mp2nygbZz4j5UaHSooXhJu8Tf/metadata

{
“mint”: “E9GsTE8EChwkyMUBBY2Mp2nygbZz4j5UaHSooXhJu8Tf”,
“standard”: “metaplex”,
“name”: “Froots #2333”,
“symbol”: “FRTS”,
“metaplex”: {
“metadataUri”: “https://arweave.net/Olk00fZpaFHv2OwZJlBMjuh0O7KNfYTXRmT_jKHy90M”,
“updateAuthority”: “9HKgcjgZDRLTitAkr8Xp3XWopeqQ2NJxuHv9iAdqCMqR”,
“sellerFeeBasisPoints”: 500,
“primarySaleHappened”: 1,
“owners”: [
{
“address”: “6Lff4TP4DRQ61vnvhRkdt9zzSeUju4mYMr5qZQNEiCZt”,
“verified”: 1,
“share”: 0
},
{
“address”: “5VSCvdUxX4F5SEMRW31H1UexgjpnhsiKJEb2QFQv7YXe”,
“verified”: 0,
“share”: 92
},
{
“address”: “4JEsS44q2S1XNLLwHB2ix5JHziyqU7jBte5Sewcg4StA”,
“verified”: 0,
“share”: 5
},
{
“address”: “BCmuwKiY9yvBfjDAEbN3oYvMAaQU9VU3F7bmFEce2NF9”,
“verified”: 0,
“share”: 3
}
],
“isMutable”: true,
“masterEdition”: false
}
}


I got 2 questions for the above:

  1. The query (API) itself is under nft, as you can see in the url, but I am still able to get metadata for a fungible token - as far as I know (correct me if I am wrong), an NFT is a mint account with zero decimals and whose supply will never exceed one - so maybe categorization for this API is somewhat misleading, if I can use this API for a normal fungible token?

  2. Which attribute from the metadata can I use to differentiate NFT from FT with 100% accuracy? I suppose I can use “primarySaleHappened” (whatever has this field as 1 is an NFT), but not sure if it can be 100% guaranteed.

Much thanks in advance, I am relatively new to this field, so please correct me if I am misunderstanding anything!

can I use owners field to differentiate fungible vs non-fungible?

It may be changed later. You can also use that API endpoint for tokens e.g. USDC.

Which attribute from the metadata can I use to differentiate NFT from FT with 100% accuracy

Do you have other examples (addresses)?

Hi @alex, thanks for your answer.

For your 2nd point,

NFT Examples

  1. DeGod
    {
    “mint”: “G7strUmm4fhcnT7PgbB6dn4JuG8GNx3JdBNQvaGSQBer”,
    “standard”: “metaplex”,
    “name”: “DeGod #7082”,
    “symbol”: “DGOD”,
    “metaplex”: {
    “metadataUri”: “https://metadata.degods.com/g/7081.json”,
    “updateAuthority”: “AxFuniPo7RaDgPH6Gizf4GZmLQFc4M5ipckeeZfkrPNn”,
    “sellerFeeBasisPoints”: 0,
    “primarySaleHappened”: 1,
    “owners”: [
    {
    “address”: “9MynErYQ5Qi6obp4YwwdoDmXkZ1hYVtPUqYmJJ3rZ9Kn”,
    “verified”: 1,
    “share”: 0
    },
    {
    “address”: “AxFuniPo7RaDgPH6Gizf4GZmLQFc4M5ipckeeZfkrPNn”,
    “verified”: 1,
    “share”: 100
    }
    ],
    “isMutable”: true,
    “masterEdition”: false
    }
    }

  2. Okay Bears
    {
    “mint”: “FLWvavtEt4sqLdAh8MjB3YT4hzEXdzFCyzRhD6fnGn1r”,
    “standard”: “metaplex”,
    “name”: “Okay Bear #3826”,
    “symbol”: “okay_bears”,
    “metaplex”: {
    “metadataUri”: “https://bafybeigtouebpxhlaps7f3mlvo7lwortfc7umg7dp2q6uut3muiwarslee.ipfs.nftstorage.link/3825.json”,
    “updateAuthority”: “4zj22pu8yRyenFHwLmue28CqVmGFgVQt5FmVvwdP5fLa”,
    “sellerFeeBasisPoints”: 750,
    “primarySaleHappened”: 1,
    “owners”: [
    {
    “address”: “3xVDoLaecZwXXtN59o6T3Gfxwjcgf8Hc9RfoqBn995P9”,
    “verified”: 1,
    “share”: 0
    },
    {
    “address”: “7zL7HVn85F5yFT6XM3BsJcQF7PBcNE7R2BT5GyfunpKe”,
    “verified”: 0,
    “share”: 100
    }
    ],
    “isMutable”: true,
    “masterEdition”: false
    }
    }

  3. Taiyo Robotics
    {
    “mint”: “BfdRYzY5qjKAnZg4QL41HwY5nvQEJdhTyizXFAvmHUgr”,
    “standard”: “metaplex”,
    “name”: “TYR-1838”,
    “symbol”: “”,
    “metaplex”: {
    “metadataUri”: “https://cdn.taiyorobotics.com/metadata/0ce7985344f04c7a6ceda9241cdfb221.json”,
    “updateAuthority”: “CDgbhX61QFADQAeeYKP5BQ7nnzDyMkkR3NEhYF2ETn1k”,
    “sellerFeeBasisPoints”: 500,
    “primarySaleHappened”: 1,
    “owners”: [
    {
    “address”: “AsbhrsY4posEBmZ8vyAooKtpvyJoWQWTqsSnnZpDmChn”,
    “verified”: 1,
    “share”: 0
    },
    {
    “address”: “CDgbhX61QFADQAeeYKP5BQ7nnzDyMkkR3NEhYF2ETn1k”,
    “verified”: 0,
    “share”: 100
    }
    ],
    “isMutable”: true,
    “masterEdition”: false
    }
    }

FUNGIBLE TOKENS

  1. USDC
    {
    “mint”: “EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v”,
    “standard”: “metaplex”,
    “name”: “USD Coin”,
    “symbol”: “USDC”,
    “metaplex”: {
    “metadataUri”: “”,
    “updateAuthority”: “2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9”,
    “sellerFeeBasisPoints”: 0,
    “primarySaleHappened”: 0,
    “isMutable”: true,
    “masterEdition”: false
    }
    }

2. GMT
{
“statusCode”: 400,
“message”: “Bad Request”
}

  1. LINK
    {
    “mint”: “CWE8jPTUYhdCTZYWPTe1o5DFqfdjzWKc9WKz6rSjQUdG”,
    “standard”: “metaplex”,
    “name”: “Wrapped Chainlink (Sollet)”,
    “symbol”: “LINK”,
    “metaplex”: {
    “metadataUri”: “”,
    “updateAuthority”: “6krMGWgeqD4CySfMr94WcfcVbf2TrMzfshAk5DcZ7mbu”,
    “sellerFeeBasisPoints”: 0,
    “primarySaleHappened”: 0,
    “isMutable”: true,
    “masterEdition”: false
    }
    }

  2. USDT
    {
    “mint”: “Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB”,
    “standard”: “metaplex”,
    “name”: “USDT”,
    “symbol”: “USDT”,
    “metaplex”: {
    “metadataUri”: “”,
    “updateAuthority”: “Q6XprfkF8RQQKoQVG33xT88H7wi8Uk1B1CC7YAs69Gi”,
    “sellerFeeBasisPoints”: 0,
    “primarySaleHappened”: 0,
    “isMutable”: true,
    “masterEdition”: false
    }
    }

  3. SRM (Serum)
    {
    “mint”: “SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt”,
    “standard”: “metaplex”,
    “name”: “Serum”,
    “symbol”: “SRM”,
    “metaplex”: {
    “metadataUri”: “”,
    “updateAuthority”: “AqH29mZfQFgRpfwaPoTMWSKJ5kqauoc1FwVBRksZyQrt”,
    “sellerFeeBasisPoints”: 0,
    “primarySaleHappened”: 0,
    “isMutable”: true,
    “masterEdition”: false
    }
    }


Those are some response examples of famous NFT’s and tokens on Solana.
I just realized that moralis returns Bad Request for some tokens, GMT for example.
Some of tokens which moralis returns Bad Request:


May I know why moralis returns Bad Request for some tokens? Thanks. :pray:

Can you please read this on posting code in the future so your posts are easier to read.

I just realized that moralis returns Bad Request for some tokens, GMT for example.
Some of tokens which moralis returns Bad Request:

This seems expected - those two tokens do not have any metadata (check “Metadata” tab on Solscan).

Which attribute from the metadata can I use to differentiate NFT from FT with 100% accuracy

As for your question about telling the difference, I don’t think you reliably can with just these results.

Much thanks for your response @alex,

Just realized there are well-known tokens without metadata in it.

I hope that the error message is more than just “Bad Request”, as I can’t quite figure out what is exactly wrong with the request :slightly_smiling_face:

Have a lovely day!

1 Like