Skip to main content
This page covers the core SDK lifecycle:
  1. Create config (createCofheConfig)
  2. Create client (createCofheClient)
  3. Connect (client.connect)
  4. Manage connection (change account / disconnect)

1. Create config

Import createCofheConfig from the entrypoint that matches your runtime:
  • Browser apps: @cofhe/sdk/web
  • Node.js scripts/backends: @cofhe/sdk/node
The only required field is supportedChains.

2. Create the client

3. Connect

The SDK connects to CoFHE using viem clients:
  • PublicClient: read-only chain access
  • WalletClient: signing + sending transactions
If you already have viem clients, pass them directly.

Using adapters

If you use a different wallet/provider stack, @cofhe/sdk/adapters provides adapters that convert into viem-shaped clients.

4. Managing connections

Reconnect behavior

Calling connect again with the same clients is a no-op. Calling it with new clients replaces the connection state.

Changing connected account

To switch the client’s connected account, call cofheClient.connect() with updated viem clients.

Disconnecting

To manually disconnect, call cofheClient.disconnect(). This clears the in-memory connection state (clients/account/chainId) and marks the client as disconnected. It does not delete persisted permits or stored FHE keys.