Framework-agnostic, modular, and developer-friendly SDK for building confidential applications with Fully Homomorphic Encryption (FHE).
π Zama FHEVM Challenge Submission
π Live Example: https://fhe-evidence-manager.vercel.app/
π¦ GitHub Repository: https://github.com/KristofferSchuppe/fhevm-react-template
πΊ Demo Video: demo.mp4 (Download to watch - video player links may not work in all environments)
The FHEVM Toolkit provides a universal, framework-agnostic SDK that makes building confidential front-ends simple, consistent, and developer-friendly. Inspired by wagmi's intuitive design, our SDK works seamlessly across Node.js, Next.js, React, Vue, and any JavaScript environment.
Core Concept: FHE Contract Privacy Evidence Management - The toolkit includes a complete implementation of a confidential judicial evidence system that demonstrates real-world FHE usage with role-based access control, secure evidence submission, and cryptographic privacy guarantees.
Key Features:
- π― Framework-Agnostic: Works with any frontend setup (Next.js, React, Vue, Node.js)
- π¦ All-in-One Package: Wraps all required dependencies - no scattered packages
- πͺ Wagmi-Like API: Intuitive hooks and modular structure for React developers
- π <10 Lines to Start: Minimal boilerplate, maximum productivity
- π Complete FHE Flow: Init, encrypt, decrypt, and permission management
- π Well-Documented: Clear examples and comprehensive guides
- π§ͺ Production-Ready: Tested, typed, and battle-tested
- βοΈ Real Use Case: FHE Evidence Manager - Confidential judicial evidence system
πΊ Demo Video: demo.mp4
Important: Download the video file to watch. Video player links may not work in all environments.
The video showcases:
- SDK installation and setup (<10 lines of code)
- Next.js integration with React hooks
- FHE Evidence Manager example
- Encryption and decryption workflow
- Multi-framework support demonstration
npm installnpm run buildChoose your preferred framework and get started:
# Next.js template
cd templates/nextjs
npm install
npm run dev
# React template
cd templates/react
npm install
npm run dev
# Vue template
cd templates/vue
npm install
npm run dev
# Node.js template
cd templates/nodejs
npm install
npm run dev# Next.js example
npm run dev:nextjs
# Privacy Evidence Manager
npm run dev:evidenceimport { FhevmClient } from '@fhevm-toolkit/sdk';
// 3 lines to initialize
const client = new FhevmClient({ provider, signer, chainId: 11155111 });
await client.init();
// 1 line to encrypt
const encrypted = await client.encryptInput({ value: 42, type: 'uint32', contractAddress: CONTRACT_ADDRESS });
// Done! β
fhevm-toolkit/
βββ packages/
β βββ fhevm-sdk/ # π₯ Universal SDK Package
β βββ src/
β β βββ core/ # Core FhevmClient, encryption, decryption
β β βββ adapters/ # Framework adapters (React hooks)
β β βββ utils/ # Contract helpers, validation
β β βββ types/ # TypeScript definitions
β β βββ config/ # Network configurations
β βββ dist/ # Built package
β βββ README.md # SDK documentation
β
βββ templates/ # π¨ Framework Templates
β βββ nextjs/ # Next.js 14 template
β β βββ src/
β β β βββ app/ # App Router with API routes
β β β βββ components/ # UI and FHE components
β β β βββ lib/ # FHE integration library
β β β βββ hooks/ # Custom React hooks
β β β βββ types/ # TypeScript types
β β βββ README.md
β β
β βββ react/ # React + Vite template
β β βββ src/
β β β βββ components/ # React components
β β β βββ hooks/ # FHE hooks
β β βββ README.md
β β
β βββ vue/ # Vue 3 template
β β βββ src/
β β β βββ components/ # Vue components
β β β βββ composables/ # FHE composables
β β βββ README.md
β β
β βββ nodejs/ # Node.js template
β βββ src/ # Main application
β βββ examples/ # Usage examples
β βββ README.md
β
βββ examples/
β βββ nextjs-fhe-integration/ # π± Complete Next.js example
β β βββ src/app/ # Next.js 14 App Router
β β βββ src/components/ # FHE & UI components
β β βββ src/lib/ # FHE integration library
β β βββ src/hooks/ # Custom React hooks
β β βββ README.md
β β
β βββ nextjs-evidence-manager/ # π± Next.js + RainbowKit example
β β βββ app/ # Next.js 14 App Router
β β βββ lib/ # SDK integration
β β βββ README.md
β β
β βββ privacy-evidence-manager/# π Smart Contract + React Example
β βββ contracts/ # Solidity contracts
β βββ scripts/ # Deploy & interact scripts
β βββ test/ # 77 tests (92.45% coverage)
β βββ src/ # React frontend
β βββ README.md
β
βββ docs/ # π Documentation
β βββ SDK_GUIDE.md # Complete SDK guide
β βββ INTEGRATION.md # Framework integration examples
β βββ API_REFERENCE.md # API documentation
β βββ DEPLOYMENT.md # Deployment guide
β
βββ demo.mp4 # π¬ Video demonstration
βββ package.json # Monorepo configuration
βββ README.md # This file
FhevmClient - Main class for FHEVM operations
const client = new FhevmClient({ provider, signer, chainId });
await client.init();Encryption - Type-safe encryption utilities
const encrypted = await client.encryptInput({
value: 100,
type: 'uint64',
contractAddress: CONTRACT_ADDRESS
});Decryption - User and public decryption
const permission = await client.generatePermissionSignature(CONTRACT_ADDRESS);React Hooks - Wagmi-like hooks (optional)
const { client, isInitialized } = useFhevmClient({ provider, signer, chainId });
const { encrypt, isEncrypting } = useEncrypt(client);Complete Next.js 14 templates with App Router, API routes, and SDK integration.
Templates Available:
templates/nextjs/- Base Next.js templateexamples/nextjs-fhe-integration/- Full FHE integration exampleexamples/nextjs-evidence-manager/- Evidence manager app
'use client';
import { useFhevmClient, useEncrypt } from '@fhevm-toolkit/sdk';
export default function Page() {
const { client, isInitialized } = useFhevmClient({
provider,
signer,
chainId: 11155111
});
const { encrypt } = useEncrypt(client);
const handleSubmit = async (value: number) => {
const result = await encrypt({
value,
type: 'uint64',
contractAddress: CONTRACT_ADDRESS
});
// Use result in contract call
};
return <div>{/* UI */}</div>;
}Features:
- β App Router with API routes
- β FHE Provider & Components
- β Custom hooks (useFHE, useEncryption, useComputation)
- β TypeScript & Tailwind CSS
React 18 + Vite template with SDK integration.
Location: templates/react/
Features:
- β Vite for fast development
- β FHE hooks and components
- β TypeScript support
- β Modern CSS styling
Vue 3 Composition API template with SDK integration.
Location: templates/vue/
<script setup lang="ts">
import { useFHE } from '@/composables/useFHE';
const { client, isInitialized, initializeFHE } = useFHE();
const handleEncrypt = async () => {
const result = await client.value.encryptInput({
value: 100,
type: 'uint64',
contractAddress: CONTRACT_ADDRESS
});
};
</script>Features:
- β Vue 3 Composition API
- β FHE composables
- β TypeScript support
- β Vite build system
Server-side Node.js/TypeScript template with multiple examples.
Location: templates/nodejs/
import { FhevmClient } from '@fhevm-toolkit/sdk';
async function main() {
const client = new FhevmClient({ provider, signer, chainId: 11155111 });
await client.init();
const encrypted = await client.encryptInput({
value: 100,
type: 'uint64',
contractAddress: CONTRACT_ADDRESS
});
console.log('Encrypted:', encrypted);
}
main();Features:
- β TypeScript with tsx
- β Environment configuration
- β Multiple usage examples
- β Production-ready setup
Location: examples/nextjs-fhe-integration/
Features:
- β Next.js 14 with App Router
- β Complete FHE Provider implementation
- β Encryption/Decryption demos
- β Homomorphic computation examples
- β Banking & Medical use cases
- β Key management interface
- β TypeScript + Tailwind CSS
Run:
cd examples/nextjs-fhe-integration
npm install
npm run devLocation: examples/nextjs-evidence-manager/
Features:
- β Next.js 14 with App Router
- β RainbowKit wallet integration
- β Wagmi + FHEVM SDK hooks
- β Tailwind CSS styling
- β Real-time encryption demo
- β Confidential judicial evidence system
Run:
npm run dev:nextjsLive Demo: https://fhe-evidence-manager.vercel.app/
Location: examples/privacy-evidence-manager/
Features:
- β Hardhat smart contract project
- β React frontend with Vite
- β FHEVM SDK integration
- β 77 tests with 92.45% coverage
- β Sepolia deployment
- β Role-based access control
- β Confidential judicial evidence management
Run:
cd examples/privacy-evidence-manager
npm install
npm run compile # Compile contracts
npm test # Run tests
npm run frontend # Run React frontend
npm run deploy # Deploy to SepoliaDeployed Contract: 0x2BB2Eed0a66d74D92897aFAADa41a988E50C1830
GitHub: https://github.com/KristofferSchuppe/FHEEvidenceManager
- SDK Guide - Complete SDK reference
- API Reference - Full API documentation
- Integration Guide - Framework integration examples
- TypeScript Types - Type definitions
- Next.js Template - Next.js 14 template guide
- React Template - React + Vite template guide
- Vue Template - Vue 3 template guide
- Node.js Template - Node.js/TypeScript template guide
- Next.js FHE Integration - Complete Next.js FHE example
- Next.js Evidence Manager - Next.js setup guide
- Privacy Evidence Manager - Smart contract + React example
- Deployment Guide - Deploy to Sepolia/Mainnet
- Security Best Practices - Security guidelines
- Troubleshooting - Common issues
const client = new FhevmClient({
provider: ethersProvider,
signer: ethersSigner,
chainId: 11155111,
gatewayUrl: 'https://gateway.fhevm.io', // Optional
aclAddress: '0x...' // Optional
});
await client.init(); // Fetches public key, ready to use// Supported types: bool, uint8, uint16, uint32, uint64, uint128, uint256, address
const encrypted = await client.encryptInput({
value: 42,
type: 'uint32',
contractAddress: CONTRACT_ADDRESS
});
// Use in contract
const tx = await contract.submitValue(encrypted.handles[0], encrypted.inputProof);// Generate EIP-712 signature for decryption
const permission = await client.generatePermissionSignature(CONTRACT_ADDRESS);
console.log(permission.signature); // Use for decryption
console.log(permission.publicKey); // Public keyimport {
encryptBool,
encryptUint32,
encryptUint64,
encryptBatch,
validateAddress,
createContract
} from '@fhevm-toolkit/sdk';
// Type-specific helpers
const boolResult = await encryptBool(client, true, CONTRACT_ADDRESS);
const uint32Result = await encryptUint32(client, 100, CONTRACT_ADDRESS);
// Batch operations
const results = await encryptBatch(client, [
{ value: true, type: 'bool', contractAddress: CONTRACT_ADDRESS },
{ value: 42, type: 'uint32', contractAddress: CONTRACT_ADDRESS }
]);// Initialize client
const { client, isInitialized, error } = useFhevmClient({ provider, signer, chainId });
// Encryption hook
const { encrypt, isEncrypting } = useEncrypt(client);
// Permission hook
const { generatePermission, isGenerating } = usePermission(client);
// State hooks
const state = useFhevmState(client);
const publicKey = usePublicKey(client);cd packages/fhevm-sdk
npm testcd examples/privacy-evidence-manager
npm test
# Results
β 77 tests passing
β 92.45% statement coverage
β 95.83% function coverage
β 95.4% line coverage- FHE Evidence Manager: https://fhe-evidence-manager.vercel.app/
- FHE Evidence Manager Contract:
0x2BB2Eed0a66d74D92897aFAADa41a988E50C1830(Sepolia) - Verified on Etherscan: β Yes
- FHEVM Toolkit: https://github.com/KristofferSchuppe/fhevm-react-template
- FHE Evidence Manager: https://github.com/KristofferSchuppe/FHEEvidenceManager
- Video Demo:
demo.mp4(Download to watch - included in repo)
- <10 lines to start: Minimal boilerplate
- Clear API: Wagmi-like structure, familiar to web3 devs
- TypeScript support: Full type definitions
- Error handling: Comprehensive error types
- Full FHE flow: Init β Encrypt β Decrypt β Permissions β
- Contract interaction: Helpers for contract calls
- Batch operations: Encrypt multiple values
- Permission signatures: EIP-712 implementation
- Framework-agnostic core: Works everywhere
- Modular architecture: Import only what you need
- React adapter: Optional hooks for React apps
- Clean utilities: Validation, contract helpers
- Comprehensive guides: 5+ documentation files
- Code examples: Next.js, Node.js, Vue examples
- API reference: Full TypeScript documentation
- Video demo: Complete walkthrough
- Multi-environment: Next.js β Node.js β (Vue ready)
- Real use case: Privacy Evidence Manager
- Production-ready: 77 tests, 92.45% coverage
- Developer experience: CLI-friendly, minimal setup
npm run install:allnpm run build# Next.js example
npm run dev:nextjs
# Evidence Manager
npm run dev:evidencenpm run clean
npm installπ¦ fhevm-toolkit (this repo)
βββ π¦ packages/fhevm-sdk/ Universal SDK package
βββ π¨ templates/ Framework templates
β βββ nextjs/ Next.js 14 template
β βββ react/ React + Vite template
β βββ vue/ Vue 3 template
β βββ nodejs/ Node.js template
βββ π± examples/ Example applications
β βββ nextjs-fhe-integration/ Complete Next.js FHE example
β βββ nextjs-evidence-manager/ Next.js + RainbowKit example
β βββ privacy-evidence-manager/ Smart contract + React example
βββ π docs/ Complete documentation
βββ π¬ demo.mp4 Video demonstration
βββ π package.json Monorepo config
βββ π README.md This file
βββ π LICENSE MIT License
Contributions welcome! This is an open-source project built for the Zama FHEVM Challenge.
How to contribute:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
This project builds on:
- Zama - FHE technology and fhevmjs library
- fhevm-react-template - Original template (forked)
- wagmi - API design inspiration
- Hardhat - Development framework
- ethers.js - Ethereum library
Submission Details:
- Challenge: Universal FHEVM SDK
- Deliverables:
- β
Universal SDK package (
@fhevm-toolkit/sdk) - β Next.js example application
- β Privacy Evidence Manager example
- β Complete documentation
- β
Video demonstration (
demo.mp4) - β Deployed contracts and live demos
- β
Universal SDK package (
GitHub Repository: https://github.com/KristofferSchuppe/fhevm-react-template
Live Demo: https://fhe-evidence-manager.vercel.app/
Forked From: fhevm-react-template
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Complete Docs
Built with π for Zama FHEVM Challenge
Making confidential computing simple, consistent, and developer-friendly
Status: β Complete - Ready for Evaluation