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

# useUpdateEscrow

## Uso

Este hook personalizado expone una función para actualizar un escrow.

{% code overflow="wrap" %}

```typescript
import { useUpdateEscrow} from "@trustless-work/escrow/hooks";
import { UpdateSingleReleaseEscrowPayload, UpdateMultiReleaseEscrowPayload } from "@trustless-work/escrow/types";

/*
 *  useUpdateEscrow
*/
const { updateEscrow } = useUpdateEscrow();

/* 
 * Devuelve una transacción sin firmar
 * el payload debe ser del tipo `UpdateSingleReleaseEscrowPayload` o `UpdateMultiReleaseEscrowPayload`
*/
const { unsignedTransaction } = await updateEscrow(payload);

```

{% endcode %}

### Función

`updateEscrow`

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 única transacción.

**UpdateSingleReleaseEscrowPayload:** Un objeto con los campos necesarios para actualizar un **single-release** escrow.

**UpdateMultiReleaseEscrowPayload:** Un objeto con los campos necesarios para actualizar un **multi-release** escrow.

**Parámetros**:

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

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

{% content-ref url="/pages/ddfc0f4e88c15503bbbf92f15d78f15efb38347f" %}
[Actualizar escrow](/trustless-work/v1-es/introduccion/developer-resources/tipos/cargas-utiles/actualizar-escrow.md)
{% endcontent-ref %}

*Valor de retorno:*

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

***

## Ejemplo de uso

<pre class="language-typescript" data-title="src/hooks/useUpdateEscrowForm.ts" data-overflow="wrap"><code class="lang-typescript"><strong>import {
</strong>  useUpdateEscrow,
  useSendTransaction,
} from "@trustless-work/escrow/hooks";
import {
  UpdateSingleReleaseEscrowPayload, UpdateMultiReleaseEscrowPayload
} from "@trustless-work/escrow/types";

export const useUpdateEscrowForm = () => {

 /*
  *  useUpdateEscrow
 */
 const { updateEscrow } = useUpdateEscrow();
 
 /*
  *  useSendTransaction
 */
 const { sendTransaction } = useSendTransaction();

/*
 * función onSubmit, esto podría ser llamado por un botón de formulario
*/
 const onSubmit = async (payload: UpdateSingleReleaseEscrowPayload | UpdateMultiReleaseEscrowPayload) => {

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

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

      /**
       * @Nota:
       * - Necesitamos firmar la transacción usando tu [clave privada] como la billetera
       * - El resultado será una transacción firmada
       */
      const signedXdr = await signTransaction({ /* Este método debe ser proporcionado por la billetera */
        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 actualizado con éxito
       * - Mostrar una notificación de éxito
       *
       * data.status == "ERROR"
       * - Mostrar una notificación de error
       */
      if (data.status === "SUCCESS") {
        toast.success("Escrow actualizado");
      }
    } catch (error: unknown) {
      // lógica para capturar el error
    }
  };
}

</code></pre>


---

# 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:

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

The question should be specific, self-contained, and written in natural language.
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.
