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

# Browser and server integration

> Use isolated entry points, server-only test credentials, and an authenticated same-origin proxy.

Use the exact package and peers from the [quickstart](https://docs.gol.network/examples/solana/quickstart.md). `@gol/sdk/solana` is browser-safe; it exports `SolanaClient`, canonical encoders, independent reads, review verifiers, instruction builders, and generated `golDelegate`/`golMandate` clients. `@gol/sdk/solana/server` exports `createSolanaApiClient`, which carries a test project API key and belongs on your application server. Webhook HMAC verification comes from `@gol/sdk/server`, also server-only.

Keep the preview isolated from an existing Base application's SDK dependency and wallet configuration. The regular GOL consumer app and its Privy mainnet signer are not Solana preview entry points. A Wallet Standard account must explicitly advertise `solana:devnet`; never fall back to a mainnet signing request.

## Same-origin browser transport

The SDK requires a typed transport, not a browser API key. The project UUID may be public. This transport sends requests to your application server using your existing user session:

```ts theme={null}
import { SolanaClient, type SolanaRequest } from "@gol/sdk/solana";

export function browserClient(projectId: string) {
  const request: SolanaRequest = async <T>(method: "GET" | "POST", path: string, body?: unknown, idempotencyKey?: string): Promise<T> => {
    const response = await fetch("/api/gol-solana", {
      method: "POST", credentials: "same-origin", cache: "no-store",
      headers: { "content-type": "application/json" },
      body: JSON.stringify({ method, path, body, idempotencyKey }),
    });
    if (!response.ok) throw Error(`Solana request failed (${response.status})`);
    return response.json() as Promise<T>;
  };
  return new SolanaClient(request, projectId);
}
```

The server must authenticate the user and authorize the specific owner/resource and operation before using its API key. A shared project key alone does not prove that the browser user controls an owner or mandate. Use a fixed upstream origin, a fixed project, an explicit route allowlist, CSRF/origin protection, request limits, and no-store responses. Do not build a general URL-forwarding proxy.

## Server proxy pattern

This handler factory can be mounted as your server's POST handler. Supply `authorize` from your application's session and owner/resource authorization layer. It must fail closed and must not accept a browser-supplied owner assertion as proof. It is intentionally a required dependency, not an always-true sample authentication check.

```ts theme={null}
type Envelope = { method: "GET" | "POST"; path: string; body?: unknown; idempotencyKey?: string };
type Authorize = (request: Request, operation: Envelope) => Promise<boolean>;

export function makeSolanaProxy(options: {
  applicationOrigin: string; projectId: string; apiKey: string;
  authorize: Authorize;
}) {
  const base = `/v1/projects/${options.projectId}/solana`;
  const get = /^(configuration|owners\/[1-9A-HJ-NP-Za-km-z]{32,44}|mandates|mandates\/0x[0-9a-fA-F]{64}(\/refusals)?|executions(\?mandateId=0x[0-9a-fA-F]{64})?|executions\/[0-9a-f-]{36})$/;
  const post = /^(mandates\/(prepare|confirm)|mandates\/0x[0-9a-fA-F]{64}\/owner-actions\/(prepare|confirm)|executions(\/prepare)?)$/;
  return async function POST(request: Request): Promise<Response> {
    if (request.method !== "POST") return new Response(null, { status: 405 });
    if (request.headers.get("origin") !== options.applicationOrigin)
      return new Response(null, { status: 403 });
    const raw = await request.text();
    if (new TextEncoder().encode(raw).length > 20000)
      return new Response(null, { status: 413 });
    let operation: Envelope;
    try { operation = JSON.parse(raw); }
    catch { return new Response(null, { status: 400 }); }
    if (!operation || typeof operation.path !== "string" || !operation.path.startsWith(`${base}/`))
      return new Response(null, { status: 400 });
    const tail = operation.path.slice(base.length + 1);
    if (!(operation.method === "GET" ? get.test(tail) : operation.method === "POST" && post.test(tail)))
      return new Response(null, { status: 400 });
    if (operation.idempotencyKey !== undefined && !/^0x[0-9a-fA-F]{64}$/.test(operation.idempotencyKey))
      return new Response(null, { status: 400 });
    if (!await options.authorize(request, operation))
      return new Response(null, { status: 403 });
    const response = await fetch(`https://api.gol.network${operation.path}`, {
      method: operation.method, redirect: "error", cache: "no-store",
      headers: {
        authorization: `Bearer ${options.apiKey}`, accept: "application/json",
        ...(operation.body === undefined ? {} : { "content-type": "application/json" }),
        ...(operation.idempotencyKey ? { "idempotency-key": operation.idempotencyKey } : {}),
      },
      ...(operation.method === "POST" && operation.body !== undefined ? { body: JSON.stringify(operation.body) } : {}),
    });
    return new Response(await response.text(), {
      status: response.status,
      headers: { "content-type": "application/json", "cache-control": "no-store" },
    });
  };
}
```

Issue the server key for the minimum scopes your proxy needs. Webhook creation/secret management should stay in a separate server administrative flow, so it is absent from this browser allowlist. Add application rate limits and bounded transport error handling; do not expose upstream exception objects or private provider URLs. Retain an operation's draft ID/action ID across retries. Canonical request validation and authority enforcement remain in the platform and on-chain programs.

The [SDK reference](https://docs.gol.network/examples/solana/sdk-reference.md) lists the exact entry-point declarations; the [API reference](https://docs.gol.network/examples/solana/api-reference.md) lists the route schemas and scopes.


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