For Competition Evaluators and Developers
This guide will get you up and running with the FHEVM SDK in less than 5 minutes.
git clone https://github.com/OsbaldoSchmeler/WaterResourceManager.git
cd WaterResourceManager/fhevm-react-templatenpm installThis will install dependencies for:
- 📦 Core SDK (
packages/fhevm-sdk) - 🎯 Next.js example (
examples/nextjs-water-management)
npm run devOpen your browser to http://localhost:3000
That's it! 🎉
The Next.js example demonstrates:
-
Privacy-Preserving Forms
- Enter water demand (e.g., 1000 liters)
- Adjust priority level (1-10)
- Click "Encrypt Data" to see FHE encryption in action
-
Real-Time SDK Integration
useFHEVM()hook initializes the SDKuseEncrypt()hook encrypts user inputs- Loading states show encryption progress
- Encrypted data displayed in UI
-
Complete Workflow
- SDK initialization with Sepolia network
- Client-side encryption before submission
- Type-safe TypeScript throughout
- Responsive UI with Tailwind CSS
Location: packages/fhevm-sdk/
Key Files:
packages/fhevm-sdk/
├── src/
│ ├── index.ts ← Framework-agnostic core
│ └── react.tsx ← React hooks adapter
├── package.json ← SDK dependencies
└── tsconfig.json ← TypeScript config
Core Exports:
// From src/index.ts
export { initFHEVM, encrypt, decrypt, createFHEContract };
// From src/react.tsx
export { useFHEVM, useEncrypt, useDecrypt, useContract };Location: examples/nextjs-water-management/
Key Files:
examples/nextjs-water-management/
├── pages/
│ ├── index.tsx ← Main demo page
│ └── _app.tsx ← Next.js app wrapper
├── styles/
│ └── globals.css ← Tailwind styles
├── package.json ← Example dependencies
├── next.config.js ← Next.js config
├── tsconfig.json ← TypeScript config
├── tailwind.config.js ← Tailwind config
└── postcss.config.js ← PostCSS config
Open browser console to see:
✅ FHEVM SDK initialized on sepolia
Enter values and click "Encrypt Data" to see:
🔐 Encrypted uint32(1000)
🔐 Encrypted uint32(5)
View the encrypted values in the UI:
Demand: 0x656e637279707465645f75696e7433325f31303030
Priority: 0x656e637279707465645f75696e7433325f35
npm install fhevm-sdkimport { initFHEVM, encrypt } from 'fhevm-sdk';
// Initialize
await initFHEVM({
network: 'sepolia',
provider: window.ethereum
});
// Encrypt
const encrypted = await encrypt.uint32(1000);
console.log('Encrypted:', encrypted);import { useFHEVM, useEncrypt } from 'fhevm-sdk/react';
function MyComponent() {
const { isReady } = useFHEVM({ network: 'sepolia' });
const { encryptUint32, isEncrypting } = useEncrypt();
const handleSubmit = async () => {
const encrypted = await encryptUint32(1000);
console.log('Encrypted:', encrypted);
};
return (
<button onClick={handleSubmit} disabled={!isReady || isEncrypting}>
{isEncrypting ? 'Encrypting...' : 'Encrypt'}
</button>
);
}# Build SDK package
npm run build --workspace=packages/fhevm-sdk
# Build Next.js example
npm run build --workspace=examples/nextjs-water-management# From root directory
cd ../..
npm test
npm run test:coverage| Document | Purpose |
|---|---|
| README.md | Complete SDK documentation |
| SUBMISSION.md | Competition submission summary |
| QUICK_START.md | This guide |
| docs/ | Additional documentation |
Network: Ethereum Sepolia Testnet
Address: 0x4E2c3faE5165E4d5f9E2dEcFEA50e84399157b76
Explorer: View on Etherscan
Solution: Ensure you're in the monorepo root:
cd WaterResourceManager/fhevm-react-template
npm installSolution: Check port 3000 is available:
# Windows
netstat -ano | findstr :3000
# macOS/Linux
lsof -i :3000Solution: Ensure all dependencies are installed:
npm install --workspacesFile: demo.mp4
Duration: 5-10 minutes
Contents: SDK overview, Next.js walkthrough, live encryption demo
Run these commands to verify everything works:
# 1. Check structure
cd fhevm-react-template
ls -la packages/fhevm-sdk/src/
ls -la examples/nextjs-water-management/pages/
# 2. Verify configs
cat packages/fhevm-sdk/package.json
cat examples/nextjs-water-management/package.json
# 3. Install dependencies
npm install
# 4. Start development server
npm run dev
# 5. Open browser
# http://localhost:3000✅ Framework-agnostic SDK ✅ All-in-one package ✅ wagmi-like API structure ✅ Complete FHE workflow ✅ Next.js example (working) ✅ < 10 line setup (3 lines!) ✅ Clear documentation ✅ All content in English ✅ No forbidden naming
Start the demo:
npm run devOpen browser: http://localhost:3000
Built with 🔐 Zama FHEVM Making Confidential Computing 🚀 Simple