create-fhevm-nextjs
v1.5.9
Published
Create a NextJS app with FHEVM SDK integration
Maintainers
Readme
create-fhevm-nextjs
A CLI to create a Next.js app with FHEVM SDK integration.
✨ Updated for FHEVM 0.9.1: This package now uses FHEVM 0.9.1 with the new self-relaying decryption pattern,
decryptMultipleHandlessupport,ZamaEthereumConfig,FHE.checkSignatures, and updated contract addresses on Sepolia testnet.
Usage
npx create-fhevm-nextjs my-app
cd my-app
npm install
npm run devEnvironment Setup
Before deploying contracts, you need to set up your environment variables:
1. Create a .env file in the hardhat directory:
cd hardhat
touch .env2. Add your environment variables to .env:
# Your wallet mnemonic (12 or 24 words)
MNEMONIC=your wallet mnemonic phrase here
# Your Infura API key (get one at https://infura.io)
INFURA_API_KEY=your_infura_api_key_here
# Optional: Etherscan API key for contract verification
ETHERSCAN_API_KEY=your_etherscan_api_key_here3. Get your Infura API key:
- Visit https://infura.io
- Sign up for a free account
- Create a new project
- Copy your project API key
4. Deploy your contracts:
# Deploy to Sepolia testnet
npm run deploy:sepoliaWhat you get
- Complete React application with FHEVM SDK integration
- Bundled FHEVM SDK (no external dependencies)
- Beautiful Zama-branded UI
- TypeScript support
- Tailwind CSS styling
- Working FHEVM operations (encryption, decryption, contract interactions)
- Three Complete FHE Contracts for testing on Sepolia testnet:
- FHECounter: Encrypted counter with increment/decrement
- ReviewCardsFHE: Encrypted rating system with public decryption
- SimpleVoting: Encrypted voting system with tally reveal
- Public decryption demo with hardcoded ciphertexts
- Ready-to-use React hooks
- Complete Hardhat development environment with:
- All three FHE smart contracts
- Deployment scripts for Sepolia testnet
- Contract testing utilities
- TypeScript support for contracts
- Universal FHEVM SDK (FHEVM 0.9.1) with utilities for:
- FHEVM initialization
- Encrypted inputs creation
- User decryption with EIP-712 signing
- Public decryption flows
decryptMultipleHandlesfor batch decryption with proofs- Self-relaying decryption pattern for contract callbacks
Deployed FHE Contracts (FHEVM 0.9.1)
The generated app includes pre-deployed FHE Contracts on Sepolia testnet for testing:
- FHECounter Contract:
0x7A14b454D19A4CB4c55E0386d04Eb0B66e6717EC(FHEVM 0.9.1) - ReviewCardsFHE Contract:
0xf80A030984a0AB6111B6e60973A6c16C668ede7a(FHEVM 0.9.1) - SimpleVoting Contract:
0x4189777Eb42f68Ce959E498a171e328BfDA90C46(FHEVM 0.9.1) - Network: Sepolia testnet (Chain ID: 11155111)
- Features:
- Get encrypted count from contract
- Increment/decrement with encrypted inputs
- User decryption with EIP-712 signing
- Public decryption with
decryptMultipleHandles - Self-relaying decryption pattern for voting tallies
Features
- ✅ Self-contained: No need to install FHEVM SDK separately
- ✅ Cross-platform: Works on Windows, Mac, Linux
- ✅ Zero configuration: Works out of the box
- ✅ Production ready: Includes all necessary files and configurations
- ✅ Beautiful UI: Zama design system with Tailwind CSS
- ✅ Real FHEVM operations: Actual encryption/decryption functionality
- ✅ Live contract: Pre-deployed FHE counter for immediate testing
- ✅ Complete development environment: Includes Hardhat for smart contract development
Smart Contract Development
The generated app includes a complete Hardhat development environment with all necessary files for FHEVM smart contract development:
📁 Hardhat Directory Structure:
hardhat/
├── contracts/
│ ├── FHECounter.sol # FHE Counter smart contract
│ ├── ReviewCardsFHE_uint32.sol # FHE Rating system contract
│ └── SimpleVoting_uint32.sol # FHE Voting system contract
├── deploy/
│ └── deploy.ts # Deployment script for all contracts
├── hardhat.config.js # Hardhat configuration (JavaScript)
├── package.json # Hardhat dependencies
└── tsconfig.json # TypeScript configuration🔧 Available Commands:
# Navigate to the hardhat directory
cd hardhat
# Install dependencies
npm install
# Compile contracts
npm run compile
# Start local hardhat node
npm run chain
# Deploy to hardhat network
npm run deploy:hardhat
# Deploy to Sepolia testnet (requires INFURA_API_KEY)
npm run deploy:sepolia📋 What's Included:
- ✅ FHE Counter Contract - Complete Solidity smart contract
- ✅ Deployment Scripts - Ready-to-use deployment scripts
- ✅ TypeScript Support - Full type safety for contracts
- ✅ Network Configuration - Pre-configured for hardhat and sepolia
- ✅ FHEVM Integration - Built-in FHEVM contract support
- ✅ Simplified Scripts - Clean, focused deployment commands
- ✅ JavaScript Config - No TypeScript compilation issues
Requirements
- Node.js 16 or higher
- npm or yarn
License
MIT
