Skip to main content

fhe/react

Interfaces

UserDecryptor

Defined in: fhe/react/use-decrypted-handle.ts:33

Subset of @zama-fhe/sdk RelayerSDK we depend on for user-decryption. Declared structurally so consumers can pass any v3 RelayerSDK (RelayerWeb, RelayerNode, or a mock like MockFhevmInstance) without us importing the optional peer dep.

Methods

userDecrypt()
userDecrypt(params): Promise<...>;

Defined in: fhe/react/use-decrypted-handle.ts:34

Parameters
ParameterType
params{ handleContractPairs: ...; privateKey?: ...; publicKey?: ...; signature?: ...; contractAddresses?: ...; userAddress?: ...; requestValidity?: ...; contractsChainId?: ...; }
params.handleContractPairs...
params.privateKey?...
params.publicKey?...
params.signature?...
params.contractAddresses?...
params.userAddress?...
params.requestValidity?...
params.contractsChainId?...
Returns

Promise<...>


UseDecryptedHandleOptions

Defined in: fhe/react/use-decrypted-handle.ts:55

Options accepted by useDecryptedHandle.

Properties

PropertyTypeDescriptionDefined in
handle?... | ...The encrypted handle to decrypt. undefined keeps the hook in idle state — useful when the handle comes from a downstream query that hasn't resolved yet.fhe/react/use-decrypted-handle.ts:61
contractAddress?... | ...The contract that granted ACL access to the handle. The relayer enforces (handle, contractAddress, userAddress) triples — passing the wrong contract here returns an empty result with no diagnostic.fhe/react/use-decrypted-handle.ts:67
userDecryptor?... | ...Lazy or eager Zama RelayerSDK / MockFhevmInstance / RelayerWeb / RelayerNode. Recommended in React: userDecryptor: () => useZamaSDK().relayer — the SDK calls this per-decryption so it picks up the live RelayerSDK instance rather than a stale capture (CLAUDE.md Pitfall #3).fhe/react/use-decrypted-handle.ts:74
relayerParams?... | ...Extra params passed straight through to the relayer's userDecrypt. The Zama RelayerWeb / RelayerNode require privateKey, publicKey, signature, requestValidity, contractsChainId. MockFhevmInstance tolerates a partial shape. Hosts that wrap their own keypair management pass the full shape here.fhe/react/use-decrypted-handle.ts:82
enabled?... | ... | ...Skip the decrypt — defaults to false. Useful when the consumer wants to render an "Encrypted" placeholder until the user opts in.fhe/react/use-decrypted-handle.ts:89

Type Aliases

UserDecryptorSource

type UserDecryptorSource = ... | ...;

Defined in: fhe/react/use-decrypted-handle.ts:47

Eager or lazy UserDecryptor reference — mirrors EncryptorSource.


UseDecryptedHandleResult

type UseDecryptedHandleResult = ... | ... | ... | ...;

Defined in: fhe/react/use-decrypted-handle.ts:93

Discriminated state machine for the hook's return.

Functions

useDecryptedHandle()

function useDecryptedHandle(opts): UseDecryptedHandleResult;

Defined in: fhe/react/use-decrypted-handle.ts:119

Decrypt a single EncryptedHandle returned by an FHE-product encrypted view (e.g. EncryptedViewResult.handle from ConfidentialVestingManagerClient.getTokenBalance()).

import { useDecryptedHandle } from "@tokenops/sdk/fhe/react";

const { status, value } = useDecryptedHandle({
handle: viewResult?.handle,
contractAddress: managerAddress,
userDecryptor: () => useZamaSDK().relayer,
relayerParams: { ...keypair, requestValidity, contractsChainId },
});

The relayer source resolves lazily per decrypt — the hook does NOT memoize the SDK client across renders, because user-decrypt is a one-shot action (no benefit to client caching).

Parameters

ParameterType
optsUseDecryptedHandleOptions

Returns

UseDecryptedHandleResult