Skip to main content

useCompilerMetadata

Hook for retrieving information such as the ABI, license, and metadata of a smart contract using it's contract address.

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

Usage

Provide your contract address as the argument.

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

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

function App() {
const { data, isLoading, error } = useCompilerMetadata(contractAddress);
}

export default App;

Return Value

The hook's data property, once loaded, contains the following properties:

{
name: string;
metadata: Record<string, any>;
abi: {
[x: string]: any;
type: string;
name: string;
inputs: {
[x: string]: any;
stateMutability?: string | undefined;
components?: {
[x: string]: any;
type: string;
name: string;
}[] | undefined;
type: string;
name: string;
}[];
outputs: {
[x: string]: any;
stateMutability?: string | undefined;
components?: {
[x: string]: any;
type: string;
name: string;
}[] | undefined;
type: string;
name: string;
}[];
}[];
info: {
title?: string | undefined;
author?: string | undefined;
details?: string | undefined;
notice?: string | undefined;
};
licenses: string[];
}