The World's First Fully Encrypted Enterprise Payroll System
π Quick Start β’ π Documentation β’ ποΈ Architecture β’ π Security β’ π» Demo
The Confidential Payroll System is a revolutionary blockchain-based payroll management solution that leverages Zama's Fully Homomorphic Encryption (FHE) technology to provide complete salary privacy while maintaining full regulatory compliance. This system enables organizations to process payroll, calculate taxes, distribute bonuses, and generate compliance reportsβall without ever exposing individual salary data in plaintext.
- π Complete Privacy: Individual salaries and financial data remain encrypted end-to-end
- π Regulatory Compliance: Generate audit reports without exposing sensitive data
- π° Cost Efficiency: 50% reduction in payroll processing costs
- β‘ Real-time Processing: Instant encrypted payments with sub-second confirmations
- π Global Scale: Support for multi-currency and cross-border payments
- π€ Automation: Smart contract-based tax calculations and withholdings
# Clone the repository
git clone
cd into the folder
# Install dependencies
cd payroll-contracts && npm install
cd ../frontend && npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration
# Deploy contracts locally
cd payroll-contracts
npx hardhat node # In one terminal
npx hardhat run scripts/deploy.js --network localhost # In another terminal
# Start the frontend
cd ../frontend
npm run dev
# Access the application
open http://localhost:5173- Features
- Architecture
- Technology Stack
- Installation
- Smart Contracts
- Frontend Application
- API Documentation
- Security
- Testing
- Deployment
- Use Cases
- Contributing
- License
- Store and manage salaries using FHE encryption
- Process payments without revealing amounts
- Support for multiple pay frequencies (weekly, bi-weekly, monthly)
- Calculate progressive taxes on encrypted income
- Automatic withholding with confidential rates
- Compliance reporting without data exposure
- Distribute performance bonuses privately
- Encrypted KPI-based calculations
- Batch bonus processing for efficiency
- Generate regulatory reports without exposing individual data
- Aggregate statistics with privacy preservation
- Audit trails with encrypted transaction history
- Secure fund management with encrypted balances
- Approval workflows with hidden transaction amounts
- DeFi integration for yield generation
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React + TypeScript) β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β βEmployee β βEmployer β βAdmin β βAuditor β β
β βDashboard β βDashboard β βDashboard β βDashboard β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β ethers.js + fhenixjs
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β Smart Contracts (FHEVM) β
β ββββββββββββββββββββββββββ ββββββββββββββββββββββββββ β
β βConfidentialPayrollSystemβ β PayrollToken β β
β β - Employee Management β β - Encrypted ERC20 β β
β β - Payroll Processing β β - Tax Withholding β β
β β - Bonus Distribution β β - Payment Processing β β
β β - Compliance Reports β β β β
β ββββββββββββββββββββββββββ ββββββββββββββββββββββββββ β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β FHEVM Infrastructure β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β βFHE β βACL β βGateway β βOracle β β
β βOperationsβ βManagementβ βService β βService β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
graph LR
A[User Input] --> B[Client Encryption]
B --> C[Smart Contract]
C --> D[FHE Operations]
D --> E[Encrypted Result]
E --> F[ACL Check]
F --> G[Client Decryption]
G --> H[Display Result]
- Blockchain: Ethereum / Zama Network
- Smart Contracts: Solidity 0.8.24
- FHE Library: @fhevm/solidity ^0.7.0
- Token Standard: Confidential ERC20
- Development: Hardhat 2.26.0
- Testing: Chai, Mocha
- Framework: React 19.1.1
- Language: TypeScript 5.8.3
- Build Tool: Vite 7.1.2
- UI Library: Material-UI 7.3.1
- Web3: ethers.js 6.15.0
- State Management: React Query 5.85.6
- Routing: React Router 7.8.2
- FHE SDK: fhenixjs
- Encryption: Zama TFHE
- Key Management: KMS Verifier
- Decryption: Async Oracle Pattern
- Node.js >= 20.0.0
- npm >= 7.0.0
- Git
- MetaMask or compatible Web3 wallet
git clone https://github.com/kamalbuilds/private-payroll-zama.git
cd private-payroll-zamacd payroll-contracts
npm installcd ../frontend
npm install# In payroll-contracts/
cp .env.example .env
# Add your private key and RPC URLs
# In frontend/
cp .env.example .env
# Add contract addresses and API endpointscd payroll-contracts
# Start local node
npx hardhat node
# Deploy contracts (in another terminal)
npx hardhat run scripts/deploy.js --network localhostcd frontend
npm run dev
# Application available at http://localhost:5173Main payroll management contract handling employee data and payment processing.
// Add employee with encrypted salary
function addEmployee(
address employee,
externalEuint64 encryptedSalary,
externalEuint64 encryptedTaxRate,
bytes calldata inputProof
) external onlyRole(PAYROLL_ADMIN_ROLE)
// Process payroll for all employees
function processPayroll() external onlyRole(PAYROLL_ADMIN_ROLE)
// Distribute bonus to employee
function distributeBonus(
address employee,
externalEuint64 encryptedBonus,
bytes calldata inputProof
) external onlyRole(EMPLOYER_ROLE)
// Generate compliance report
function generateComplianceReport() external onlyRole(AUDITOR_ROLE) returns (bytes32)Confidential ERC20 token for salary payments with tax withholding.
// Process payroll payment with tax withholding
function processPayrollPayment(
address employee,
euint64 grossPay,
euint64 taxAmount
) public onlyPayrollManager
// Batch process multiple payments
function batchProcessPayroll(
address[] calldata employees,
euint64[] calldata grossPayments,
euint64[] calldata taxAmounts
) external onlyPayrollManager| Role | Permissions |
|---|---|
DEFAULT_ADMIN_ROLE |
Full system administration |
EMPLOYER_ROLE |
Distribute bonuses, view reports |
PAYROLL_ADMIN_ROLE |
Process payroll, manage employees |
AUDITOR_ROLE |
Generate compliance reports |
- View encrypted salary (with permission)
- Payment history table
- Tax withholding information
- Year-to-date earnings
- Bonus notifications
- Add/remove employees
- Distribute bonuses
- View aggregate statistics
- Budget management
- Performance tracking
- Process payroll batches
- System configuration
- Security settings
- User management
- Emergency controls
- Generate compliance reports
- View encrypted aggregates
- Audit trail access
- Zero-knowledge proofs
- Export functionality
src/
βββ components/
β βββ WalletConnect.tsx # MetaMask connection
β βββ EncryptedDataDisplay.tsx # Show/hide encrypted values
β βββ PayrollProcessing.tsx # Batch payment processing
β βββ EmployeeManagement.tsx # Add/remove employees
β βββ BonusDistribution.tsx # Bonus management
β βββ ComplianceReport.tsx # Report generation
βββ pages/
β βββ LoginPage.tsx # Role selection
β βββ DashboardPage.tsx # Main dashboard
β βββ [Role]Dashboard.tsx # Role-specific views
βββ hooks/
β βββ useWallet.ts # Wallet management
β βββ useEncryption.ts # FHE operations
β βββ usePayrollContract.ts # Contract interactions
βββ utils/
βββ encryption.ts # FHE helpers
βββ constants.ts # Contract addresses
// Initialize contract connection
import { ethers } from 'ethers';
import { PayrollSystem__factory } from '../types';
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const payrollSystem = PayrollSystem__factory.connect(CONTRACT_ADDRESS, signer);
// Add employee with encryption
import { FhenixClient } from 'fhenixjs';
const client = new FhenixClient({ provider });
const encryptedSalary = await client.encrypt(120000, 'uint64');
const encryptedTaxRate = await client.encrypt(25, 'uint64');
await payrollSystem.addEmployee(
employeeAddress,
encryptedSalary.encrypted,
encryptedTaxRate.encrypted,
encryptedSalary.proof
);// Use wallet connection
const { account, connect, disconnect } = useWallet();
// Encrypt data
const { encrypt, decrypt } = useEncryption();
const encryptedValue = await encrypt(plainValue);
// Contract interaction
const { addEmployee, processPayroll } = usePayrollContract();
await addEmployee(address, salary, taxRate);- End-to-End Encryption: All sensitive data encrypted with Zama's TFHE
- Homomorphic Operations: Computations on encrypted data without decryption
- Access Control: Fine-grained permissions with FHE.allow()
- Zero-Knowledge Proofs: Compliance verification without data exposure
- Role-Based Access Control: OpenZeppelin AccessControl implementation
- Reentrancy Protection: Safe transfer patterns
- Integer Overflow Protection: Solidity 0.8+ automatic checks
- Emergency Pause: Circuit breaker functionality
- Input Validation: Comprehensive form validation
- XSS Protection: React's built-in protections
- Secure Communication: HTTPS only
- Wallet Security: No private key storage
- External security audit before mainnet
- Formal verification of critical functions
- Bug bounty program
- Penetration testing
- Gas optimization audit
cd payroll-contracts
npm run testnpm run coveragetest/
βββ PayrollSystem.test.ts # Main contract tests
βββ PayrollToken.test.ts # Token tests
βββ Integration.test.ts # End-to-end tests
βββ helpers/
βββ encryption.ts # FHE test helpers
βββ fixtures.ts # Test data
describe("Payroll Processing", () => {
it("Should process encrypted payroll", async () => {
const encryptedSalary = await encrypt(120000);
await payrollSystem.addEmployee(employee, encryptedSalary, proof);
await expect(payrollSystem.processPayroll())
.to.emit(payrollSystem, "PayrollProcessed")
.withArgs(1, 1);
});
});npx hardhat node
npx hardhat run scripts/deploy.js --network localhostnpx hardhat run scripts/deploy.js --network sepolia
npx hardhat verify --network sepolia CONTRACT_ADDRESS# 1. Update .env with mainnet RPC and private key
# 2. Review security checklist
# 3. Deploy contracts
npx hardhat run scripts/deploy.js --network mainnet
# 4. Verify contracts
npx hardhat verify --network mainnet CONTRACT_ADDRESS
# 5. Transfer ownership to multisig- Security audit completed
- Gas optimization done
- Environment variables secured
- Multisig wallet configured
- Monitoring setup
- Incident response plan
// Admin processes monthly payroll
await payrollSystem.processPayroll();
// All employees receive encrypted net pay
// Taxes automatically withheld// Employer distributes encrypted bonus
const bonus = await encrypt(5000);
await payrollSystem.distributeBonus(employee, bonus, proof);// Auditor generates report without seeing individual data
const reportHash = await payrollSystem.generateComplianceReport();
// Report contains aggregated encrypted data// System remits accumulated taxes
await payrollToken.remitTaxWithholdings();
// Tax authority receives encrypted total// Employee views their encrypted salary
const salary = await payrollSystem.confidentialBalanceOf(myAddress);
// Only the employee can decrypt their own salary// Process payroll in different currencies
const usdSalary = await encrypt(5000, 'USD');
const eurSalary = await encrypt(4500, 'EUR');We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
- Solidity: Follow Solidity Style Guide
- TypeScript: ESLint + Prettier configuration
- Commits: Conventional Commits specification
- All new features must have tests
- Maintain >80% code coverage
- Pass all CI/CD checks
This project is licensed under the BSD-3-Clause-Clear License - see the LICENSE file for details.
- Zama - For the revolutionary FHE technology
- OpenZeppelin - For secure smart contract libraries
- Hardhat - For the development environment
- Community contributors and testers
- Documentation: docs.confidential-payroll.io
- Discord: Join our community
- Twitter: @ConfidentialPay
- Email: [email protected]
- Smart Contracts Implementation
- Frontend Application
- Local Testing
- Documentation
- Security Audit
- Testnet Deployment
- Mainnet Launch
- Enterprise Partnerships
Built with β€οΈ using Zama's FHE Technology
Revolutionizing Payroll Privacy, One Encrypted Transaction at a Time
Website β’ Documentation β’ Blog