A Hardhat-based template for developing Fully Homomorphic Encryption (FHE) enabled Solidity smart contracts using the FHEVM protocol by Zama.
For detailed instructions see: FHEVM Hardhat Quick Start Tutorial
- Node.js: Version 20 or higher
- npm or yarn/pnpm: Package manager
-
Install dependencies
npm install
-
Set up environment variables
npx hardhat vars set MNEMONIC # Set your Infura API key for network access npx hardhat vars set INFURA_API_KEY # Optional: Set Etherscan API key for contract verification npx hardhat vars set ETHERSCAN_API_KEY
-
Compile and test
npm run compile npm run test
-
Deploy to local network
# Start a local FHEVM-ready node npx hardhat node # Deploy to local network npx hardhat deploy --network localhost
-
Deploy to Sepolia Testnet
# Deploy to Sepolia npx hardhat deploy --network sepolia # Verify contract on Etherscan npx hardhat verify --network sepolia <CONTRACT_ADDRESS>
-
Test on Sepolia Testnet
# Once deployed, you can run a simple test on Sepolia. npx hardhat test --network sepolia
fhevm-hardhat-template/
├── contracts/ # Smart contract source files
│ └── FHECounter.sol # Example FHE counter contract
├── deploy/ # Deployment scripts
├── tasks/ # Hardhat custom tasks
├── test/ # Test files
├── hardhat.config.ts # Hardhat configuration
└── package.json # Dependencies and scripts
Script | Description |
---|---|
npm run compile |
Compile all contracts |
npm run test |
Run all tests |
npm run coverage |
Generate coverage report |
npm run lint |
Run linting checks |
npm run clean |
Clean build artifacts |
This project is licensed under the BSD-3-Clause-Clear License. See the LICENSE file for details.
- GitHub Issues: Report bugs or request features
- Documentation: FHEVM Docs
- Community: Zama Discord
Built with ❤️ by the Zama team