fhevm-forge-sdk
v0.3.2
Published
Relayer-native TypeScript SDK and React hooks for Zama FHEVM. Powers fhevm-forge scaffolding.
Maintainers
Readme
@fhevm/sdk (fhevm-forge-sdk)
The high-performance TypeScript SDK and React hooks for Zama FHEVM. This library powers the projects generated by fhevm-forge.
Features
- Relayer-Native: Built-in support for Zama's threshold decryption via the Relayer SDK.
- Singleton Management: Efficient WASM initialization and key management.
- React Hooks: Production-ready hooks for encryption (
useEncrypt) and re-encryption (useReencrypt). - Headless Support: Clean APIs for background agents and scripts.
Installation
npm install fhevm-forge-sdk ethers @zama-fhe/relayer-sdkBasic Usage
Initialize the Provider (React)
import { FhevmProvider } from "fhevm-forge-sdk";
function App() {
return (
<FhevmProvider chain="sepolia" provider={window.ethereum}>
<YourApp />
</FhevmProvider>
);
}Encrypt Data for a Transaction
import { useEncrypt } from "fhevm-forge-sdk";
const { encrypt, encrypting } = useEncrypt(contractAddress, userAddress);
const handleSubmit = async (amount: bigint) => {
const encrypted = await encrypt("uint64", amount);
if (encrypted) {
// Send to contract
}
};Reveal Private Data (Re-encryption)
import { useReencrypt } from "fhevm-forge-sdk";
const { reveal, values, loading } = useReencrypt(contractAddress, userAddress, signer);
useEffect(() => {
reveal([handle1, handle2]);
}, [handle1, handle2]);License
MIT
