Searching for a better way to store NFT metadata

Hi, I have been thinking recently about the way we are predominately creating NFTs on Cardano, right now the trend is to add the NFT attributes to the transaction metadata, however, I think this is not really that good if we want to do more interesting things with the tokens. As long as we keep adding the NFT attributes to the transaction metadata we will never have decentralized minting (creating new NFTs from smart contracts, e.g breeding mechanism etc), as we can not enforce any kind of restrictions on the transaction metadata from the scripts. The users always have all the freedom to add anything to the metadata. Also, we cant read the information stored there from the contracts, making it impossible to use for example to implement business logic on the chain.

I have the following idea, but I am not sure if it could work:

Objectives:

1.- Stay away from an account base model and if possible keep the NFT as a native token.
2.- Have the metadata accessible from the contracts (token metadata must be inside an eUTXO).

Possible solution:

At minting time we create two tokens, for example:

“fffffffffffffffffffff.Monster00001” and “fffffffffffffffffffff.Monster00001_state” (they could be in the same policy or different policies).

Token “Monster00001” could still be freely traded as a native token, however token Monster00001_state will be trapped in an eUTXO which holds the token metadata or dynamic state (depending on the use case).

To retrieve the metadata for token fffffffffffffffffffff.Monster00001 we just need to find the eUTXO which contains fffffffffffffffffffff.Monster00001_state and read its Datum, but here is where I am stuck.

I know that by using –tx-out-datum-embed-file we can embed the datum data on the transaction (as opposed to the datum hash). However, is this information persisted on the blockchain? (I am guessing it is as it is needed in some scripts validators), and if so, how can we retrieve this data?.

Another option I was thinking of is to encode the data in additional tokens, for example, if the NFT has strength attribute or dexterity, we could add these tokens to the eUTXO (30 tokens of strength).

We could also encode some information on the asset name as @bwbush showed on another thread, however, the space to do this is limited (although if we are creative I guess we could store a large amount of information there). We could also combine several of these approaches.

I was wondering if anyone has come up with a good solution for this/ has already implemented something like this?

Hello @AngelCastilloB

There is a developer that goes by handle TurboEgon. He already developed a way to have fully on-chain interactive CNFT. He was also one of the original CNFT creators and he implemented this structure in CNFT series he developed called Stellar Hood. He took the info of all discovered stars and planets from NASA and created CNFT representing each stellar body with type, stats distance from earth, etc… You can click on the CNFT and you can rotate and zoom in and out to see position of the stellar objects for that CNFT in the system where it resides. The best part is that it is fully on-chain and fully interactive while being accessed trough blockchain. No IPFS or outside servers needed.
He was able to fully imbed a machine code into CNFT meta data that functions as a program when accessed. You can view an example of this on Stellar Hood website
https://stellarhood.com/

He also had couple of other projects and his tech was used to make Cardano Trees CNFT (that became famous recently).

This dev is a genius, too bad not too many people know about him or his work. He was one of the OGs of CNFT projects, first to invent fully on chain interactive Cardano NFT, First to support artist that wanted to make Cardano NFT be fully on chain. I guess people rather just buy JPEG images these days :rofl:

If you want to check out some of his other projects and application of this:

2 Likes

Hi @Neo_Spank, thanks for the information, this looks awesome!. However is not what I am looking for, even tho all the data of the tokens are on-chain, it is still located at the transaction metadata, which makes it inaccessible from the smart contracts.

I am trying to find a way to add the token data in a way in which I can access it from the smartcontracts so I can enforce rules upon it.

But thanks for sharing, looks awesome :)!.

1 Like

@AngelCastilloB have you considered passing it in as a datum for the script?

Hi @DinoDude, yes this is what I want to do, what I am trying to figure out is how to display the token attributes off-chain, since the datum is stored in the eUTXO as a hash, how can I retrieve the actual datum value (instead of the hash) off-chain to for example display the NFT in a website?.

I think blockfrost has on his API a way to retrieve datum values, but how could I do this with dbSync for example?

For the first question it depends greatly on the hashing format as not all can be decoded to original form (MD5 etc). If it is base16 or something simple then it should be fairly easy to reverse the hash for display purposes. Many blockchain explorer websites already do this for asset names of tokens.

As for how would you query the ledger, find the minting transactions for a given policy, find a specific token, get datums and lookup metadata from cardano db sync I will look into it and post a SQL query here if/when I figure it out. This is something I will need later for my project as well.

Afterthought, there is also an external metadata server registry here: