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

# Network and RPC

> Mainnet configuration, RPC requirements, the endpoints the SDK reaches, and Content-Security-Policy entries

## Mainnet only

Cloak is deployed on Solana mainnet and nowhere else. There is no devnet, testnet or local
deployment, and the published SDK cannot be pointed at one: its endpoints are fixed when the package
is built. Test with small amounts on mainnet.

| | Value |
| - | - |
| Cluster | Solana mainnet-beta |
| Program | `zh1eLd6rSphLejbFfJEneUwzHRfMKxgzrgkfwA6qRkW` |
| Cloak endpoint | `https://api.cloak.ag` (`CLOAK_PRODUCTION_RELAY_URL`) |
| Circuits bundle | `https://storage.googleapis.com/cloak-circuits/circuits/0.2.0/` |

## Your Solana RPC

Cloak hosts no Solana RPC. You bring a mainnet endpoint from any provider and the SDK talks to it
directly. Cloak never inspects, replaces or proxies it.

```ts theme={null}
import { createCloak, createCloakRpc } from "@cloak.dev/sdk";

// createCloak takes the URL, or a CloakRpc you built.
const cloak = await createCloak({ wallet, rpc: process.env.SOLANA_RPC_URL });

// The low-level API takes a CloakRpc as `connection`.
const connection = createCloakRpc(process.env.SOLANA_RPC_URL!);
```

What to know about the endpoint:

* **Use a dedicated endpoint for anything beyond a demo.** If you omit `rpc`, `createCloak` falls back
  to the public mainnet endpoint, which is rate-limited.
* **Loopback endpoints are refused.** A published build throws on a `localhost` or `127.0.0.1` RPC,
  because a production artifact talking to a local validator is always a mistake.
* **Keep the URL server-side if it carries an API key.** In a browser app, either expose a
  key-restricted endpoint, or proxy RPC through your own route and pass that route's URL. Do not
  ship a secret key in a `NEXT_PUBLIC_` variable.
* **Scanning is RPC-heavy.** Transaction history (`scanTransactions`) reads program transactions
  page by page. Give it an endpoint with generous limits, and pass `limit` and the resume options to
  scan incrementally.

## The endpoints the SDK reaches

| Origin | Why | Directive |
| - | - | - |
| Your RPC | Reads chain state, sends deposits | `connect-src` |
| `https://api.cloak.ag` | Used by the SDK for private sends, withdrawals, swaps and viewing-key registration | `connect-src` |
| `https://storage.googleapis.com` | Downloads the circuits bundle (about 23 MB, once per page load) | `connect-src` |
| WebAssembly compilation | The witness generator runs as WebAssembly | `script-src 'wasm-unsafe-eval'` |

A strict Content-Security-Policy needs all of them:

```
connect-src 'self' https://<your-rpc-host> https://api.cloak.ag https://storage.googleapis.com;
script-src  'self' 'wasm-unsafe-eval';
```

If the circuits origin is blocked, the failure surfaces inside proof generation as a failed fetch
naming the artifact URL. The line that names your policy is in the browser console.

Cross-chain shields and sends also reach the routes those calls use. See
[Cross-chain](https://docs.cloak.ag/guides/cross-chain.md).

## Warming the circuits

The first proof of a page load downloads and verifies the circuits bundle. Start the download when
your page mounts, so the user's first action does not wait on it:

```ts theme={null}
import { getCircuitsPath, verifyAllCircuits } from "@cloak.dev/sdk";

void verifyAllCircuits(getCircuitsPath()); // fire and forget
```

Verified bytes are kept in memory for the life of the page.

## `relayUrl` in the low-level API

The low-level functions take a `relayUrl` option on every call. Pass the exported constant:

```ts theme={null}
import { CLOAK_PRODUCTION_RELAY_URL } from "@cloak.dev/sdk";

const options = { relayUrl: CLOAK_PRODUCTION_RELAY_URL /* , connection, ... */ };
```

There is no default, and the SDK reads no environment variable for it. Any value off the build's
allowlist throws locally before anything is signed. `createCloak` takes no endpoint option. Details
in [Request authentication](https://docs.cloak.ag/sdk/request-authentication.md#which-endpoint-the-sdk-talks-to-and-which-rpc-you-use).

## Related

* [Configuration options](https://docs.cloak.ag/reference/configuration.md)
* [Troubleshooting](https://docs.cloak.ag/resources/troubleshooting.md)


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