useMetadata
Hook for getting the metadata associated with a smart contract.
Available to use on contracts that implement the Contract Metadata interface.
import { useMetadata } from "@thirdweb-dev/react";
Usage
Provide your contract instance as the argument.
import { useContract, useMetadata } from "@thirdweb-dev/react";
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useMetadata(contract);
}
Return Value
The hook's data
property, once loaded, is an object containing the contract's metadata.
CustomContractMetadata | undefined;
interface CustomContractMetadata {
/**
* The name of the contract.
*/
name: string;
/**
* A description of the contract.
*/
description?: string;
/**
* The image associated with the contract.
*/
image?: any;
/**
* An external link associated with the contract.
*/
external_link?: string;
}