- Create config (
createCofheConfig) - Create client (
createCofheClient) - Connect (
client.connect) - Manage connection (change account / disconnect)
1. Create config
ImportcreateCofheConfig from the entrypoint that matches your runtime:
- Browser apps:
@cofhe/sdk/web - Node.js scripts/backends:
@cofhe/sdk/node
supportedChains.
2. Create the client
3. Connect
The SDK connects to CoFHE using viem clients:PublicClient: read-only chain accessWalletClient: signing + sending transactions
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
Callingconnect 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, callcofheClient.connect() with updated viem clients.
Disconnecting
To manually disconnect, callcofheClient.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.