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

# Primeros pasos

### Descripción general

El Trustless Work React SDK es una colección de hooks y entidades tipadas.

Utiliza [Axios](https://axios-http.com/docs/intro) para solicitudes HTTP.

{% hint style="info" %}
Los flujos de escritura requieren una clave de API (`NEXT_PUBLIC_API_KEY`). Las llamadas de solo lectura pueden funcionar sin una.
{% endhint %}

### Enlaces rápidos

<table data-view="cards"><thead><tr><th>Título</th><th data-card-target data-type="content-ref">Enlace</th></tr></thead><tbody><tr><td>Paquete NPM</td><td><a href="https://www.npmjs.com/package/@trustless-work/escrow">https://www.npmjs.com/package/@trustless-work/escrow</a></td></tr><tr><td>Conceptos básicos de la API (URLs base, Swagger, límites)</td><td><a href="/trustless-work/v1-es/api-rest/introduction.md">Introducción</a></td></tr><tr><td>Enviar transacciones firmadas (XDR)</td><td><a href="/trustless-work/v1-es/escrow-react-sdk/usesendtransaction.md">useSendTransaction</a></td></tr></tbody></table>

### Configuración

{% stepper %}
{% step %}

### Instalación

Instala el SDK.

{% tabs %}
{% tab title="npm" %}

```sh
npm install "@trustless-work/escrow"
```

{% endtab %}

{% tab title="yarn" %}

```sh
yarn add "@trustless-work/escrow"
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Configura el proveedor

Configurarás 2 cosas:

* `baseURL`: usa `development` (testnet) o `mainNet` (mainnet).
* `apiKey`: desde el dApp BackOffice.

El SDK exporta `TrustlessWorkConfig`. Envuelve tu aplicación con él para habilitar todos los hooks.

{% code title="src/trustless-work-provider.tsx" overflow="wrap" fullWidth="true" %}

```typescript
"use client"; // asegúrate de que este sea un componente cliente

import React from "react";
import {
  // entorno de desarrollo = "https://dev.api.trustlesswork.com"
  development,

  // entorno mainnet = "https://api.trustlesswork.com"
  mainNet,
  TrustlessWorkConfig,
} from "@trustless-work/escrow";

interface TrustlessWorkProviderProps {
  children: React.ReactNode;
}

export function TrustlessWorkProvider({
  children,
}: TrustlessWorkProviderProps) {
  const apiKey = process.env.NEXT_PUBLIC_API_KEY || "";

  return (
    <TrustlessWorkConfig baseURL={development} apiKey={apiKey}>
      {children}
    </TrustlessWorkConfig>
  );
}

```

{% endcode %}

{% hint style="warning" %}
Si renderizas este proveedor en el servidor, los hooks fallarán. Mantenlo en un componente cliente.
{% endhint %}
{% endstep %}

{% step %}

### Envuelve tu aplicación

Elige el fragmento que coincida con tu configuración.

{% tabs %}
{% tab title="Next.js (App Router)" %}
{% code title="app/layout.tsx" %}

```typescript
import { TrustlessWorkProvider } from "@/trustless-work-provider";
 
export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        <TrustlessWorkProvider>{children}</TrustlessWorkProvider>
      </body>
    </html>
  );
}
```

{% endcode %}
{% endtab %}

{% tab title="React (SPA)" %}
{% code title="src/app.tsx" %}

```typescript
import { TrustlessWorkProvider } from "./trustless-work-provider";
 
export function App() {
  return (
    <TrustlessWorkProvider>
      <YourApp />
    </TrustlessWorkProvider>
  );
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Usa hooks y entidades

Ahora puedes llamar a los hooks del SDK desde cualquier componente bajo el proveedor.

Flujo típico:

1. Llama a un hook para obtener un **XDR sin firmar**.
2. Firma el XDR con la wallet del rol correcto.
3. Envíalo con `useSendTransaction`.

Leer: [useSendTransaction](/trustless-work/v1-es/escrow-react-sdk/usesendtransaction.md).
{% endstep %}
{% endstepper %}

{% hint style="success" %}
Este SDK soporta **single-release** y **multi-release** escrows. Usa el hook y el tipo de payload correctos para cada flujo.
{% endhint %}


---

# 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/primeros-pasos.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.
