cofhe namespace. There are three ways to create and connect a CofheClient from a test, in increasing order of control.
Batteries included (recommended)
cofhe.createClientWithBatteries(walletClient?) is the one-call setup. It:
- Creates a CoFHE config with
environment: 'hardhat'. - Creates a
CofheClient. - Connects it using the wallet client you pass (or the first wallet client on the connection if you don’t).
- Generates and signs a self permit so the client can immediately decrypt encrypted values.
Because the self permit is created up-front, encrypt / decrypt / decryptForView / decryptForTx all work immediately without any additional setup.
Manual setup
For more control — custom config options, multiple signers, adjustingencryptDelay — set up the client step by step.
1
Create config
cofhe.createConfig wraps createCofheConfig from @cofhe/sdk/node with two Hardhat-3-specific additions:- Sets
environment: 'hardhat'automatically. - Defaults
mocks.encryptDelayto0so tests run without artificial wait times.
2
Create the client
client.connect(...) before using it.3
Connect with the connection's wallet client