<p>The problem with the given approach of verifying the amount of tokens through <a href="https://docs.blockfrost.io/#tag/Cardano-Assets/paths/%7E1assets/get" rel="nofollow noreferrer">the /assets/ endpoint</a> like suggested is that it might guarantee you that it is an NFT currently, but it does not guarantee that it will always be an NFT.</p>
<p>For instance, it might be that the native script &quot;owner&quot; minted only one token currently, but he can still mint however many assets he wants in the future.</p>
<p>In order to actually enforce the policy is locked and guarantee that a specific token is an NFT an always will be, you will need to look at the policy of that script. To do that, block frost offers you the endpoint <code>/script/{hash}/json</code></p>
<p>For example, in pre-prod, the endpoint <code>https://cardano-preprod.blockfrost.io/api/v0/scripts/ee518da45e3ebe2858669e4eaf7c3c5a7f9be7733e47e0d48c596fd3/json</code> will give you the output</p>
<pre class="lang-json prettyprint-override"><code>{
    &quot;json&quot;: {
        &quot;type&quot;: &quot;all&quot;,
        &quot;scripts&quot;: [
            {
                &quot;type&quot;: &quot;sig&quot;,
                &quot;keyHash&quot;: &quot;87f96fd385bb6911a6f8eb47d97093ce2e3b5db2d884db7b238b0cec&quot;
            },
            {
                &quot;slot&quot;: 21561710,
                &quot;type&quot;: &quot;before&quot;
            }
        ]
    }
}
</code></pre>
<p>Which tell us that this script is governed by two rules. First, it can only be minted by the user with the key <code>87f96fd385bb6911a6f8eb47d97093ce2e3b5db2d884db7b238b0cec</code>, second that it cannot be minted after the slot <code>21561710</code>. This second part is what is important for us. NFTs are only guaranteed to be NFTs forever if the this second argument is present and if our current slot is greater than whatever slot is in that script.</p>

CC BY-SA 4.0
2023-03-02T05:41:36.807Z
what is the script hash ?
Yogesh
CC BY-SA 4.0
2023-03-02T08:50:05.143Z
@Yogesh it is the minting policy of the token
Mateus
CC BY-SA 4.0
2023-03-02T09:37:39.240Z
How can one retrieve script hash using policy_id or wallet address ?
Yogesh
CC BY-SA 4.0
2023-03-02T10:07:09.483Z
@Yogesh It is the policy ID
Mateus
CC BY-SA 4.0
2023-03-02T12:09:35.423Z
I can't find the API for this to retrieve script hash using policy ID ?
Yogesh
CC BY-SA 4.0
2023-03-02T13:06:56.253Z
@Yogesh The script hash is the same thing as the policy ID. There is no need for any API. It is a synonym. The only exception are minting policies which are not created by native scripts, but rather by a Plutus script, in which case the script hash is the has of that Plutus script itself. But it has not being widely used yet and most NFT projects still use native scripts.
Mateus
CC BY-SA 4.0
2023-03-01T14:01:50.407Z
2023-03-01T14:01:50.407Z
Mateus
<p>The only way to know if a token is an NFT is to check the Minting Policy that was used to create it. There will be the rules used to validate its creation, and you will see if in the rules there are some checks to prevent this Minting Policy to run more than once and to allow only the mint of 1 unit of this token.</p>
<p>There are two kinds of Minting Policies. Old ones with Native Scripts and newer ones with Plutus Scripts.</p>
<p>If they were minted with Native Scripts you need to see in the code some validations like @Mateus explained, with the slot before check:</p>
<pre><code>{
   &quot;slot&quot;: 21561710,
   &quot;type&quot;: &quot;before&quot;
}
</code></pre>
<p>That means that this particular Minting Policy can't run after that slot.</p>
<p>If they were minted with Plutus Scripts you will need to check if the Minting Policy is a parametrized one using an specific UTXO, that the policy is checking that this UTXO is used in the transaction and that the quantity of units of the token minted is 1.</p>
<p>The way to get the code of the Minting Policies is not so clear.
With the Currency Symbol of the token you can try to find it in the blockchain. Some times you will find it, most of the times, not....
Some blockchain explorers let developers upload the code of their minting Policies.</p>
<p>Summarizing, there is not a flawless way to probe if a token is a NFT or not.
As @Mateus explain also, one token could be a NFT now, but another copy could be done after, and it will not be a NFT anymore.
The only way to know that is going to be for ever a NFT is reading the code of the minting policy.</p>
<p>I needed to perform this check in a project I was working for, and I just relay in Blockfrost: <a href="https://docs.blockfrost.io/#tag/Cardano-Assets/paths/%7E1assets%7E1%7Basset%7D/get" rel="nofollow noreferrer">https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets~1%7Basset%7D/get</a></p>
<p>There you can see the &quot;quantity&quot; and the &quot;mint_or_burn_count&quot;. Just check if they are both 1. And at least for the moment you are sure that is a NFT.</p>

CC BY-SA 4.0
2023-03-05T00:34:36.057Z
2023-03-05T00:34:36.057Z
Manu Padilla
<p>After having a quick look at their API, it looks like it is not possible to find if the token is fungible or not.</p>
<p>You can try to fetch the quantity using <a href="https://docs.blockfrost.io/#tag/Cardano-Assets/paths/%7E1assets%7E1%7Basset%7D/get" rel="nofollow noreferrer">the /assets/ Blockfrost's endpoint</a> to see if is just one (NFT) or more (fungible).</p>

CC BY-SA 4.0
2023-03-01T13:39:11.090Z
2023-03-01T13:39:11.090Z
Marek Mahut - StakeNuts
<p>I am fetching assets stored in my wallet address. I want to seperate the fungible tokens and NFTs ,  on what basis I can differenciate both of them from data I am fetching from API (opencnft.io) like policy_id or fingerprint or any other factor which differenciates both of them?</p>

<nft>
How to differenciate between fungible token and NFT from their API data?
# How to differenciate between fungible token and NFT from their API data?

(Asked by: username_0 on 2023-03-01)

I am fetching assets stored in my wallet address. I want to seperate the fungible tokens and NFTs , on what basis I can differenciate both of them from data I am fetching from API (opencnft.io) like policy\_id or fingerprint or any other factor which differenciates both of them?

**Tags:** nft

---

## 3 answers

### Answer by username_1 on 2023-03-01. Score: 1

The problem with the given approach of verifying the amount of tokens through the /assets/ endpoint like suggested is that it might guarantee you that it is an NFT currently, but it does not guarantee that it will always be an NFT.
For instance, it might be that the native script "owner" minted only one token currently, but he can still mint however many assets he wants in the future.
In order to actually enforce the policy is locked and guarantee that a specific token is an NFT an always will be, you will need to look at the policy of that script. To do that, block frost offers you the endpoint /script/{hash}/json
For example, in pre-prod, the endpoint https://cardano-preprod.blockfrost.io/api/v0/scripts/ee518da45e3ebe2858669e4eaf7c3c5a7f9be7733e47e0d48c596fd3/json will give you the output
{
    "json": {
        "type": "all",
        "scripts": [
            {
                "type": "sig",
                "keyHash": "87f96fd385bb6911a6f8eb47d97093ce2e3b5db2d884db7b238b0cec"
            },
            {
                "slot": 21561710,
                "type": "before"
            }
        ]
    }
}

Which tell us that this script is governed by two rules. First, it can only be minted by the user with the key 87f96fd385bb6911a6f8eb47d97093ce2e3b5db2d884db7b238b0cec, second that it cannot be minted after the slot 21561710. This second part is what is important for us. NFTs are only guaranteed to be NFTs forever if the this second argument is present and if our current slot is greater than whatever slot is in that script.

> **Comments:**
> **username_0**: what is the script hash ?  
> **username_1**: @Yogesh it is the minting policy of the token  
> **username_0**: How can one retrieve script hash using policy_id or wallet address ?  
> **username_1**: @Yogesh It is the policy ID  
> **username_0**: I can't find the API for this to retrieve script hash using policy ID ?  
> **username_1**: @Yogesh The script hash is the same thing as the policy ID. There is no need for any API. It is a synonym. The only exception are minting policies which are not created by native scripts, but rather by a Plutus script, in which case the script hash is the has of that Plutus script itself. But it has not being widely used yet and most NFT projects still use native scripts.  

---

### Answer by username_2 on 2023-03-05. Score: 1

The only way to know if a token is an NFT is to check the Minting Policy that was used to create it. There will be the rules used to validate its creation, and you will see if in the rules there are some checks to prevent this Minting Policy to run more than once and to allow only the mint of 1 unit of this token.
There are two kinds of Minting Policies. Old ones with Native Scripts and newer ones with Plutus Scripts.
If they were minted with Native Scripts you need to see in the code some validations like @Mateus explained, with the slot before check:
{
   "slot": 21561710,
   "type": "before"
}

That means that this particular Minting Policy can't run after that slot.
If they were minted with Plutus Scripts you will need to check if the Minting Policy is a parametrized one using an specific UTXO, that the policy is checking that this UTXO is used in the transaction and that the quantity of units of the token minted is 1.
The way to get the code of the Minting Policies is not so clear.
With the Currency Symbol of the token you can try to find it in the blockchain. Some times you will find it, most of the times, not....
Some blockchain explorers let developers upload the code of their minting Policies.
Summarizing, there is not a flawless way to probe if a token is a NFT or not.
As @Mateus explain also, one token could be a NFT now, but another copy could be done after, and it will not be a NFT anymore.
The only way to know that is going to be for ever a NFT is reading the code of the minting policy.
I needed to perform this check in a project I was working for, and I just relay in Blockfrost: https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets~1%7Basset%7D/get
There you can see the "quantity" and the "mint_or_burn_count". Just check if they are both 1. And at least for the moment you are sure that is a NFT.


---

### Answer by username_3 on 2023-03-01. Score: 0

After having a quick look at their API, it looks like it is not possible to find if the token is fungible or not.

You can try to fetch the quantity using [the /assets/ Blockfrost's endpoint](https://docs.blockfrost.io/#tag/Cardano-Assets/paths/%7E1assets%7E1%7Basset%7D/get) to see if is just one (NFT) or more (fungible).


---

