4

One can check with online tools (described here) if a token is an NFT.

How the same thing can be done using CLI tools (in some sort of a script)?

3 Answers 3

2

Since at the moment non-fungible tokens are indivisible in the Cardano network, and they can be sent only along with 1,500,000 lovelace, NFTs can be easily seen querying the "balance" at the destination address with the standard command:

cardano-cli query utxo --address $(cat payment.addr) --mainnet

Moreover, don't miss blockfrost.io project. Using it you can query information of a native token on Cardano (consider, you need to provide the string concatenation of the policy_id and hex-encoded asset_name):

curl -H 'project_id: 1234567890' https://cardano-mainnet.blockfrost.io/api/v0/assets/d894897411707efa755a76deb66d26dfd50593f2e70863e1661e98a07370616365636f696e73

You'll get the following JSON response:

{
  "policy_id": "d894897411707efa755a76deb66d26dfd50593f2e70863e1661e98a0",
  "asset_name": "7370616365636f696e73",
  "fingerprint": "asset1pmmzqf2akudknt05ealtvcvsy7n6wnc9dd03mf",
  "quantity": "50000000",
  "initial_mint_tx_hash": "3cce12c77b9d11d70575320c4f2834b26debb065308fbe43954018fbeb90010d",
  "onchain_metadata": null,
  "metadata": null
}
1

in script i would do the follow :

  1. cardano-cli query utxo --address $address --mainnet > fullUtxo.out
  2. tail -n +3 fullUtxo.out | sort -k3 -nr > balance.out while read -r utxo; do
  3. tokenAmount=$(awk '{ print $6}' <<< "${utxo}")

if you can take this info from step 3. you can use it how you prefer. for example if tokenAmount = TxOutDatumNone , means you have no Token if tokenAmount = X (number),you have X tokens from the token in the { print $7}

if you need any further assist, let me know

1

but i realized you speak for NFT. then i would do it by blockfrost:

curl -H 'project_id: mainnetb2ZFKeNsfggfDFGHJsdgw4nEhuWhExyfV'
https://cardano-mainnet.blockfrost.io/api/v0/assets/{asset}

            [![enter image description here][1]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.