FHE-Pay is a revolutionary payroll streaming platform built on Ethereum that uses Fully Homomorphic Encryption (FHE) to enable employers to create encrypted salary streams while keeping salary amounts completely private. Employees can withdraw from their salary streams in real-time with total privacy protection.
- π End-to-End Encryption: All salary amounts are encrypted using FHE, ensuring complete privacy
- β‘ Real-Time Streaming: Employees can access their earned salary instantly as it accrues
- π¦ Blockchain-Based: Built on Ethereum with smart contract automation
- π₯ Multi-Party Support: Separate interfaces for employers and employees
- π Security First: Comprehensive security measures including reentrancy protection
- π Analytics Dashboard: Real-time insights into payroll and earnings
- Core Contract:
contracts/PayrollStream.sol- Main payroll streaming contract with FHE integration - FHE Integration: Built with Zama's fhEVM for encrypted salary calculations
- Key Features:
- Encrypted salary storage using TFHE.euint256
- Async withdrawal requests via gateway decryption
- Stream management (create, pause, resume)
- Multi-party support (employer/employee)
- Framework: Next.js 14 with App Router
- State Management: Zustand for global state, React Query for server state
- Web3 Integration: Wagmi + RainbowKit for wallet connection
- Styling: Tailwind CSS with custom components
- FHE Integration: @zama-fhe/relayer-sdk for client-side encryption
- Node.js 18+ installed
- MetaMask or compatible Web3 wallet
- Ethereum Sepolia testnet ETH for testing
-
Clone the repository
git clone <repository-url> cd fhe-pay
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env.local
Configure your
.env.localwith:# Blockchain Configuration NEXT_PUBLIC_SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_PROJECT_ID NEXT_PUBLIC_CONTRACT_ADDRESS=YOUR_DEPLOYED_CONTRACT_ADDRESS NEXT_PUBLIC_CHAIN_ID=11155111 NEXT_PUBLIC_ENVIRONMENT=development # FHE Configuration NEXT_PUBLIC_FHE_GATEWAY_URL=https://gateway.zama.ai PRIVATE_KEY=YOUR_PRIVATE_KEY # WalletConnect NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=YOUR_WALLETCONNECT_PROJECT_ID # Etherscan ETHERSCAN_API_KEY=YOUR_ETHERSCAN_API_KEY
-
Start the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
npm run dev # Start Next.js development server
npm run build # Build Next.js application
npm run start # Start production server
npm run lint # Run ESLintnpx hardhat compile # Compile Solidity contracts
npx hardhat test # Run contract tests
npx hardhat node # Start local Hardhat network
npx hardhat deploy # Deploy contracts# Deploy to Sepolia testnet
npx hardhat run scripts/deploy.ts --network sepolia
# Verify contract on Etherscan
npx hardhat verify --network sepolia <contract_address>npx hardhat test # Run all tests
npx hardhat test --grep <pattern> # Run specific tests
npx hardhat coverage # Run coverage report- Location:
test/PayrollStream.test.ts - Framework: Hardhat + ethers + chai
- Coverage: All contract functions including FHE operations
- Encryption: Salary amounts are encrypted on the frontend using @zama-fhe/relayer-sdk
- Storage: Encrypted values are stored as TFHE.euint256 in the smart contract
- Calculations: All mathematical operations are performed on encrypted data
- Decryption: Async gateway requests for withdrawal amounts when needed
src/lib/fhe.ts- Core FHE utilities and instance managementsrc/hooks/useFHE.ts- React hooks for FHE operationscontracts/PayrollStream.sol- Contract with TFHE integration
- Connect your Web3 wallet
- Navigate to the Employer Dashboard
- Create new payroll streams by specifying employee addresses and encrypted salary amounts
- Manage existing streams (pause, resume, modify)
- Monitor total payroll obligations
- Connect your Web3 wallet
- View your active salary streams
- Withdraw available earnings in real-time
- Track withdrawal history and remaining balance
- Start Hardhat local network:
npx hardhat node - Deploy contracts:
npx hardhat run scripts/deploy.ts --network localhost - Update frontend .env with contract address
- Ensure you have Sepolia ETH
- Compile contracts:
npx hardhat compile - Deploy:
npx hardhat run scripts/deploy.ts --network sepolia - Verify:
npx hardhat verify --network sepolia <address> - Update frontend environment variables
- Security audit required before mainnet deployment
- Follow the same deployment process as testnet
- Use mainnet configuration in hardhat.config.ts
- FHE Encryption: End-to-end encryption of all salary data
- Reentrancy Protection: Prevents recursive contract calls
- Emergency Controls: Contract owner can pause operations in emergencies
- Async Decryption: Prevents blocking operations during decryption
- Input Validation: Comprehensive validation on all contract functions
- Access Control: Role-based permissions for different user types
- Solidity: Smart contract development
- Hardhat: Development environment and testing framework
- Ethers: Ethereum library for contract interaction
- Zama fhEVM: FHE-enabled Ethereum Virtual Machine
- Next.js 14: React framework with App Router
- TypeScript: Type-safe JavaScript
- Tailwind CSS: Utility-first CSS framework
- Wagmi: React hooks for Ethereum
- RainbowKit: Wallet connection library
- @zama-fhe/relayer-sdk: Client-side FHE operations
- TFHE: Threshold Fully Homomorphic Encryption
- Async Gateway: Decryption service for FHE operations
- Zustand: Lightweight state management
- React Query: Server state management and caching
- Supabase: Backend services (if applicable)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This software is provided as-is for educational and development purposes. Please conduct thorough security audits before deploying to production environments. The developers are not responsible for any financial losses or security breaches.
For questions or support:
- Create an issue in the GitHub repository
- Review the CLAUDE.md file for development guidance
- Check the DEPLOYMENT.md for deployment instructions