Skip to main content

useContractData() function

This feature is currently in beta and may change based on feedback that we receive.

Use this to get data from a contract read-function call.

Example

const { contract } = useContract("{{contract_address}}");
const { data, isLoading, error } = useContractData(
contract,
"functionName",
...args,
);

Signature:

export declare function useContractData(
contract: RequiredParam<ReturnType<typeof useContract>["contract"]>,
functionName: RequiredParam<string>,
...args: unknown[] | [...unknown[], CallOverrides]
): import("@tanstack/react-query").UseQueryResult<any, unknown>;

Parameters

ParameterTypeDescription
contractRequiredParam<ReturnType<typeof useContract>["contract"]>the contract instance of the contract to call a function on
functionNameRequiredParam<string>the name of the function to call
argsunknown[] | [...unknown[], CallOverrides]The arguments to pass to the function (if any), with optional call arguments as the last parameter

Returns:

import("@tanstack/react-query").UseQueryResult<any, unknown>

a response object that includes the data returned by the function call