1

I have a question but I cannot find a concrete answer for that. I have a smart contract developed in Plutus for managing locking and withdraw of Tokens/NFTs. I'm wondering if I can validate some metadata of my NFT onchain, in my validator script.

For example, imagining this NFT: https://pool.pm/asset16tkxq9yrk6lmkwld6vnz5m8f6j54gj376jy2xx

The metadata contains: Artist, Artist Website, Id, Rarity and so on; Can I get the information about the metadata onchain on my validation script? so I can verify an specific word contained on this attributes?

Thank you so much.

1 Answer 1

2

If the NFT was minted using a transaction with metadata (cardano-cli), then the Plutus script won't be able to access this information. This is because you can only feed UTxOs to Plutus validator scripts. UTxOs don't contain the data stored on the ledger.

If you are in this situation, I would solve your problem by getting the metadata of the NFT from the ledger (using a service like Blockfrost) and validating it BEFORE feeding the UTxO to the validator script. This way, if metadata doesn't match, then there's no point in continuing with the execution of the Plutus script.

On the contrary, if the NFT was minted using a Plutus minting policy, as per this tweet, you have the ability to store this information in the UTxOs, using TxWitness field, as part of the datum hash.

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.