This repository contains example dApps built using fhEVM (Fully Homomorphic EVM). Each example demonstrates different aspects of building privacy-preserving smart contracts using FHE operations.
This repository has a monorepo structure with the following components:
dapps/
├── packages/
│ ├── hardhat/ # Smart contracts & deployment examples
│ ├── fhevm-sdk/ # FHEVM SDK package
│ └── erc7984example/ # React erc7984 example application
└── scripts/ # Build and deployment scripts
The ./packages/hardhat folder contains several privacy-preserving smart contract examples:
- Encryption/Decryption - Examples of encrypting and decrypting values
- FHE Operators - Basic homomorphic operations like addition and conditional logic
- User Decrypt - User-side decryption examples
- Public Decrypt - Public on-chain decryption capabilities
- FHE Wordle - Privacy-preserving word guessing game using encrypted letter comparisons
- Confidential Auctions - Multiple auction implementations with encrypted bids:
- Blind auctions with sealed bids
- Dutch auctions with descending prices
- Confidential Token Example - Mock confidential token for testing
- ERC20 Wrapper - Wrapper for standard ERC20 tokens
- ETH Wrapper - Wrapper for native ETH
- Faucet Contract - Test token distribution contract
- Mock USDZ - Mock stablecoin implementation
- Prize Item - Mock NFT-like contract
Each example includes detailed documentation in its respective README explaining the implementation and FHE usage.
The ./packages/erc7984example directory contains a simple React-based frontend that demonstrates interacting with an ERC7984 confidential token smart contract using the fhEVM SDK.
Features:
- Uses OpenZeppelin's confidential smart contract library.
- Connect your Ethereum wallet (e.g., via MetaMask).
- Mint, transfer, and check balances of ERC7984 confidential tokens, all using fully homomorphic encryption under the hood.
- Perform transactions with strong privacy guarantees: amounts and balances remain encrypted on-chain.
- User-friendly interface to experiment with confidential token operations.
# Clone the repository
git clone <repository-url>
cd dapps
# Install dependencies
pnpm installSet 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 run startOption B: Sepolia Testnet
# Deploy to Sepolia testnet
pnpm deploy:sepolia
# Start the frontend
pnpm run start- 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
- In production,
NEXT_PUBLIC_ALCHEMY_API_KEYmust be set (seepackages/erc7984example/scaffold.config.ts). The app throws if missing. - Ensure
packages/erc7984example/contracts/deployedContracts.tspoints to your live contract addresses. - Optional: set
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_IDfor better WalletConnect reliability. - Optional: add per-chain RPCs via
rpcOverridesinpackages/erc7984example/scaffold.config.ts.
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.
This repository serves as a comprehensive example of building privacy-preserving dApps with fhEVM. Feel free to explore the examples, run the tests, and use them as a foundation for your own projects.
This project is licensed under the BSD-3-Clause-Clear License. See the LICENSE file for details.