> For the complete documentation index, see [llms.txt](https://docs.trustlesswork.com/trustless-work/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trustlesswork.com/trustless-work/v1-es/escrow-react-sdk/escrows/usereleasefunds.md).

# useReleaseFunds

Libera los fondos del escrow al proveedor de servicios a través del aprobador.

## Uso

Este hook personalizado expone una función para liberar los fondos de un escrow.

{% code overflow="wrap" %}

```typescript
import { useReleaseFunds } from "@trustless-work/escrow/hooks";
import { SingleReleaseReleaseFundsPayload, MultiReleaseReleaseFundsPayload } from "@trustless-work/escrow/types";

/*
 *  useReleaseFunds
*/
const { releaseFunds } = useReleaseFunds();

/* 
 * Devuelve una transacción sin firmar
 * el payload debe ser de tipo `MultiReleaseReleaseFundsPayload` o `SingleReleaseReleaseFundsPayload`
*/
const { unsignedTransaction } = await releaseFunds(payload);

```

{% endcode %}

### Función de Mutación

`releaseFunds`

Responsable de construir y devolver una transacción sin firmar basada en el payload proporcionado.

**EscrowType**: Especifica el tipo de escrow. Acepta los siguientes valores:

* **multi-release**: Permite múltiples liberaciones de fondos.
* **single-release**: Los fondos se liberan en una sola transacción.

**SingleReleaseReleaseFundsPayload:** Un objeto con los campos necesarios para liberar un **single-release** escrow.

**MultiReleaseReleaseFundsPayload:** Un objeto con los campos necesarios para liberar un **multi-release** escrow por un hito específico.

**Parámetros**:

Asegúrate de que coincidan: si eliges el tipo "multi-release", también debes usar un payload de "multi-release".

* **tipo**: Describe el tipo de escrow que se va a usar. Las opciones son "multi-release" o "single-release".
* **payload**: Un objeto que contiene los campos requeridos para liberar un escrow o un hito.

{% content-ref url="/pages/ebcaff442460b5bab0049bb67c938c852a363922" %}
[Liberar fondos](/trustless-work/v1-es/introduccion/developer-resources/tipos/cargas-utiles/liberar-fondos.md)
{% endcontent-ref %}

*Valor de retorno:*

`unsignedTransaction`: Un objeto que representa la transacción construida, lista para ser firmada por tu wallet y transmitida.

***

## Ejemplo de uso

{% code title="src/hooks/useReleaseFundsForm.ts" overflow="wrap" %}

```typescript
import {
  useReleaseFunds,
  useSendTransaction,
} from "@trustless-work/escrow/hooks";
import {
  SingleReleaseReleaseFundsPayload, MultiReleaseReleaseFundsPayload
} from "@trustless-work/escrow/types";

export const useReleaseFundsForm = () => {

 /*
  *  useReleaseFunds
 */
 const { releaseFunds } = useReleaseFunds();
 
 /*
  *  useSendTransaction
 */
 const { sendTransaction } = useSendTransaction();

/*
 * función onSubmit, esto podría ser llamado por el botón del formulario
*/
 const onSubmit = async (payload: MultiReleaseReleaseFundsPayload | SingleReleaseReleaseFundsPayload) => {

    try {
      /**
       * Llamada a la API usando los hooks de trustless work
       * @Nota:
       * - Necesitamos pasar el payload a la función releaseFunds
       * - El resultado será una transacción sin firmar
       */
      const { unsignedTransaction } = await releaseFunds(
        payload,
        "multi-release"
        // o ...
        // "single-release"
      );

      if (!unsignedTransaction) {
        throw new Error(
          "La transacción sin firmar falta en useReleaseFunds."
        );
      }

      /**
       * @Nota:
       * - Necesitamos firmar la transacción usando tu [clave privada] como la wallet
       * - El resultado será una transacción firmada
       */
      const signedXdr = await signTransaction({ /* Este método debe ser proporcionado por la wallet */
        unsignedTransaction,
        address: walletAddress || "",
      });

      if (!signedXdr) {
        throw new Error("La transacción firmada falta.");
      }

      /**
       * @Nota:
       * - Necesitamos enviar la transacción firmada a la API
       * - Los datos serán un SendTransactionResponse
       */
      const data = await sendTransaction(signedXdr);

      /**
       * @Respuestas:
       * data.status === "SUCCESS"
       * - Escrow liberado con éxito
       * - Mostrar un toast de éxito
       *
       * data.status == "ERROR"
       * - Mostrar un toast de error
       */
      if (data.status === "SUCCESS") {
         toast.success("El escrow ha sido liberado");
      }
    } catch (error: unknown) {
      // lógica para capturar errores
    }
  };
}

```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.trustlesswork.com/trustless-work/v1-es/escrow-react-sdk/escrows/usereleasefunds.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
