useMetadata

Hook for getting the metadata associated with a smart contract.

Available to use on contracts that implement the Contract Metadata interface.

Example

import { useContract, useMetadata } from "@thirdweb-dev/react";
function App() {
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useMetadata(contract);
}
function useMetadata(
contract: RequiredParam<ValidContractInstance>,
): UseQueryResult;

Parameters

Instance of a SmartContract

Type

let contract: RequiredParam<ValidContractInstance>;

Returns

let returnType: UseQueryResult;

A CustomContractMetadata object containing the metadata

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;
}