> 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-pt/sdk-react-de-escrow/indexador/usegetmultipleescrowbalances.md).

# useGetMultipleEscrowBalances

## Uso

Este hook personalizado expõe uma função para obter os saldos que você deseja obter.

{% code overflow="wrap" %}

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

/*
 *  useGetEscrow
*/
const { getMultipleBalances } = useGetMultipleEscrowBalances();

/* 
 * Ele retorna os saldos dos custodias
 * o payload deve ser do tipo `GetBalanceParams`
*/
await getMultipleBalances(payload);
```

{% endcode %}

### Função

* `getMultipleBalances`\
  Responsável por construir e retornar dados com base no payload fornecido.

*Argumento:*

`GetBalanceParams` : Um objeto contendo os campos necessários para obter os saldos.

{% content-ref url="/pages/99829e0c5d54940c1eaf5f95bfc7bf02e255f2a1" %}
[Obter saldos](/trustless-work/v1-pt/introducao/developer-resources/tipos/payloads/obter-saldos.md)
{% endcontent-ref %}

*Valor de Retorno:*

`saldos`: Os saldos que você está procurando.

***

## Exemplo de UsoForm

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

```typescript
import {
  useGetMultipleEscrowBalances,
} from "@trustless-work/escrow/hooks";
import {
  GetBalanceParams, 
} from "@trustless-work/escrow/types";

export const useGetMultipleEscrowBalancesForm = () => {

 /*
  *  useGetMultipleEscrowBalances
 */
 const { getMultipleBalances } = useGetMultipleEscrowBalances();

/*
 * função onSubmit, isso pode ser chamada por um botão de formulário
*/
 const onSubmit = async (payload: GetBalanceParams) => {

    try {
      /**
       * Chamada de API usando os hooks do trustless work
       * @Nota:
       * - Precisamos passar o payload para a função getMultipleBalances
       * - O resultado será saldos
      */
      const { balances } = await getMultipleBalances(payload);
      
      if (!balances) {
        throw new Error("Saldos não encontrados");
      }

      /**
       * @Respostas:
       * balances !== null
       * - Saldos recebidos com sucesso
       * - Mostrar um toast de sucesso
       *
       * balances === null
       * - Mostrar um toast de erro
       */
      if (balances) {
        toast.success("Saldos recebidos");
      }
    } catch (error: unknown) {
      // lógica de captura de erro
    }
  };
}

```

{% 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:

```
GET https://docs.trustlesswork.com/trustless-work/v1-pt/sdk-react-de-escrow/indexador/usegetmultipleescrowbalances.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.
