createContractQuery

Creates a useQuery hook for a contract call.

Example

import { createContractQuery } from "thirdweb/react";
import { totalSupply } from "thirdweb/extensions/erc20";
const useTotalSupply = createContractQuery(totalSupply);
const { data, isLoading } = useTotalSupply({ contract });
function createContractQuery(
readCall: (
options: BaseTransactionOptions<opts, abi>,
) => Promise<result>,
): (
options: BaseTransactionOptions<opts, abi> & {
queryOptions?: Partial<{ enabled: boolean }>;
},
) => UseQueryResult<result, Error>;

Parameters

A function that performs the contract function call and returns the result.

Type

let readCall: (
options: BaseTransactionOptions<opts, abi>,
) => Promise<result>;

Returns

let returnType: (
options: BaseTransactionOptions<opts, abi> & {
queryOptions?: Partial<{ enabled: boolean }>;
},
) => UseQueryResult<result, Error>;

An object containing the created useRead hook.