Saving NFT metadata offchain

Ive got a Q. @abcoathup
If we are saving metadata offchain how can we ensure the integrity of the dynamic metadata of the NFT?
Lets say there is a ‘strength’ : 20 attribute. Upgrading to 25 needs to have some onchain event.

How can we achieve that to ensure that onchain knows that it should be 25 strength forever instead of 20?
I would much rather use offchain for metadata but not sure how to implement this so onchain knows that something happened.

Is there a smart contract example of this?

1 Like

Hi @Nathan,

Welcome to the community :wave:

You can’t without storing some data (or a hash) onchain, your users have to trust that you will not modify this metadata to their detriment. If the outcome of an onchain action (such as a battle) decreases strength then ideally this value would be onchain in some form associated with the NFT.

Though cost and speed come into play.

I assume you are working on a gaming solution, which suggests you are using a sidechain or a Layer 2 solution (otherwise the cost of transactions could be greater than the value of the NFTs), so cost of storage may be less of an issue than mainnet.

I would look for examples in a similar domain and using a similar scaling solution.

The top ERC721 on Etherscan is great to look at mainnet projects:

Feel free to ask more questions.

Would it be possible to use the following method?
(this is very off the cuff thinking)

  1. Create a signing request with a message.
    1a. Message contains an array with all necessary info - basically an array with a possible unique value generated by Oracle for security purposes.
  2. Oracle type service could monitor the smart contract for transactions
  3. Oracle then updates the internal database and references the transaction as proof of change.
  4. Oracle can then, upon request, provide the necessary data and TX ID in some predefined format showing proof of change.

In the event of someone wanting to validate the information they could look at the NFT data supplied by the Oracle including the TX ID supplied to determine if the information is valid. Its a two part process to request the information and then request the ID to validate but its a possible solution.

Some examples of adding “input data” to the transaction can be found here.

1 Like

Hi @Nathan,

I am not sure.

If you want your NFT to track some state based on onchain events, then you either update your onchain metadata or your offchain metadata.

Adding transparency is a good thing but if you are doing metadata offchain, then your users have to trust you. You could publish changes to IPFS, and you could even sign them.