useStartDispute

Responsible for setting the escrow in dispute state. Changes the value of the escrow's "disputed" flag property to true.

Usage

This custom hook exposes a function to start a dispute in an escrow.

import { useStartDispute } from "@trustless-work/escrow/hooks";
import { SingleReleaseStartDisputePayload, MultiReleaseStartDisputePayload } from "@trustless-work/escrow/types";

/*
 *  useStartDispute
*/
const { startDispute } = useStartDispute();

/* 
 * It returns an unsigned transaction
 * payload should be of type `MultiReleaseStartDisputePayload` or `SingleReleaseStartDisputePayload`
*/
const { unsignedTransaction } = await startDispute(payload);

Mutation Function

startDispute

This is the main mutation function. Internally, it wraps mutate or mutateAsync and is responsible for building and returning an unsigned transaction based on the provided payload.

EscrowType: Specifies the type of escrow. It accepts the following values:

  • multi-release: Allows for multiple releases of funds.

  • single-release: Funds are released in a single transaction.

SingleReleaseStartDisputePayload: An object with fields necessary to dispute a single-release escrow.

MultiReleaseStartDisputePayload: An object with fields necessary to dispute a multi-release escrow by milestone.

Parameters:

Ensure they match: if you choose a "multi-release" type, you must also use a "multi-release" payload.

  • type: Describes the escrow type to be used. Options are "multi-release" or "single-release".

  • payload: An object containing the required fields to initialize an escrow.

Start Dispute

Return Value:

unsignedTransaction: An object representing the constructed transaction, ready to be signed by your wallet and broadcast.


Usage Example

Last updated

Was this helpful?