jobjab-fhevm-sdk
v0.2.0
Published
Universal, framework-agnostic SDK for building confidential dApps with FHEVM
Maintainers
Readme
jobjab-fhevm-sdk
Universal, framework-agnostic SDK for building confidential dApps with FHEVM
✨ Fully compatible with Zama FHEVM v0.9 specification
Installation
npm install jobjab-fhevm-sdkQuick Start
Core (Framework-Agnostic)
import { createFhevmClient } from 'jobjab-fhevm-sdk';
const client = createFhevmClient({ network: 'sepolia' });
await client.init();
const result = await client.encrypt(
contractAddress,
userAddress,
{ type: 'euint32', value: 42 }
);React
import { FhevmProvider, useEncrypt } from 'jobjab-fhevm-sdk/adapters/react';
import { EncryptedInput } from 'jobjab-fhevm-sdk/components/react';
<FhevmProvider config={{ network: 'sepolia' }}>
<YourApp />
</FhevmProvider>
function YourApp() {
const { encrypt } = useEncrypt({ contractAddress, userAddress });
return <EncryptedInput type="euint32" onEncrypted={(r) => console.log(r)} />;
}Features
- 🎯 Framework-Agnostic - React, Vue, Node.js, Vanilla JS
- 🪝 Wagmi-like API - Provider + hooks pattern
- 📦 Components - EncryptedInput, DecryptButton, CipherPreview
- ⚡ Performance - Batch operations (3-5x faster), caching
- 🔐 Complete - Encrypt, decrypt (user + public), EIP-712
- 🚨 Error Handling - Helpful error codes and suggestions
- 🧪 Tested - 142+ tests passing
API
Core
createFhevmClient(config) // Create client
client.init() // Initialize
client.encrypt(addr, user, value) // Encrypt value
client.encryptBatch(addr, user, values) // Batch (3-5x faster)
client.decrypt(requests, signature) // Decrypt with EIP-712
client.publicDecrypt(handle, addr) // Public decryptReact
<FhevmProvider config={...}> // Provider
useFhevmClient() // Access client
useEncrypt({ contractAddress, userAddress })
useDecrypt({ requests, signature })
useDecryptionSignature({ contractAddresses, signer })Components
<EncryptedInput type="euint32" onEncrypted={handler} />
<DecryptButton handle="0x..." signer={signer} showValue />
<CipherPreview handle="0x..." showDecrypt />Supported Types
Primary Types (FHEVM v0.9)
ebool- Boolean valueseuint8,euint16,euint32,euint64,euint128,euint256- Unsigned integerseaddress- Ethereum addresses
Legacy Types (Deprecated in v0.7+)
ebytes64,ebytes128,ebytes256- Not recommended for new projects
Note: The SDK uses externalE* types with inputProof (ZKPoK) pattern, matching FHEVM v0.9's encrypted input specification. See Zama Docs for details.
FHEVM v0.9 Compatibility
This SDK is designed for FHEVM v0.9 and includes:
✅ Decryption via Relayer/KMS - No deprecated FHE.requestDecryption or FHE.setDecryptionOracle
✅ Simplified EIP-712 - No contractsChainId field (matches v0.9 spec)
✅ Gateway Architecture - Full support for gateway chain decryption flow
✅ ACL Permissions - Works with FHE.allow, FHE.allowThis, FHE.makePubliclyDecryptable
✅ Modern Types - Primary focus on euint*, ebool, eaddress (v0.9 spec)
Verified with: @zama-fhe/[email protected]
Documentation
- Examples - ../../examples/ - 10 runnable .ts files
- API Docs - ../../docs/ - Detailed per-function docs
- Recipes - ../../COOKBOOK.md - 29 common patterns
- Troubleshooting - ../../TROUBLESHOOTING.md
Example Usage
// Encrypt
const encrypted = await client.encrypt(addr, user, { type: 'euint32', value: 100 });
await contract.myFunction(encrypted.handles[0], encrypted.inputProof);
// Decrypt
const keypair = client.generateKeypair();
const eip712 = client.createEIP712(keypair.publicKey, [addr]);
const sig = await signer.signTypedData(eip712.domain, eip712.types, eip712.message);
const decrypted = await client.decrypt([{ handle, contractAddress }], { ...keypair, signature: sig, ... });Links
License
BSD-3-Clause-Clear
Built for Zama Bounty Program - October 2025
