Skip to main content
A TokenUpdateNftsTransaction updates the metadata property of non-fungible tokens (NFTs) on the Hedera network. The transaction requires signing with the metadata key and will fail otherwise. The new metadata must be a valid byte array and is limited to 100 bytes. All transactions are recorded on the network, providing an auditable history of changes. The metadata key allows updates to existing NFTs in a collection; if no value is provided for a field, it remains unchanged.
🚨 Metadata keys, like other token keys, must be set during the token creation. If metadata keys are not set when the token is created, they cannot be added later, and you won’t be able to update the token’s metadata.
With the introduction of HIP-850, the Supply Key now has the enhanced capability to update the metadata of NFTs while they are held in the treasury account. This enhancement allows for dynamic updates to NFT serial numbers before they are distributed, ensuring that once the NFTs leave the treasury account, their metadata remains immutable. This approach provides security and control, preventing unauthorized modifications after distribution.
PropertyDescription
Token IDThe ID of the NFT to update.
Serial NumbersThe list of serial numbers to be updated.
MetadataThe new metadata of the NFT(s).
Transaction Signing Requirements
  • Metadata key is required to sign.
  • Transaction fee payer account key.
Transaction Fees
  • Please see the transaction and query fees table for the base transaction fee.
  • Please use the Hedera fee estimator to estimate your transaction fee cost.

Methods

MethodTypeRequirement
setTokenId(<tokenId>)TokenIDRequired
setSerialNumbers(<[int64]>)List<int64>Required
setMetadata(<bytes>)bytesOptional
// Create the transaction
TokenUpdateNftsTransaction tokenUpdateNftsTx = new TokenUpdateNftsTransaction()
    .setTokenId(tokenId)
    .setSerialNumbers(nftSerials)
    .setMetadata(newMetadata)
    .freezeWith(client);

// Sign the transaction and execute it
TransactionReceipt tokenUpdateNftsResponse = tokenUpdateNftsTx.sign(metadataKey)).execute(client);

// Get receipt for update nfts metadata transaction
TokenUpdateNftsReceipt tokenUpdateNftsReceipt = tokenUpdateNftsResponse.getReceipt(client);

// Get the transaction consensus status
Status transactionStatus = tokenUpdateNftsReceipt.status;

// Print the token update metadata transaction status
System.out.println("Token metadata update status: " + transactionStatus);

//v2.32.0

FAQs

The transaction fee to update the metadata of 1 NFT is $0.001 To update metadata for multiple NFTs in a single call is N x $0.001 (N being the number of NFTs to update). See the full list of token transaction fees here.
If you don’t set metadata keys during token creation, you won’t be able to add them later or use them to update the token’s metadata.
No, metadata keys are not required for all token types. If your use case will need the ability to update the metadata in the future, the metadata key must be set during token creation. HIP-646 introduces the token metadata field for fungible tokens, providing users the ability to update metadata for both token types (fungible and non-fungible) using the metadata key.
Yes, you can create a token without metadata keys but you won’t be able to add metadata keys or update the token’s metadata.
No, once a token is created with metadata keys, those keys become a permanent part of the token’s configuration. They cannot be removed or modified after the token creation.
No, this is just like a regular TokenUpdate. It will fail if token is paused.
If the tokenId of the NFT is not paused, and if the token has metadataKey the metadata of NFT can still be updated.

Contributors: MilanWR