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

# Configuration and providers

> Configure Tayho environments, API keys, RPC failover, and EIP-1193, viem, or ethers adapters.

# Configuration and providers

The client requires an environment and API key. A signer is needed only for writes. A chain reader
is optional because the API can perform the bounded preparation reads; direct RPC reads are useful
when an application wants to verify execution-critical state itself.

## Client options

| Option             |                         Required | Meaning                                                                                                   |
| ------------------ | -------------------------------: | --------------------------------------------------------------------------------------------------------- |
| `environment`      |                              Yes | `development` or `production`; must match API configuration                                               |
| `apiKey`           |                              Yes | Publishable browser key or server-only secret key                                                         |
| `apiUrl`           | Development: no; production: yes | HTTPS override; localhost HTTP is accepted for development. Production has no published default endpoint. |
| `signer`           |                       For writes | Narrow typed-data signer                                                                                  |
| `rpc`              |                               No | Native SDK RPC pool configuration                                                                         |
| `chainReader`      |                               No | Injected narrow reader; mutually exclusive with `rpc`                                                     |
| `fetch`            |                               No | Custom fetch implementation for API and native RPC                                                        |
| `webSocketFactory` |                               No | Custom WebSocket implementation for non-browser runtimes                                                  |

## Native RPC configuration

```ts theme={null}
import { createTayhoClient } from "@tayho/sdk";

const client = createTayhoClient({
  environment: "development",
  apiKey: "th_pk_example",
  rpc: {
    urls: [
      "https://your-managed-hyperevm-endpoint.example",
      "https://rpcs.chain.link/hyperevm/testnet",
    ],
    timeoutMs: 8_000,
    retryCount: 1,
    circuitCooldownMs: 30_000,
  },
});
```

The pool accepts one to eight unique HTTPS origins without URL userinfo. It retries across origins,
temporarily cools repeatedly failing origins, and disables an origin that reports the wrong chain
during verification.

Only these RPC methods are used:

* `eth_chainId`
* `eth_blockNumber`
* `eth_getBalance`
* `eth_call`
* `eth_getTransactionReceipt`

There is no generic request method, log scan, or transaction send.

## Browser EIP-1193

```ts theme={null}
import { createTayhoClient } from "@tayho/sdk";
import {
  createEip1193ChainReader,
  createEip1193Signer,
} from "@tayho/sdk/eip1193";

const provider = window.ethereum;
const client = createTayhoClient({
  environment: "development",
  apiKey: "th_pk_example",
  chainReader: createEip1193ChainReader(provider),
  signer: createEip1193Signer(provider),
});
```

The signer calls `eth_accounts` and `eth_signTypedData_v4`. It cannot ask the wallet to send a
transaction.

## viem

```ts theme={null}
import { createTayhoClient } from "@tayho/sdk";
import { createViemChainReader, createViemSigner } from "@tayho/sdk/viem";

const client = createTayhoClient({
  environment: "development",
  apiKey: "th_pk_example",
  chainReader: createViemChainReader(publicClient),
  signer: createViemSigner(walletClient),
});
```

## ethers v6

```ts theme={null}
import { createTayhoClient } from "@tayho/sdk";
import { createEthersChainReader, createEthersSigner } from "@tayho/sdk/ethers";

const client = createTayhoClient({
  environment: "development",
  apiKey: "th_pk_example",
  chainReader: createEthersChainReader(provider),
  signer: createEthersSigner(signer),
});
```

## Chain verification

The first `configuration()` call:

1. Reads the Tayho deployment from the API.
2. Verifies that its environment equals the requested environment.
3. Verifies the chain reader against the deployment chain when configured.
4. Rejects mismatched, malformed, or unavailable RPC origins with a `TayhoError`.

Do not catch a chain mismatch and continue with the same reader. Correct the environment or RPC
configuration.

## API keys

* Publishable keys (`th_pk_`) can be used in browsers only when origin restrictions and project
  quotas are appropriate.
* Secret keys (`th_sk_`) are server-only.
* Keys carry `read`, `realtime`, and/or `actions:submit` scopes.
* Revoked, expired, suspended, wrong-origin, wrong-CIDR, or wrong-scope keys fail closed.

The client never sends configured RPC URLs to Tayho. It does send the API key on every HTTP request
and uses a short-lived single-use ticket for WebSocket authentication.
