useFhevmEncrypt
Usage
import { useFhevmEncrypt } from '@fhevm/react-sdk';
import { useAccount } from 'wagmi';
function EncryptDemo() {
const { address } = useAccount();
const { createInput, isReady } = useFhevmEncrypt({
contractAddress: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
});
async function handleEncrypt() {
if (!isReady || !address) return;
// Create encrypted input bound to contract and user
const input = createInput(address);
// Add values to encrypt
input.add32(42);
input.add64(100n);
input.addBool(true);
// Encrypt all values in a single operation
const { handles, inputProof } = await input.encrypt();
// Use in contract call
await contract.myMethod(handles[0], handles[1], handles[2], inputProof);
}
return (
<button onClick={handleEncrypt} disabled={!isReady}>
Encrypt & Submit
</button>
);
}Supported Types
Batch Encryption
Last updated