Is it possible to somehow update an existing ERC-721 Token's MetaData after it was already minted?

Let's say we've created a Knight character for a game - by minting an NFT for it, and 3 months later we want to update that Knight's attributes to reflect the amount of experience or treasure it has amassed through game play.

The original URI for this Knight-Token looked something like this:

    "name" : "KnightToken1",  
    "description" : "One-of-a-kind-Knight",
    "image" : "http://www.mydomain.com/myImages/knightImage.png”, 
    "attributes" : 
        “Age” : “30",
        "Treasure” : “2 Gold Crates”


We now want to update the "Treasure" attribute to "100 Gold Crates" - how can it be done?

My understanding was that it can't be done - the Blockchain is supposedly immutable after all - but I've seen some posts essentially saying "with our API you CAN do this!" - except they don't tell you how.

So I'm wondering: is this a false claim - or is there really some clever way of updating an already-minted ERC-721's token metadata? And if so, how?


Is it possible to somehow update an existing ERC-721 Token's MetaData after it was already minted?

Yes. This is not disallowed by the standard and so you are free to do this.

The official implementation of ERC-721 is maintained by 0xcert. It is free/open source and you can use the Metadata Mock contract as a starting point. You will simply add a public function that calls the internal _setTokenUri function which is waiting for you.

It will be up to you decide whether to allow anybody to change any URI anytime or if certain restrictions will be implemented.

  • 3
    Oh interesting. Seems to set up a fun paradox: On the one hand, while we’d want the owner of any NFT to truly own it - it shouldn’t mean this ownership would permit them to freely change their Token’s metadata. Cause if they do they could set their Knight’s “Treasure” value to “50,000,000 Gold Crates” at will. On the other hand, if we, the developers, need to be able to update the “Treasure” attribute of said Knight-NFT - well, by definition we shouldn’t have permission to tweak the attributes of an NFT that is clearly owned by someone else. Cause that would break everything. Fun!
    – Mark55
    Sep 28 '20 at 20:09
  • William, I looked at the ERC 721 code maintained by OpenZeppelin, and there doesn't seem to be a setTokenUri function. See here: github.com/OpenZeppelin/openzeppelin-contracts/blob/master/… OpenZeppelin contracts are popular for being compliant. Almost everyone uses them. Are you sure setTokenUri is not disallowed by the standard? Moreover any ideas why OpenZeppelin's implementation doesn't have it? Jul 27 '21 at 15:02
  • I am quite sure that setting a token URI is not disallowed by the standard, you can consider me an authority on this topic. OpenZeppelin Contracts does allow this, please note the virtual modifier on the tokenURI definition. They do not implement it for you because they usually implement the most popular use case. Jul 28 '21 at 2:12
  • William, I have read your answer and it gave me hope but then I couldn't find anything related to setTokenUri and found this saying that it got removed with v 0.8.* + forum.openzeppelin.com/t/…
    – anthony422
    Sep 14 '21 at 9:40
  • 1
    _setTokenUri still exists here.
    – Sierox
    Oct 9 '21 at 17:23

I created an NFT, listed it on OpenSea testnet. TestNFT

The NFT had a link to a json metadata file. After a few minutes, I edited the json metadata file, and then hit the refresh metadata button on opensea, and the metadata changed to the new value. So, yes, you can do this.

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.