> 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/usefundescrow.md).

# useFundEscrow

## Uso

Este hook personalizado expone una función para financiar y escrow.

{% code overflow="wrap" %}

```typescript
import { useFundEscrow } from "@trustless-work/escrow/hooks";
import { FundEscrowPayload } from "@trustless-work/escrow/types";

/*
 *  useFundEscrow
*/
const { fundEscrow } = useFundEscrow();

/* 
 * Devuelve una transacción no firmada
 * el payload debe ser de tipo `fundEscrow`
*/
const { unsignedTransaction } = await fundEscrow(payload);

```

{% endcode %}

### Función de Mutación

**`fundEscrow`**

Devuelve una transacción no firmada 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.

**FundEscrowPayload:** Un objeto con los campos necesarios para financiar un escrow. Es aplicable tanto para los tipos de escrow single-release como multi-release.

**Parámetros**:

* **type**: Describe el tipo de escrow a utilizar. Las opciones son "multi-release" o "single-release".
* **payload**: Contiene los datos requeridos para financiar el escrow.

{% 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/useFundEscrowForm.ts" overflow="wrap" %}

```typescript
import {
  useFundEscrow,
  useSendTransaction,
} from "@trustless-work/escrow/hooks";
import {
  FundEscrowPayload
} from "@trustless-work/escrow/types";

export const useFundEscrowForm = () => {

 /*
  *  useFundEscrow
 */
 const { fundEscrow } = useFundEscrow();
 
 /*
  *  useSendTransaction
 */
 const { sendTransaction } = useSendTransaction();

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

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

      if (!unsignedTransaction) {
        throw new Error(
          "La transacción no firmada falta en la respuesta de fundEscrow."
        );
      }

      /**
       * @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 financiado con éxito
       * - Mostrar un toast de éxito
       *
       * data.status == "ERROR"
       * - Mostrar un toast de error
       */
      if (data.status === "SUCCESS") {
        toast.success("Escrow financiado");
      }
    } 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
