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

# Overview

> Introduction to @cofhe/sdk - the TypeScript client SDK for building FHE-enabled applications on Fhenix

`@cofhe/sdk` is the TypeScript client SDK for [CoFHE](/deep-dive/cofhe-components/overview). It handles the client-side operations required to interact with FHE-enabled smart contracts: encrypting inputs with ZK proofs, decrypting ciphertext handles via the Threshold Network, and managing EIP-712 permits for access control.

On-chain, contracts use [`FHE.sol`](/fhe-library/introduction/overview) to operate on encrypted data. Off-chain, this SDK prepares the inputs and reads the outputs.

## What the SDK does

<CardGroup cols={2}>
  <Card title="Encrypt Inputs" icon="lock">
    Packs plaintext values, generates a ZKPoK, and submits them to the CoFHE verifier. Returns signed EncryptedItemInput objects for use in contract calls.
  </Card>

  <Card title="Decrypt for View" icon="eye">
    Requests decryption of a ciphertext handle via the Threshold Network using a permit. Returns the plaintext locally, not published on-chain.
  </Card>

  <Card title="Decrypt for Tx" icon="arrow-right-arrow-left">
    Requests decryption and returns the plaintext with a Threshold Network signature for on-chain verification.
  </Card>

  <Card title="Manage Permits" icon="id-card">
    Creates, stores, and manages EIP-712 permits that authorize decryption of specific ciphertext handles.
  </Card>
</CardGroup>

## Entrypoints

| Entrypoint            | Contents                                                                                                    |
| --------------------- | ----------------------------------------------------------------------------------------------------------- |
| `@cofhe/sdk`          | Core types (`Encryptable`, `FheTypes`, `EncryptStep`, `CofheError`), shared across runtimes                 |
| `@cofhe/sdk/web`      | `createCofheConfig` / `createCofheClient` with browser defaults (IndexedDB storage, TFHE WASM, Web Workers) |
| `@cofhe/sdk/node`     | `createCofheConfig` / `createCofheClient` with Node.js defaults (filesystem storage, `node-tfhe`)           |
| `@cofhe/sdk/permits`  | Permit creation, validation, serialization, and storage utilities                                           |
| `@cofhe/sdk/adapters` | `Ethers5Adapter`, `Ethers6Adapter`, `WagmiAdapter`, `HardhatSignerAdapter`                                  |
| `@cofhe/sdk/chains`   | Built-in chain definitions and `getChainById` / `getChainByName` helpers                                    |

```typescript theme={null}
// Browser
import { createCofheConfig, createCofheClient } from '@cofhe/sdk/web';

// Node.js
import {
  createCofheConfig as createCofheConfigNode,
  createCofheClient as createCofheClientNode,
} from '@cofhe/sdk/node';

// Shared
import { Encryptable, FheTypes } from '@cofhe/sdk';
import { chains } from '@cofhe/sdk/chains';
import { Ethers6Adapter } from '@cofhe/sdk/adapters';
```

## Client lifecycle

The SDK follows a three-step lifecycle: **config → client → connect**.

```
createCofheConfig({ supportedChains }) → createCofheClient(config) → client.connect(publicClient, walletClient)
```

```typescript theme={null}
import { createCofheConfig, createCofheClient } from '@cofhe/sdk/web';
import { Encryptable, FheTypes } from '@cofhe/sdk';
import { chains } from '@cofhe/sdk/chains';

const config = createCofheConfig({
  supportedChains: [chains.sepolia],
});
const client = createCofheClient(config);
await client.connect(publicClient, walletClient);

// Encrypt and send
const [encrypted] = await client
  .encryptInputs([Encryptable.uint64(100n)])
  .execute();
await contract.deposit(encrypted);

// Decrypt for UI
await client.permits.getOrCreateSelfPermit();
const ctHash = await contract.getBalance();
const balance = await client
  .decryptForView(ctHash, FheTypes.Uint64)
  .execute();
```

## Key concepts

<CardGroup cols={2}>
  <Card title="Quick Start" icon="rocket" href="/client-sdk/quick-start">
    Install the SDK, write a contract, and run your first encrypt → store → decrypt test in minutes.
  </Card>

  <Card title="Encrypting Inputs" icon="lock" href="/client-sdk/guides/encrypting-inputs">
    Encrypt plaintext values with ZK proofs before passing them to your smart contract.
  </Card>

  <Card title="Permits" icon="id-card" href="/client-sdk/guides/permits">
    Create and manage EIP-712 permits that authorize decryption of confidential data.
  </Card>

  <Card title="Decrypt to View" icon="eye" href="/client-sdk/guides/decrypt-to-view">
    Reveal encrypted values locally for UI display using permits.
  </Card>

  <Card title="Decrypt to Transact" icon="arrow-right-arrow-left" href="/client-sdk/guides/decrypt-to-tx">
    Decrypt with a verifiable Threshold Network signature for on-chain use.
  </Card>
</CardGroup>
