A framework-agnostic frontend toolkit that helps developers run confidential dApps with ease. Built for the Zama Developer Program October 2025 Bounty Track.
- π End-to-End Encryption: Secure encryption and decryption of sensitive data
- β‘ Framework Agnostic: Works with React, Vue, Node.js, and any frontend setup
- π― Wagmi-like API: Intuitive structure familiar to web3 developers
- π‘οΈ Production Ready: Built on Zama's official FHEVM infrastructure
- π¦ Multiple Examples: Next.js, Vue, and Node.js implementations
- π§ͺ Comprehensive Testing: Full test coverage and CI/CD pipeline
packages/fhevm-sdk/- Enhanced SDK with universal featurespackages/nextjs/- Enhanced Next.js application with modern UIpackages/vue-example/- Vue 3 example with Composition APIpackages/node-example/- Node.js server-side examplepackages/hardhat/- Smart contracts and deployment
- Node.js (v20 or higher)
- pnpm package manager
- MetaMask browser extension (for frontend examples)
- Git for cloning the repository
# Clone the repository
git clone <repository-url>
cd fhevm-react-template
# Initialize submodules
git submodule update --init --recursive
# Install dependencies
pnpm installSet up your environment variables:
# .env file
MNEMONIC=your_wallet_mnemonic_phrase
INFURA_API_KEY=your_infura_api_key# Start local Hardhat node
pnpm chain
# Deploy contracts to localhost
pnpm deploy:localhost
# Start the Next.js frontend
pnpm start# Start Vue development server
pnpm start:vue# Run Node.js example
pnpm start:nodeWe added shortcuts to get the repo running quickly on a fresh machine.
# Runs install, builds SDK, starts a local Hardhat chain, and deploys contracts
pnpm quick-start
# Run a minimal e2e smoke test (builds, starts chain, deploys, runs smoke, tears down)
pnpm smokeIf you need details about how the relayer runtime is provided, see docs/RELAYER_RUNTIME.md.
import { createFHEVM } from '@fhevm-sdk/universal';
import { BrowserProvider } from 'ethers';
// Initialize FHEVM
const fhevm = createFHEVM('ethers');
await fhevm.initialize({
chainId: 1,
provider: new BrowserProvider(window.ethereum),
});
// Encrypt data
const encrypted = await fhevm.encrypt('Hello FHEVM!');
// Decrypt data (with automatic retry on failure)
const decrypted = await fhevm.decrypt(encrypted);
console.log(decrypted.value); // 'Hello FHEVM!'
// Batch operations for efficiency
const encryptedBatch = await fhevm.encryptBatch(['data1', 'data2', 'data3']);
const decryptedBatch = await fhevm.decryptBatch(encryptedBatch);import { useFHEVM } from '@fhevm-sdk/react';
function MyComponent() {
const { initialize, encrypt, decrypt, instance } = useFHEVM();
// Use the SDK...
}<script setup>
import { useFHEVM } from '@fhevm-sdk/vue';
import { BrowserProvider } from 'ethers';
const {
isInitialized,
isLoading,
error,
initialize,
encrypt,
decrypt,
encryptBatch,
decryptBatch
} = useFHEVM('ethers');
// Initialize on mount
onMounted(async () => {
await initialize({
chainId: 1,
provider: new BrowserProvider(window.ethereum),
});
});
</script>import { createFHEVM } from '@fhevm-sdk/universal';
const fhevm = createFHEVM('ethers');
await fhevm.initialize({
chainId: 1,
provider: new JsonRpcProvider('https://eth-mainnet.g.alchemy.com/v2/demo'),
});The SDK now includes:
- Universal Core: Framework-agnostic core functionality
- Provider Support: Both Ethers.js and Viem support
- TypeScript First: Full type safety and excellent developer experience
- Error Handling: Comprehensive error handling with custom types
- Utilities: Helper functions for validation and formatting
- React: Hooks, context, and pre-built components
- Vue: Composables and reactive state management
- Node.js: Server-side encryption/decryption utilities
- Modern UI: Beautiful, responsive design with Tailwind CSS
- Wallet Integration: RainbowKit for seamless wallet connection
- Live Demo: Real-time encryption/decryption demonstration
- FHECounter Contract: Interactive contract example
- Vue 3 Composition API: Modern Vue.js implementation
- Reactive State: Full reactivity with Vue's reactivity system
- Component-based: Modular component architecture
- Server-side Encryption: Complete server-side implementation
- Batch Operations: Batch encryption/decryption examples
- CLI Interface: Command-line interface for testing
# Build all packages
pnpm build
# Build specific package
pnpm sdk:build# Run tests
pnpm test
# Run SDK tests
pnpm sdk:test# Lint all packages
pnpm lint- Next.js: Deploy to Vercel, Netlify, or any static hosting
- Vue: Deploy to Vercel, Netlify, or any static hosting
- Railway: Serverless deployment
- Heroku: Traditional deployment
- Docker: Container deployment
Initializes the FHEVM instance with the provided configuration.
Encrypts a value and returns the encrypted data with signature.
Decrypts an encrypted value and returns the original data.
Retrieves the public key for encryption.
Signs a message using the connected wallet.
interface FHEVMConfig {
chainId: number;
publicClient?: PublicClient; // For Viem
walletClient?: WalletClient; // For Viem
provider?: BrowserProvider; // For Ethers
relayerUrl?: string; // Optional relayer
contractAddress?: string; // Contract address
}- Unit Tests: Comprehensive unit test coverage
- Integration Tests: Cross-package integration tests
- Example Tests: All examples are tested
- Error Tests: Error condition testing
# Run all tests
pnpm test
# Run specific package tests
pnpm sdk:test
pnpm hardhat:test- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
See CONTRIBUTING.md for detailed guidelines.
This project is licensed under the BSD-3-Clause-Clear License. See the LICENSE file for details.
- Built for the Zama Developer Program October 2025 Bounty Track
- Based on Zama's official FHEVM infrastructure
- Inspired by wagmi's excellent developer experience
Built with β€οΈ for the Zama Developer Program