Search code examples
ipfsnfthedera-hashgraph

Change Hedera NFT metadata after minting


Is there a way to change a Hedera NFT metadata after it has been minted?

My goal is to implement similar NFT minting flow as is usually used in other NFT projects, which is to first have the prereveal metadata and on the day of reveal change it to the actual one.


Solution

  • The NFT metadata field on the ledger is immutable. There is a community proposal on dynamic NFTs which may interest you.

    There are other, perhaps "hacky", ways to change the metadata of your NFT (changing the contents of the URI itself), but that may introduce some trust concerns for users.

    One could burn and re-mint NFTs, assuming your tokenId (the NFT collection) has a supply key that enables mint/burn operations. Note that that would change the serial number of the NFT.

    In case burning is a viable option for you, here's some code to do that:

      let tokenBurnTx = await new TokenBurnTransaction()
            .setTokenId(tokenId)
            .setSerials([nftSerial])
            .freezeWith(client)
            .sign(supplyKey);
        let tokenBurnSubmit = await tokenBurnTx.execute(client);
        let tokenBurnRx = await tokenBurnSubmit.getReceipt(client);
        console.log(`\nBurn NFT with serial ${nftSerial}: ${tokenBurnRx.status} \n`);