Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

useInitializeEscrow

Deploy the escrow contract and define the escrow properties.

Usage

This custom hook exposes a function to deploy an escrow.

import { useInitializeEscrow } from "@trustless-work/escrow/hooks";
import { InitializeSingleReleaseEscrowPayload, InitializeMultiReleaseEscrowPayload } from "@trustless-work/escrow/types";

/*
 *  useInitializeEscrow 
*/
const { deployEscrow } = useInitializeEscrow();

/* 
 * It returns an unsigned transaction
 * payload should be of type `InitializeMultiReleaseEscrowPayload` or `InitializeSingleReleaseEscrowPayload`
*/
const { unsignedTransaction } = await deployEscrow(payload);

Function

deployEscrow 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.

InitializeSingleReleaseEscrowPayload: An object with fields necessary to initialize a single-release escrow.

InitializeMultiReleaseEscrowPayload: An object with fields necessary to initialize a multi-release escrow.

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.

Deploy

Return Value:

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


Usage Example

Last updated