Introduction

Welcome to the fhEVM Examples library. These examples span multiple categories and are designed to help you learn privacy-preserving smart contract patterns step by step.

Start here

Example map

Auctions

Example
Concept
Difficulty

Sealed-bid auction with encrypted bids and public reveal

Advanced

Dutch auction with descending price and encrypted reserve

Intermediate

Basic

Example
Concept
Difficulty

Missing FHE.allowThis breaks reuse of stored handles

Intermediate

Missing FHE.allow(user) blocks user decryption

Intermediate

View functions return encrypted handles, not plaintext

Intermediate

Store multiple encrypted values with a single proof

Beginner

Store one encrypted value and grant permissions

Beginner

Add two encrypted values with FHE.add

Beginner

Encrypted counter using FHE.add and FHE.sub

Beginner

Compare two encrypted values using FHE.eq

Beginner

Conditional selection on encrypted values using FHE.select

Beginner

Subtract two encrypted values with FHE.sub

Beginner

Handles are opaque references; FHE ops create derived handles (symbolic execution)

Intermediate

Store encrypted handles and reuse them across calls

Intermediate

Input proofs bind encrypted inputs to a contract and sender

Intermediate

Public decryption flow for multiple encrypted values

Intermediate

Public decryption flow for a single encrypted value

Intermediate

User decryption flow for multiple encrypted results

Beginner

User decryption flow for a single encrypted result

Beginner

Games

Example
Concept
Difficulty

Encrypted letter comparison with branch-free feedback

Intermediate

Identity

Example
Concept
Difficulty

User-controlled FHE.allow() permissions

Intermediate

Combining encrypted compliance checks with FHE.and()

Intermediate

FHE.select() for branch-free compliant transfers

Advanced

FHE comparison (le, ge) for threshold checks without revealing values

Beginner

ERC7984ERC20Wrapper (ERC20 ↔ ERC7984) + KYC-gated wrap/unwrap

Advanced

Minimal ERC7984 token with confidential mint + transfer

Beginner

OpenZeppelin ERC7984Restricted + public KYC allowlist (revert-based compliance)

Intermediate

ERC7984ObserverAccess for opt-in audit / compliance observers

Intermediate

Storing encrypted identity attributes (euint8, euint16, ebool)

Intermediate

ERC7984 → ERC20 swap using public decryption + FHE.checkSignatures (KYC is public)

Advanced

ERC7984 → ERC7984 swap using FHE.allowTransient across token contracts (KYC is public)

Intermediate

FHE.allowTransient() for one-transaction permissions between contracts

Intermediate

Confidential vesting (ERC7984) + public KYC gating + factory/clones

Advanced

Last updated