Skip to main content

useContractWrite() 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,
} = useContractWrite(contract, "myFunction");

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

Signature:

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

Returns:

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

a response object that includes the write function to call