Skip to main content

useUpdateMetadata

Hook for updating the NFT metadata on a smart contract.

Available to use on smart contracts that implement the ERC721 or ERC1155 standard.

import { useUpdateMetadata } from "@thirdweb-dev/react";

Usage

Provide your NFT collection contract as the argument.

import { useUpdateMetadata, useContract, Web3Button } from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";

function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync: updateMetadata, isLoading, error } = useUpdateMetadata(contract);

if (error) {
console.error("failed to update metadata", error);
}

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
updateMetadata({
name: "My NFT",
description: "This is my NFT",
image: "ipfs://example.com/my-nft.png", // Accepts any URL or File type
})
}
>
Update Metadata
</Web3Button>
);
}

Configuration

description

Description of the NFT.

image

URL or File object for the NFT's image.

An optional link to an external resource related to the NFT.

name

Name of the NFT.