Skip to main content
The plugin extends every Hardhat 3 connection with a cofhe namespace. There are three ways to create and connect a CofheClient from a test, in increasing order of control. cofhe.createClientWithBatteries(walletClient?) is the one-call setup. It:
  1. Creates a CoFHE config with environment: 'hardhat'.
  2. Creates a CofheClient.
  3. Connects it using the wallet client you pass (or the first wallet client on the connection if you don’t).
  4. Generates and signs a self permit so the client can immediately decrypt encrypted values.
Or call it with no arguments to use the first wallet client on the connection:
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, adjusting encryptDelay — 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.encryptDelay to 0 so tests run without artificial wait times.
2

Create the client

The client is not connected yet — call client.connect(...) before using it.
3

Connect with the connection's wallet client

API summary

Using the client

Once connected, the client works identically to the standard SDK client. See: