Skip to main content

useContractCall() function

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

Use this to get a function to make a write call to your contract

Example

const { contract } = useContract("{{contract_address}}");
const {
mutate: myFunction,
isLoading,
error,
} = useContractCall(contract, "myFunction");

// the function can be called as follows:
// myFunction(["param 1", "param 2", ...])

Signature:

export declare function useContractCall(
contract: RequiredParam<ReturnType<typeof useContract>["contract"]>,
functionName: RequiredParam<string>,
): import("@tanstack/react-query").UseMutationResult<
any,
unknown,
unknown[] | [...unknown[], CallOverrides] | undefined,
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

Returns:

import("@tanstack/react-query").UseMutationResult<any, unknown, unknown[] | [...unknown[], CallOverrides] | undefined, unknown>

a response object that includes the write function to call