> ## Documentation Index
> Fetch the complete documentation index at: https://trust-link-tsn.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# RPC Gateway — Solana JSON-RPC and health

> Send Solana JSON-RPC through the TSN gateway and inspect provider health without exposing upstream credentials to applications.

The TSN RPC gateway forwards standard Solana JSON-RPC to ranked upstream providers and exposes health, provider, and selection endpoints.

## HTTP endpoints

| Method and path                | Purpose                                          | Return                                                                          |
| ------------------------------ | ------------------------------------------------ | ------------------------------------------------------------------------------- |
| `GET /` or `GET /health`       | Gateway health and provider state.               | JSON with `ok`, `service`, configuration, leader, probe state, and `upstreams`. |
| `GET /providers`               | Provider health inventory.                       | JSON with `ok`, `service`, `leader`, and `providers`.                           |
| `GET /selection?method=<name>` | Show the ranked provider for an RPC method.      | JSON with `upstreams` selection data.                                           |
| `GET /status`                  | Return the raw provider-pool status.             | JSON with `ok`, `service`, and pool status.                                     |
| `GET /dashboard`               | Human-readable operator dashboard.               | HTML.                                                                           |
| `POST /` or `POST /rpc`        | Forward one or more Solana JSON-RPC requests.    | Standard JSON-RPC result or error.                                              |
| `GET /ws`                      | WebSocket pass-through for Solana subscriptions. | WebSocket stream; upstream provider selection is server-side.                   |

## Parameters

For `POST /` and `POST /rpc`, send a standard JSON-RPC 2.0 object or batch array. The gateway does not define a new method namespace; method names such as `getHealth`, `getLatestBlockhash`, and `getAccountInfo` are forwarded to an upstream Solana provider.

<ParamField path="jsonrpc" type="string" required={true}>Must be `"2.0"`.</ParamField>
<ParamField path="id" type="string | number | null" required={true}>Client correlation identifier.</ParamField>
<ParamField path="method" type="string" required={true}>A supported upstream Solana JSON-RPC method.</ParamField>
<ParamField path="params" type="array" required={false}>Method-specific Solana RPC parameters.</ParamField>

<ResponseField name="result" type="unknown">The upstream Solana RPC result when the call succeeds.</ResponseField>
<ResponseField name="error" type="object">JSON-RPC error when the request is malformed or every upstream fails.</ResponseField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -s "$TSN_RPC_GATEWAY_URL/health"
  curl -s -X POST "$TSN_RPC_GATEWAY_URL/rpc" \
    -H "content-type: application/json" \
    -d '{"jsonrpc":"2.0","id":1,"method":"getHealth"}'
  ```

  ```ts TypeScript theme={null}
  import { Connection } from "@solana/web3.js";

  const connection = new Connection(process.env.TSN_RPC_GATEWAY_URL!, "confirmed");
  const blockhash = await connection.getLatestBlockhash();
  ```
</CodeGroup>

Errors include HTTP 400 with JSON-RPC `-32700` for invalid JSON, HTTP 400 with `-32600` for invalid request shape, and HTTP 502 when all upstream providers fail. Browser origins are checked by the Node server wrapper when an `Origin` header is present.

Source: [`gateway.mjs:452-579`](https://github.com/Trustlink-Labs/TSN-Protocol/blob/main/tsn-protocol/services/tsn-rpc-gateway/gateway.mjs#L452-L579), [`server.mjs:50-98`](https://github.com/Trustlink-Labs/TSN-Protocol/blob/main/tsn-protocol/services/tsn-rpc-gateway/server.mjs#L50-L98), [`README.md:24-58`](https://github.com/Trustlink-Labs/TSN-Protocol/blob/main/tsn-protocol/services/tsn-rpc-gateway/README.md#L24-L58)
