> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solanatracker.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Inicio rápido de Yellowstone gRPC

> Conecta un cliente TypeScript, configura el token, responde a pings y recibe actualizaciones de bloques Solana.

Empieza con metadatos de bloques para verificar la conexión sin descargar bloques completos. Las demás guías reutilizan el helper siguiente.

## Instala y configura

Usa Node.js 20 o posterior. Los ejemplos usan `@triton-one/yellowstone-grpc` 7.0.1; conserva la extensión `.mts` al ejecutarlos con `tsx`.

```bash theme={null}
npm install @triton-one/yellowstone-grpc@7.0.1 bs58
npm install --save-dev typescript tsx @types/node
export GRPC_ENDPOINT="https://grpc.solanatracker.io"
export GRPC_API_TOKEN="YOUR_API_TOKEN"
```

## Crea el helper de suscripción

Guárdalo como `stream.mts`. Completa los campos obligatorios, responde a pings y cierra el stream al terminar. Las desconexiones se propagan al consumidor.

```typescript stream.mts theme={null}
import Yellowstone, {
  CommitmentLevel,
  type SubscribeRequest,
  type SubscribeUpdate,
} from "@triton-one/yellowstone-grpc";

const Client = typeof Yellowstone === "function" ? Yellowstone : Yellowstone.default;

export function makeRequest(
  filters: Partial<SubscribeRequest> = {},
): SubscribeRequest {
  return {
    accounts: {}, slots: {}, transactions: {}, transactionsStatus: {},
    blocks: {}, blocksMeta: {}, entry: {}, accountsDataSlice: [],
    commitment: CommitmentLevel.CONFIRMED,
    ...filters,
  };
}

export async function* subscribe(
  filters: Partial<SubscribeRequest>,
): AsyncGenerator<SubscribeUpdate> {
  const token = process.env.GRPC_API_TOKEN;
  if (!token) throw new Error("Set GRPC_API_TOKEN before starting");
  const endpoint = process.env.GRPC_ENDPOINT ?? "https://grpc.solanatracker.io";
  // This helper exposes disconnects to the caller instead of auto-reconnecting.
  const client = new Client(endpoint, token, undefined, { enabled: false });
  const stream = await client.subscribe(makeRequest(filters));
  try {
    for await (const update of stream) {
      if (update.ping) {
        await new Promise<void>((resolve, reject) => {
          stream.write(makeRequest({ ping: { id: 1 } }), (error?: Error | null) => {
            if (error) reject(error);
            else resolve();
          });
        });
        continue;
      }
      if (!update.pong) yield update;
    }
  } finally {
    stream.destroy();
  }
}
```

## Recibe metadatos de bloques

```typescript blocks.mts theme={null}
import { subscribe } from "./stream.mts";

for await (const update of subscribe({ blocksMeta: { blocks: {} } })) {
  if (!update.blockMeta) continue;
  console.log({
    slot: update.blockMeta.slot,
    blockhash: update.blockMeta.blockhash,
    transactions: update.blockMeta.executedTransactionCount,
  });
}
```

```bash theme={null}
npx tsx blocks.mts
```

Cada fila contiene slot, blockhash y número de transacciones ejecutadas. Detén el proceso con Ctrl+C. Si no recibes datos, revisa la [autenticación](/es/yellowstone-grpc/authentication).

## Interpreta el payload

Las claves y firmas llegan como bytes; usa base58 para mostrarlas. El cliente representa enteros protobuf de 64 bits como cadenas. Conserva saldos como cadenas o `BigInt` hasta formatearlos.

## Guías relacionadas

<CardGroup cols={2}>
  <Card title="Cambios de cuentas" href="/es/yellowstone-grpc/account-monitoring" />

  <Card title="Transacciones" href="/es/yellowstone-grpc/transaction-monitoring" />

  <Card title="Fiabilidad y rendimiento" href="/es/yellowstone-grpc/best-practices" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.