useFhevmPublicDecrypt
Usage
import { useFhevmPublicDecrypt } from '@fhevm/react-sdk';
import { useState } from 'react';
function PublicCounter() {
const [count, setCount] = useState<bigint | null>(null);
const { decrypt, isDecrypting } = useFhevmPublicDecrypt();
async function handleDecrypt(handle: string) {
try {
const value = await decrypt(handle);
setCount(value as bigint);
} catch (err) {
console.error('Decryption failed:', err);
}
}
return (
<div>
<button onClick={() => handleDecrypt('0x...')} disabled={isDecrypting}>
{isDecrypting ? 'Loading...' : 'Get Public Count'}
</button>
{count !== null && <p>Count: {count.toString()}</p>}
</div>
);
}Batch Decryption
Last updated