Function useContractWrite

  • Beta

    Mke a write call to your contract

    Type Parameters

    • TContractAddress extends string

    • TContract extends ValidContractInstance

    • TContractInstance extends ValidContractInstance

    • TFunctionName extends string

    • TArgs extends any[]

    Parameters

    • contract: TContractInstance extends ValidContractInstance
          ? RequiredParam<TContractInstance>
          : TContractAddress extends never
              ? RequiredParam<SmartContract<BaseContractForAddress<TContractAddress>>>
              : RequiredParam<SmartContract<BaseContract>>

      the contract instance of the contract to call a function on

    • functionName: RequiredParam<TFunctionName & string>

      the name of the function to call

    Returns UseMutationResult<Omit<{
        data: (() => Promise<unknown>);
        receipt: providers.TransactionReceipt;
    }, "data">, unknown, {
        args?: TArgs;
        overrides?: CallOverrides;
    }, unknown>

    a response object that includes the write function to call

    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", ...])

    See

    Documentation

Generated using TypeDoc