5

I have a use case where I want to issue NFTs to users along with metadata (in the general sense of the term). The point of these NFTs is literally to hold that metadata - the user's results from participating in a race - not to display pictures/art in any way.

I later want the user to be able to provide these NFTs into a smart contract in order to prove their credentials (e.g. they are entering a marathon, which involves a smart contract that requires them to both pay an Ada fee, plus prove ownership of an NFT showing they have completed a marathon previously).

Transaction metadata is the 'workaround' used to associate metadata with art-based NFTs - "With this workaround of attaching metadata, third-party platforms like pool.pm can easily trace back to the last minting transaction, read the metadata, and query images and attributes accordingly. " (https://developers.cardano.org/docs/native-tokens/minting-nfts).

Transaction metadata is not currently usable within Plutus, however I believe in the future it will be possible to use it when creating transactions. Whether it will ever be possible to refer to it in a validator, I am not sure.

I have considered whether it would be possible to store the metadata in the datum of a UTXO holding the NFT in the user's wallet (a so called "communication" datum). However this feels fragile as I imagine you can't guarantee that it won't get lost, particularly if the UTXO also holds Ada that ends up getting spent.

Is there anything else I should be considering for this general requirement of "NFTs with metadata to be used during validation"?

1
  • If you don't have much data to store you can add it to the asset name. Like many do with the 1/1 NFTs where they put the ID into the name, e.g. MyProject123, MyProject124. You could add a unix timestamp for the time into the name of the token.
    – eddex
    Aug 10 at 14:15
1

I surely hope there's a better answer than mine, but, as a workaround, I believe one option would be to use the NFT TokenName as a metadata. For example, you could have a minting policy that would verify the conditions you provided and, if they met, use the user's PubKeyHash as the token name.

In the script validator (which will accept or reject the NFT) you could ensure that the NFT symbol is the same as the one from your script policy (ensuring conditions are met) and the token name the same as the user's PubKeyHash (making sure it was minted by him).

3
  • Thanks for the answer. Apologies for the belated acceptance. Using the TokenName isn't something I'd considered, and could work depending on how large it can be (as I need to put a fair amount of metadata in there). I will check it out.
    – William
    Aug 30 at 11:07
  • @William I don't think metadata size will be a problem, since you could create "accounts" inside a validator script, which are identified by a "signature token". The accounts could then handle all the metadata you need inside it's Datum and the "signature" token name would only need to contain the user public key hash and (depending on the implementation) the script validator hash
    – Mateus
    Aug 31 at 15:13
  • 1
    An answer I received may be helpful cardano.stackexchange.com/questions/2427/…
    – Mateus
    Aug 31 at 15:15

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.