Skip to content

zama-ai/fhevm-hardhat-template

Repository files navigation

FHEVM Hardhat Template

A Hardhat-based template for developing Fully Homomorphic Encryption (FHE) enabled Solidity smart contracts using the FHEVM protocol by Zama.

Quick Start

For detailed instructions see: FHEVM Hardhat Quick Start Tutorial

Prerequisites

  • Node.js: Version 20 or higher
  • npm or yarn/pnpm: Package manager

Installation

  1. Install dependencies

    npm install
  2. 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
  3. Compile and test

    npm run compile
    npm run test
  4. Deploy to local network

    # Start a local FHEVM-ready node
    npx hardhat node
    # Deploy to local network
    npx hardhat deploy --network localhost
  5. Deploy to Sepolia Testnet

    # Deploy to Sepolia
    npx hardhat deploy --network sepolia
    # Verify contract on Etherscan
    npx hardhat verify --network sepolia <CONTRACT_ADDRESS>
  6. Test on Sepolia Testnet

    # Once deployed, you can run a simple test on Sepolia.
    npx hardhat test --network sepolia

📁 Project Structure

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

📜 Available 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

📚 Documentation

📄 License

This project is licensed under the BSD-3-Clause-Clear License. See the LICENSE file for details.

🆘 Support


Built with ❤️ by the Zama team