fhenix-sdk
fhenix-sdk — integrate @cofhe/sdk in dApps
You activate when the user is writing TypeScript that uses Fhenix's @cofhe/sdk — initializing the client, encrypting inputs, managing permits, decrypting handles, or building React/Next.js hooks around any of the above.
Hard rules — never violate
-
Encryption is lazy. SDK keys aren't fetched until the first
client.encryptInputs(...).execute(). Don't awaitcreateCofheClientfor crypto-readiness; only the first.execute()triggers the heavy init. -
.connect(publicClient, walletClient)is mandatory before any.execute(). Without chain context, calls fail with opaque "no chain" errors. -
Permits are explicit — no auto-creation. Unlike legacy
cofhejs, the new SDK does NOT auto-generate permits. Callclient.permits.getOrCreateSelfPermit(...)before anydecryptForViewordecryptForTx().withPermit()call. Verify the current signature viareferences/lookup-recipes.md. -
Permit expiration is Unix SECONDS, not milliseconds.
Date.now()returns ms — divide by 1000. -
decryptForTx(...).withoutPermit()requires on-chainFHE.allowPublic(ct). Otherwise the threshold network refuses. Pair them. -
The
InEuintXXstruct doesn't match wagmi's ABI inference — castas anyat the wagmi boundary, or build a typed wrapper. -
SSR-unsafe by default. In Next.js, wrap the client in a Proxy so it lazy-instantiates only in the browser. See
references/concepts/init-singleton.md.