<!-- tempo-docs-context -->
> Source: [/docs/guide/private-zones/connect-to-a-zone](https://tempo.com/developers/docs/guide/private-zones/connect-to-a-zone.md)
> Section: [Zones](https://tempo.com/developers/docs/zones.md). Connect to a Zone and work with private balances, deposits, and withdrawals. Zones is live on Mainnet; see the introduction to set up a Zone. Earlier testnet sandbox guides describe a separate integration.
> Earlier testnet sandbox: use [Zones](https://tempo.com/developers/docs/zones.md) for current Mainnet deployments.
> [Documentation index](https://tempo.com/developers/llms.txt) · [Docs skill](https://tempo.com/developers/SKILL.md)

> Tempo MCP: Use `search`, `find_pages`, `read_page`, and `code` at `https://mcp.tempo.xyz` for Tempo and related documentation.
> If an indexed page is missing or reflects an older site, read this site’s [documentation index](https://tempo.com/developers/llms.txt) and Markdown pages directly.

# Connect to the Sandbox

Connect a Viem client to Zone A or Zone B and sign the token that scopes RPC reads to you.

## Overview

A Zone client reads private balances and submits Zone transactions. This guide connects one to Zone A or Zone B in the [testnet sandbox](https://tempo.com/developers/docs/guide/private-zones#testnet-compatibility), which differs from current deployments. Your account signs an [authorization token](https://tempo.com/developers/docs/zones/connect#authorize-access), so the Zone RPC scopes requests to you.

To connect directly, you need a Tempo account, RPC access, and the sandbox connection details. The interactive guides handle the connection and authorization for you.

## Create a Viem Client

Use `zoneModerato(6)` or `zoneModerato(7)` from `viem/tempo/zones` for these examples. They need `viem@2.54.6`, which matches the sandbox's portal and outbox interfaces. Install it with `pnpm add viem@2.54.6`.

Get [RPC access from Tempo](https://tempo.com/contact) before connecting to the shared endpoints directly. The server-side example reads the operator-provided HTTP `Authorization` header from `ZONE_RPC_AUTHORIZATION`. This endpoint access is separate from the signed `X-Authorization-Token`. The Zone RPC requires that token even for chain metadata reads.

The example signs that token with an ephemeral account for metadata reads. Use your actual account when reading private balances. Confirm that the endpoint's `eth_chainId` matches the sandbox chain ID before signing.

```ts
import { createClient } from 'viem'
import { generatePrivateKey } from 'viem/accounts'
import { Account, tempoActions } from 'viem/tempo'
import { http, zoneModerato } from 'viem/tempo/zones'

const rpcUrl = 'https://rpc-zone-a.testnet.tempo.xyz'
const authorization = process.env.ZONE_RPC_AUTHORIZATION
if (!authorization) throw new Error('Set ZONE_RPC_AUTHORIZATION from your zone operator.')

const zoneClient = createClient({
  account: Account.fromSecp256k1(generatePrivateKey()),
  chain: zoneModerato(6),
  transport: http(rpcUrl, {
    fetchOptions: { headers: { Authorization: authorization } },
  }),
}).extend(tempoActions())

await zoneClient.zone.signAuthorizationToken({ zoneId: 6 })

const chainId = await zoneClient.getChainId()
if (chainId !== zoneClient.chain.id) throw new Error('Zone chain ID does not match the client.')

const blockNumber = await zoneClient.getBlockNumber()
console.log(blockNumber)
```

For browser integrations, the Zone RPC gateway must allow `X-Authorization-Token` in its CORS headers. The shared testnet gateways don't currently allow that header in browsers. These demos relay requests through the docs server instead. The relay preserves your signed token and account-scoped access.

<a id="direct-connection-details" />

<span id="legacy-testnet-connection-details" />

## Sandbox Connection Details

### Zone A

| **Property** | **Value** |
|-------------------|-------|
| **Network Name** | Zone A |
| **Zone ID** | `6` |
| **Chain ID** | `4217000006` |
| **HTTP URL** | `https://rpc-zone-a.testnet.tempo.xyz` |
| **Portal Address** | `0x7069DeC4E64Fd07334A0933eDe836C17259c9B23` |
| **Outbox Address** | `0x1c00000000000000000000000000000000000002` |

### Zone B

| **Property** | **Value** |
|-------------------|-------|
| **Network Name** | Zone B |
| **Zone ID** | `7` |
| **Chain ID** | `4217000007` |
| **HTTP URL** | `https://rpc-zone-b.testnet.tempo.xyz` |
| **Portal Address** | `0x3F5296303400B56271b476F5A0B9cBF74350D6Ac` |
| **Outbox Address** | `0x1c00000000000000000000000000000000000002` |

Zones don't expose a public block explorer for private activity. Use authenticated Zone RPC reads instead.

## Related

[Deposit OUSD](https://tempo.com/developers/docs/guide/private-zones/deposit-to-a-zone): Use for moving testnet OUSD from Tempo into a Zone A balance.

[Connect to a Zone](https://tempo.com/developers/docs/zones/connect): Use for connecting your application to a current Zone deployment.

[Testnet Sandbox](https://tempo.com/developers/docs/guide/private-zones): Covers the sandbox Zones, router deployment, and compatibility limits.

[RPC Reference](https://tempo.com/developers/docs/protocol/zones/rpc): Covers the authorization token format and the methods it scopes.
