/fhenix-toolkit:fhenix-contractsfrom fhenix-toolkit
Teaches confidential Solidity patterns for Fhenix CoFHE: branchless updates with FHE.select, ACL verbs, decryption flows, and confidential-token standards. Activates on Fhenix contract work.
Ships in fhenix-toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You activate when the user is writing or editing Solidity that uses Fhenix's FHE library: files importing @fhenixprotocol/cofhe-contracts/FHE.sol or fhenix-confidential-contracts, files using euint* / ebool / eaddress types, or prompts like "build a confidential X contract."
Tight summary. Full explanations: references/hard-rules.md.
if / require on ebool → use FHE.select(cond, a, b). (concepts/branchless-update.md)FHE.allowThis(x) after every stored encrypted write — or the contract can't reuse x next tx. (concepts/allow-cascade.md)mul / div when shr works — bit-shifts approximate ratios cheaply. (concepts/bit-shift-ratio.md)approve with the operator pattern. (concepts/operator-pattern.md)trivialEncrypt exposes plaintext in calldata — only safe for non-secret constants.allow* before emit / return — the off-chain network observes handles in event/return order and expects ACL bits set first.euint32 x; reads as FHE.asEuint32(0); track presence with a separate plaintext flag.FHE.select always execute — no short-circuit. For eaddress, use FHE.asEaddress(address(0)) as the false-arm sentinel.allowPublic / allowGlobal are irreversible — there is no revokePublic. Treat them as "publish to the world."new, for large FHE contracts — new embeds child creation code; FHE contracts bust the 24KB EIP-170 limit fast.allowTransient vs allow — pick by lifetime — transient grants don't survive the current tx; never use for SDK decrypts. (concepts/allow-transient.md)| Verb | Grants | Call when |
|---|---|---|
FHE.allowThis(ct) | The current contract | After every encrypted write that's stored — mandatory. |
FHE.allowSender(ct) | msg.sender | The caller will decrypt off-chain (e.g. show their own balance). |
FHE.allow(ct, addr) | Specific address | Pass the ciphertext to another contract, or grant a known user. |
FHE.allowPublic(ct) | Everyone | Intentional protocol reveal. Pair with off-chain decryptForTx(...).withoutPermit() + on-chain FHE.verifyDecryptResult(...). |
Decision tree: references/decision-trees.md (ACL section).
When a value needs to leave the encrypted domain, pick one:
FHE.allowPublic(ct) or FHE.allow(ct, user). Client calls decryptForTx(ctHash).withoutPermit().execute() (or .withPermit()), gets {decryptedValue, signature}, and calls back into the contract which validates with FHE.verifyDecryptResult(...). Used in auction settlement (allowPublic + withoutPermit) and Equle's claim-victory.FHE.allow(ct, user). Client calls decryptForView(ctHash, utype).execute() — purely off-chain. Contract never sees the plaintext. Used in Secret Santa's target reveal.Decision tree: references/decision-trees.md (decryption-flow section).
| Standard | Use when |
|---|---|
ERC20Confidential (Fhenix's own) | Vanilla confidential ERC-20; Fhenix's standard is sufficient. |
| Vendored FHERC20 | You need to extend transfer semantics (callbacks, AVS, custom approval flows). |
| ERC-7984 (Ethereum draft) | You want cross-protocol composability with the emerging Ethereum standard. |
Detailed picker: references/concepts/confidential-token-standards.md.
Each references/concepts/<name>.md is one focused pattern with links to canonical examples in real public repos. Read on demand — don't load them all up front:
branchless-update.md — FHE.select instead of if / require.allow-cascade.md — re-grant access after every derivation; permissions don't inherit.handle-lifecycle-backfill.md — re-grant helpers, O(N) backfill on new authorized addresses, and the grantBalanceAccess pattern for FHERC20 external handles.allow-transient.md — when to reach for FHE.allowTransient vs persistent FHE.allow.encrypted-input.md — InEuintXX handling from client to chain.bit-shift-ratio.md — cheap percentage approximations via FHE.shr.operator-pattern.md — replacing ERC-20 allowance for ciphertexts.randomness-via-entropy.md — user-contributed entropy XOR (no trusted seed).confidential-token-standards.md — picking ERC20Confidential / FHERC20 / ERC7984.For function signatures, op×type availability, exact ACL semantics, or gas behavior, never recall — always look up. Read references/lookup-recipes.md for the canonical commands. The on-chain library evolves; lookup recipes always find current truth.
InEuintXX calldata from the client (if user-supplied input).FHE.asEuintXX(in) — this verifies the signature and registers the handle.FHE.select.FHE.allowThis(result) for anything stored.FHE.allowSender(result) if the caller needs to decrypt it off-chain.FHE.allow(result, addr) for any downstream contract that needs access.Verify each step against a concept file before writing. When in doubt, look up.
references/concepts/allow-cascade.md (opens in a new tab)references/concepts/allow-transient.md (opens in a new tab)references/concepts/bit-shift-ratio.md (opens in a new tab)references/concepts/branchless-update.md (opens in a new tab)references/concepts/confidential-token-standards.md (opens in a new tab)references/concepts/encrypted-input.md (opens in a new tab)references/concepts/handle-lifecycle-backfill.md (opens in a new tab)references/concepts/operator-pattern.md (opens in a new tab)references/concepts/randomness-via-entropy.md (opens in a new tab)references/decision-trees.md (opens in a new tab)references/hard-rules.md (opens in a new tab)references/lookup-recipes.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
4 skills in this plugin
/fhenix-reviewUse when auditing or reviewing confidential code for Fhenix CoFHE — both on-chain (FHE.sol) and off-chain (@cofhe/sdk). Catches ACL bugs, decrypt-flow mismatches, plaintext leaks, confidentiality-vs-anonymity confusion, and the 30+ recurring gotchas in this catalog. Activates only in review/audit contexts — PR diffs, `gh pr view` output, or prompts like "audit this", "review this", "is this safe", "security check", "look over my FHE code"./fhenix-sdkUse when working with @cofhe/sdk in TypeScript — encrypting inputs, managing permits, choosing decrypt modes (decryptForView vs decryptForTx), or wiring CoFHE into a Next.js / wagmi / viem dApp. Activates on imports of @cofhe/sdk or its subpaths, on hooks named useCofhe* or usePermit*, and on prompts like "encrypt this input" or "set up cofhe in Next.js."/fhenix-testsnpx claudepluginhub fhenixprotocol/fhenix-toolkit --plugin fhenix-toolkitOther plugins' skills for the same job