Skip to main content

useContractRead

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 } = useContractRead(contract, "functionName", ...args);

Signature:

export declare function useContractRead(contract: RequiredParam<ValidContractInstance>, functionName: RequiredParam<string>, ...args: unknown[] | [...unknown[], CallOverrides]): UseQueryResult<any, unknown>;

Parameters

ParameterTypeDescription
contractRequiredParam<ValidContractInstance>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:

UseQueryResult<any, unknown>

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