A unified monorepo for building decentralized applications powered by Fully Homomorphic Encryption (FHE) using the FHEVM (Fully Homomorphic Encryption Virtual Machine). It includes SDKs, shared contract artifacts, and example apps across multiple frameworks - all demonstrating private computation on encrypted blockchain data.
📖 View Complete Documentation & Demo Examples
For detailed guides, API references, and interactive examples, visit our comprehensive documentation site.
FHEVM extends Ethereum to support computation directly on encrypted data, enabling true on-chain privacy. With FHEVM, smart contracts can operate on ciphertexts without ever decrypting them - preserving user confidentiality while maintaining public verifiability.
This SDK simplifies integrating FHEVM into React, Vue, Node.js, or Next.js environments.
- Universal SDK - A single SDK that works across multiple environments, including React, Node.js, Next.js, and Vue.
- FHEVM Integration - Provides native support for Fully Homomorphic Encryption (FHE) smart contracts.
- @fhevm/shared Package - Contains common TypeScript types, ABIs, and utility functions shared across all framework packages.
- Modular Architecture - Each framework (React, Node.js, Next.js, Vue) is organized as a separate package for clean isolation and easier maintenance.
- Hardhat Template - Includes a preconfigured Hardhat setup based on the fhevm-hardhat-template for writing and deploying FHE contracts.
- Cross-Framework Examples - Provides reference implementations for:
- Node.js (backend interaction)
- React (frontend interaction)
- Next.js (full-stack example)
- Vue (frontend interaction)
fhevm-universal-sdk/
|
├── docs/ # Vitepress docs
├── packages/
│ ├── fhevm-sdk/ # Core SDK (encryption, decryption, FHEVM tools)
│ ├── fhevm-react/ # React hooks + providers
│ ├── fhevm-node-demo/ # Node.js demo using FHEVM contracts
│ ├── fhevm-vue-demo/ # Vue demo app
│ ├── fhevm-next-demo/ # Next.js demo app
│ ├── fhevm-shared/ # Shared contracts, ABIs, types
│ └── hardhat/ # Contract deployment & Hardhat environment
└── scripts/
└── generateAbis.ts # Generates shared ABI JSON from compiled contracts
Before you begin, ensure you have:
- Node.js (v18 or higher)
- pnpm package manager
- MetaMask browser extension
- Git for cloning the repository
- Infura / Alchemy key (for testnet RPCs)
# Clone the repository
git clone <repository-url>
cd fhevm-react-template
# Initialize submodules (includes fhevm-hardhat-template)
git submodule update --init --recursive
# Install dependencies
pnpm installOnce the submodules are synced, go to the contracts directory and write or modify your own FHE smart contracts (e.g. FHECounter.sol).
Set up your Hardhat environment variables by following the FHEVM documentation:
MNEMONIC: Your wallet mnemonic phraseINFURA_API_KEY: Your Infura API key for Sepolia
Option A: Local Development (Recommended for testing)
# Terminal 1: Start local Hardhat node
pnpm chain
# RPC URL: http://127.0.0.1:8545 | Chain ID: 31337
# Terminal 2: Deploy contracts to localhost
pnpm deploy:localhost
# Terminal 3: Start the frontend
pnpm startOption B: Sepolia Testnet
# Deploy to Sepolia testnet
pnpm deploy:sepolia
# Start the frontend
pnpm startOnce deployment is successful, generate the shared ABI file that both your backend (Node) and frontend (React) will use.
pnpm generateThis will produce a JSON file (e.g. abis.json) in the shared directory:
{
"deployedContracts": {
"11155111": {
"FHECounter": {
"address": "0xYourContractAddress",
"abi": [ ... ]
}
}
}
}
- Open http://localhost:3000 in your browser
- Click "Connect Wallet" and select MetaMask
- If using localhost, add the Hardhat network to MetaMask:
- Network Name: Hardhat Local
- RPC URL:
http://127.0.0.1:8545 - Chain ID:
31337 - Currency Symbol:
ETH
When developing with MetaMask and Hardhat, you may encounter these common issues:
Problem: MetaMask tracks transaction nonces, but when you restart Hardhat, the node resets while MetaMask doesn't update its tracking.
Solution:
- Open MetaMask extension
- Select the Hardhat network
- Go to Settings → Advanced
- Click "Clear Activity Tab" (red button)
- This resets MetaMask's nonce tracking
Problem: MetaMask caches smart contract view function results. After restarting Hardhat, you may see outdated data.
Solution:
- Restart your entire browser (not just refresh the page)
- MetaMask's cache is stored in extension memory and requires a full browser restart to clear
💡 Pro Tip: Always restart your browser after restarting Hardhat to avoid cache issues.
For more details, see the MetaMask development guide.
For detailed guides, API references, and interactive examples, visit our comprehensive documentation site.