Prerequisites
- Node.js 18+
- TypeScript 5+
- Viem 2+
Install packages
npm install @cofhe/sdk@^0.5.2 @fhenixprotocol/cofhe-contracts@^0.1.3
| Package | Version | Purpose |
|---|
@cofhe/sdk | ^0.5.2 | Client-side encryption, decryption, and permit management |
@fhenixprotocol/cofhe-contracts | ^0.1.3 | FHE.sol — the Solidity library imported by your contracts |
@fhenixprotocol/cofhe-contracts@0.1.3 requires @cofhe/sdk version >= 0.5.1. Latest published is 0.5.2.
For Hardhat projects
If you are using Hardhat for development and testing, also install the plugin:
npm install @cofhe/hardhat-plugin@^0.5.2 @cofhe/sdk@^0.5.2 @fhenixprotocol/cofhe-contracts@^0.1.3
| Package | Version | Purpose |
|---|
@cofhe/hardhat-plugin | ^0.5.2 | Extends Hardhat with hre.cofhe, deploys mock contracts automatically |
@cofhe/sdk | ^0.5.2 | Client-side encryption, decryption, and permit management |
@fhenixprotocol/cofhe-contracts | ^0.1.3 | FHE.sol — the Solidity library imported by your contracts |
See the Hardhat Plugin Getting Started guide for configuration details.
For Foundry projects
If you are using Foundry for development and testing, install the Foundry plugin and its peer packages as dev dependencies:
npm install -D @cofhe/foundry-plugin@^0.5.2 @cofhe/mock-contracts@^0.5.2 @fhenixprotocol/cofhe-contracts@^0.1.3 @openzeppelin/contracts
forge install foundry-rs/forge-std
| Package | Version | Purpose |
|---|
@cofhe/foundry-plugin | ^0.5.2 | CofheTest and CofheClient — Solidity test base and per-user SDK shim |
@cofhe/mock-contracts | ^0.5.2 | Mock CoFHE contracts used by the Foundry plugin |
@fhenixprotocol/cofhe-contracts | ^0.1.3 | FHE.sol — the Solidity library imported by your contracts |
The Foundry plugin uses Solidity-only abstractions — no @cofhe/sdk (JS) needed for tests.
See the Foundry Plugin Getting Started guide for foundry.toml and remappings.txt setup.
Runtime entrypoints
Import from the entrypoint that matches your runtime:
// Browser apps (React, Next.js, etc.)
import { createCofheConfig, createCofheClient } from '@cofhe/sdk/web';
// Node.js scripts, backends, Hardhat tests
import { createCofheConfig, createCofheClient } from '@cofhe/sdk/node';
// Shared types (works in any runtime)
import { Encryptable, FheTypes } from '@cofhe/sdk';
Next steps