Skip to content

Farukest/Lab-Z

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

65 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Composable Template System for Privacy-Preserving Smart Contracts

Stop writing FHE boilerplate from scratch.
Generate production ready encrypted smart contracts in seconds with a single CLI command.
Choose from 44 standalone templates or compose custom contracts with 16 bases + 13 modules.

npm Built with FHEVM Next.js TypeScript Solidity License: MIT

β–Έ No installation required - run one command:

npx create-labz

β–Έ Or specify template and project name directly:

npx create-labz counter my-counter
npx create-labz auction my-auction
npx create-labz token my-token

↳ What you get:

my-project/
β”œβ”€β”€ contracts/        # FHEVM smart contract
β”œβ”€β”€ test/             # TypeScript test suite
β”œβ”€β”€ deploy/           # Deployment scripts
β”œβ”€β”€ hardhat.config.ts
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
└── .gitignore

CLI-SHORT-ezgif com-video-to-gif-converter

β–Έ Lab-Z provides two ways to generate FHE smart contracts:

Command Use Case Templates
labz create Quick start with ready-made examples 44 standalone templates
labz build Custom contracts with composable modules 16 bases + 13 modules

β–ŽKey Features

  • 44 standalone templates across 9 categories (basics, encryption, decryption, acl, input-proofs, anti-patterns, handles, openzeppelin, advanced)
  • 16 composable base templates for DeFi, gaming, voting, and identity
  • 13 feature modules for ACL, admin, security, and FHE operations
  • 9 OpenZeppelin ERC7984 + FHEVM production-ready confidential contracts
  • 9-phase validation pipeline preventing incompatible module combinations
  • CLI with 9 commands, interactive mode, and visual composer

β–ŽCLI Commands

Command Options
create -i, --interactive --git --install --open -o, --output -l, --list -y, --yes
build -i, --interactive -w, --with -t, --type --list-bases --list-modules --check --preview --dry-run -o, --output -y, --yes
list -c, --category -d, --difficulty -t, --tag
search -c, --category -d, --difficulty -b, --blocks -l, --limit
info -c, --code -t, --test -b, --blocks
compose -
doctor -p, --path
deploy -n, --network --verify --no-compile -y, --yes
test --keep -y, --yes

β–ŽInstallation

β–Έ Option A: Install via npm (recommended)

npm install -g @0xflydev/labz
#      ↑    ↑        ↑
#      β”‚    β”‚        └── Package name on npm registry
#      β”‚    β”‚
#      β”‚    └── Install globally (available everywhere)
#      β”‚
#      └── Node package manager

β–Έ Option B: Build from source

git clone https://github.com/Farukest/Lab-Z.git
cd Lab-Z

pnpm install
#  ↑     ↑
#  β”‚     └── Download dependencies (TypeScript, FHEVM libs, Hardhat, etc.)
#  β”‚
#  └── Package manager (npm alternative, faster)

pnpm build
#      ↑
#      └── Compile CLI tool and core packages (enables labz commands)

β–ŽOption 1: Quick Start with create

β–Έ Use create for ready-made, tested examples - no configuration needed:

labz create --list
#      ↑       ↑
#      β”‚       └── Show all 44 available templates grouped by category
#      β”‚
#      └── Standalone project generator (labz = Lab-Z CLI)

labz create prediction-market my-market
#      ↑           ↑              ↑
#      β”‚           β”‚              └── Your project folder name
#      β”‚           β”‚
#      β”‚           └── Template name (from --list)
#      β”‚
#      └── Standalone project generator (labz = Lab-Z CLI)

cd my-market && npm install && npx hardhat test
#     ↑              ↑               ↑
#     β”‚              β”‚               └── Run the included tests
#     β”‚              β”‚
#     β”‚              └── Install dependencies
#     β”‚
#     └── Enter your new project

↳ What you get: A complete standalone Hardhat project with contract, tests, and configuration.

CLI.RUN.mp4

β–ŽOption 2: Quick Start for Custom Build with build

β–Έ Use build for composable contracts with modules:

labz build --list-bases
#  ↑    ↑        ↑
#  β”‚    β”‚        └── Show 16 available base templates
#  β”‚    β”‚
#  β”‚    └── Composable contract generator
#  β”‚
#  └────── Lab-Z CLI tool

labz build --list-modules
#              ↑
#              └── Show 13 available feature modules

labz build auction my-auction --with acl/auction-sharing
#    ↑       ↑         ↑        ↑          ↑
#    β”‚       β”‚         β”‚        β”‚          └── Module name (category/name format)
#    β”‚       β”‚         β”‚        β”‚
#    β”‚       β”‚         β”‚        └── Flag to add feature modules
#    β”‚       β”‚         β”‚
#    β”‚       β”‚         └── Your project folder name
#    β”‚       β”‚
#    β”‚       └── Base template name (from --list-bases)
#    β”‚
#    └────── Lab-Z CLI tool

labz build token my-token --with acl/transient --with functions/encrypted-add
#                            ↑                          ↑
#                            β”‚                          └── Each --with adds another module
#                            β”‚
#                            └── Multiple modules can be combined

↳ What you get: A custom contract with selected modules injected into appropriate slots.

β–Žcreate vs build

labz create labz build
Source templates/creatable/{category}/ templates/buildable/projects/ + templates/buildable/modules/
Format Ready .sol + .test.ts .tmpl templates with slots
Modules No Yes (--with acl/transient, --with functions/encrypted-add)
Parameters No Yes (--type euint64, --type euint32)
Best for Learning, quick prototypes Production, customization

β–Žlabz create

β–Έ Create project from standalone templates (quick start).

labz create [template] [project-name] [options]

  -o, --output <dir>    # Output directory (default: current)
  -l, --list            # List available templates
  -y, --yes             # Skip prompts
  -i, --interactive     # Interactive mode with template selection
  --git                 # Initialize git repository
  --install             # Run npm install after creation
  --open                # Open project in VS Code

Examples:

labz create --list                              # Show all 44 templates
labz create counter my-counter -y               # Quick create, skip prompts
labz create -i                                  # Interactive template selection
labz create auction my-auction --git --install  # Full setup with git + deps

β–Žlabz build

β–Έ Build custom contracts with composable modules.

labz build [base] [project-name] [options]

  -w, --with <modules...>    # Feature modules to include
  #    ↑
  #    └── Example: labz build auction my-auction --with acl/transient -w admin/roles
  #    └── Explanation: Add FHE or admin modules to customize your contract

  -t, --type <type>          # Encrypted type (euint8, euint32, euint64)
  #    ↑
  #    └── Example: labz build token my-token --type euint64
  #    └── Explanation: Set the encrypted integer size for FHE operations

  -o, --output <dir>         # Output directory
  #    ↑
  #    └── Example: labz build auction my-auction --output ./my-projects
  #    └── Explanation: Generate project in a custom folder instead of current directory

  --list-bases               # List available base templates
  #    ↑
  #    └── Example: labz build --list-bases
  #    └── Explanation: See all 16 base templates (auction, token, voting, etc.)

  --list-modules             # List available modules
  #    ↑
  #    └── Example: labz build --list-modules
  #    └── Explanation: See all 13 modules grouped by category (acl, admin, functions, etc.)

  --check                    # Validate compatibility without generating
  #    ↑
  #    └── Example: labz build auction my-auction --with acl/transient --check
  #    └── Explanation: Test if your module combination is valid before generating

  --preview                  # Preview generated code
  #    ↑
  #    └── Example: labz build auction my-auction --with acl/transient --preview
  #    └── Explanation: See the generated Solidity code without creating files

  --dry-run                  # Show files without creating
  #    ↑
  #    └── Example: labz build auction my-auction --dry-run
  #    └── Explanation: List files that would be created without actually writing them

  -i, --interactive          # Interactive module selection
  #    ↑
  #    └── Example: labz build auction my-auction -i
  #    └── Explanation: Choose modules from a menu instead of typing --with flags

  -y, --yes                  # Skip prompts
  #    ↑
  #    └── Example: labz build auction my-auction -y
  #    └── Explanation: Auto-confirm all prompts for scripting/automation

β–Žlabz list

β–Έ List and filter available templates.

labz list [options]
#     ↑
#     └── List and filter all templates

  -c, --category <cat>      # Filter by category (basics, advanced, openzeppelin...)
  #        ↑
  #        └── Example: labz list --category advanced
  #        └── Explanation: Show only templates in the "advanced" category

  -d, --difficulty <level>  # Filter by difficulty (beginner, intermediate, advanced)
  #         ↑
  #         └── Example: labz list --difficulty beginner
  #         └── Explanation: Filter templates by learning curve level

  -t, --tag <tag...>        # Filter by tags
  #      ↑
  #      └── Example: labz list --tag defi privacy
  #      └── Explanation: Find templates tagged with specific keywords

β–Žlabz search

β–Έ Search templates by keyword.

labz search <query> [options]
#      ↑       ↑
#      β”‚       └── Search term (e.g., "encrypted voting", "auction")
#      β”‚
#      └── Search templates by keyword

  -c, --category <cat>      # Filter by category
  #      ↑
  #      └── Example: labz search "token" -c advanced
  #      └── Explanation: Search only in a specific category

  -d, --difficulty <level>  # Filter by difficulty
  #      ↑
  #      └── Example: labz search "voting" -d beginner
  #      └── Explanation: Search only templates of a specific difficulty

  -b, --blocks              # Include code block matches
  #      ↑
  #      └── Example: labz search "encrypted voting" -b
  #      └── Explanation: Also search inside annotated code blocks

  -l, --limit <n>           # Limit results (default: 10)
  #      ↑
  #      └── Example: labz search "auction" -l 5
  #      └── Explanation: Return only first N matching templates

β–Žlabz info

β–Έ Show detailed template information.

labz info <template> [options]
#     ↑       ↑
#     β”‚       └── Template name (e.g., auction, voting, token)
#     β”‚
#     └── Show template details

  -c, --code                # Show contract source code
  #      ↑
  #      └── Example: labz info auction -c
  #      └── Explanation: Display the full Solidity contract source

  -b, --blocks              # Show annotated code blocks
  #      ↑
  #      └── Example: labz info prediction-market -b
  #      └── Explanation: Show code sections with FHE explanations

  -t, --test                # Show test file
  #      ↑
  #      └── Example: labz info auction -t
  #      └── Explanation: Display the Hardhat test file for this template

β–Žlabz compose

β–Έ Interactive visual contract builder (terminal UI).

labz compose [contract-name]
#       ↑          ↑
#       β”‚          └── Optional contract name (e.g., MyContract)
#       β”‚
#       └── Visual contract builder with terminal UI
#
#  └── Explanation: Opens a terminal menu to select base + modules visually
image

β–Žlabz doctor

β–Έ Check FHEVM development environment.

labz doctor [options]
#     ↑
#     └── Diagnose your FHEVM development setup

  -p, --path <dir>          # Project directory to check
  #      ↑
  #      └── Example: labz doctor -p ./my-project
  #      └── Explanation: Check a specific project directory

# Checks performed:
# - Node.js version (>=18)
# - npm installation
# - FHEVM dependencies (@fhevm/solidity, @fhevm/hardhat-plugin)
# - Hardhat config with FHEVM plugin
# - .env file and environment variables
# - node_modules installation

β–Žlabz deploy

β–Έ Deploy contracts to network.

labz deploy [contract] [options]
#     ↑         ↑
#     β”‚         └── Contract name (auto-detect if not specified)
#     β”‚
#     └── Deploy contracts to blockchain

  -n, --network <network>   # Target network (default: localhost)
  #        ↑
  #        └── Example: labz deploy -n sepolia
  #        └── Networks: localhost, hardhat, sepolia, mainnet

  --verify                  # Verify contract on explorer
  #   ↑
  #   └── Example: labz deploy -n sepolia --verify
  #   └── Explanation: Verify on Etherscan after deployment

  --no-compile              # Skip compilation step
  #      ↑
  #      └── Example: labz deploy --no-compile
  #      └── Explanation: Use existing compiled artifacts

  -y, --yes                 # Skip confirmation prompts
  #    ↑
  #    └── Example: labz deploy -n mainnet -y
  #    └── Explanation: Auto-confirm for CI/CD pipelines

β–Žlabz test

β–Έ Test a template in a temporary directory.

labz test <template> [options]
#     ↑       ↑
#     β”‚       └── Template ID to test
#     β”‚
#     └── Generate, install, compile in temp folder

  --keep                    # Keep the temporary directory after test
  #  ↑
  #  └── Example: labz test counter --keep
  #  └── Explanation: Preserve project for manual testing

  -y, --yes                 # Skip confirmation prompts
  #    ↑
  #    └── Example: labz test counter -y
  #    └── Explanation: Auto-confirm for CI/CD pipelines

β–ŽCategories

Category Templates Description
basics 5 counter, add, multiply, boolean, bitwise
encryption 2 encrypt single/multiple values
decryption 4 user/public decryption (single & multiple)
acl 1 FHE.allow, allowThis, allowTransient
input-proofs 1 input proof security
anti-patterns 2 common mistakes to avoid
handles 4 FHE handle lifecycle, debugging, symbolic execution
openzeppelin 9 ERC7984 confidential tokens
advanced 16 DeFi, gaming, voting, identity

β–ŽAdvanced Templates

Template Description
prediction-market Polymarket-style with encrypted positions
dark-pool Private DEX order matching
sealed-tender Sealed-bid procurement
auction Blind auction with hidden bids
voting Private voting with homomorphic tallying
quadratic-vote Quadratic voting with encrypted credits
lottery Encrypted lottery with fair randomness
dice-game Provably fair dice
poker Encrypted poker hands
mystery-box NFT mystery box with hidden rarity
escrow Private escrow with dispute resolution
token Confidential ERC20-like token
age-gate Age verification without revealing
salary-proof Salary range proofs
blind-match Private preference matching
batch-reveal Multi-party batch reveal with single proof

β–ŽBase Templates

β–Έ 16 base templates in templates/buildable/projects/:

Category Bases
Basic counter, token, voting
DeFi auction, escrow, dark-pool, prediction-market
Gaming lottery, dice-game, mystery-box, poker
Governance quadratic-vote, sealed-tender
Identity age-gate, salary-proof, blind-match

β–ŽFeature Modules

β–Έ 13 modules in templates/buildable/modules/:

Category Modules
ACL transient, sharing, token-sharing, auction-sharing, voting-results
Admin ownable, roles
Security pausable, reentrancy
Functions encrypted-add, encrypted-mul, encrypted-compare
Events basic

β–ŽExample Combinations

labz build auction sealed-auction --with acl/auction-sharing --with admin/ownable
#           ↑            ↑                       ↑                       ↑
#           β”‚            β”‚                       β”‚                       └── Only owner can end auction
#           β”‚            β”‚                       β”‚
#           β”‚            β”‚                       └── FHE.allow() for encrypted bid sharing
#           β”‚            β”‚
#           β”‚            └── Project folder name
#           β”‚
#           └── Sealed-bid auction base template

labz build token private-erc20 --with acl/transient --with functions/encrypted-add --with admin/roles
#           ↑         ↑                     ↑                        ↑                      ↑
#           β”‚         β”‚                     β”‚                        β”‚                      └── Admin can mint, operator can pause
#           β”‚         β”‚                     β”‚                        β”‚
#           β”‚         β”‚                     β”‚                        └── FHE.add() for balance operations
#           β”‚         β”‚                     β”‚
#           β”‚         β”‚                     └── FHE.allowTransient() temporary decrypt
#           β”‚         β”‚
#           β”‚         └── Project folder name
#           β”‚
#           └── Confidential ERC20-like token

labz build voting dao-voting --with acl/voting-results --with functions/encrypted-compare
#           ↑        ↑                      ↑                           ↑
#           β”‚        β”‚                      β”‚                           └── FHE.lt(), FHE.gt() for vote counting
#           β”‚        β”‚                      β”‚
#           β”‚        β”‚                      └── Share encrypted results with auditors
#           β”‚        β”‚
#           β”‚        └── Project folder name
#           β”‚
#           └── Encrypted voting system

labz build counter my-counter --with functions/encrypted-mul --with security/pausable
#           ↑         ↑                        ↑                         ↑
#           β”‚         β”‚                        β”‚                         └── Emergency pause for security
#           β”‚         β”‚                        β”‚
#           β”‚         β”‚                        └── FHE.mul() encrypted multiplication
#           β”‚         β”‚
#           β”‚         └── Project folder name
#           β”‚
#           └── Simple encrypted counter

labz build token erc7984-defi --with acl/token-sharing --with functions/encrypted-add --with admin/roles
#           ↑         ↑                    ↑                         ↑                        ↑
#           β”‚         β”‚                    β”‚                         β”‚                        └── Role-based mint/burn permissions
#           β”‚         β”‚                    β”‚                         β”‚
#           β”‚         β”‚                    β”‚                         └── FHE.add() for confidential transfers
#           β”‚         β”‚                    β”‚
#           β”‚         β”‚                    └── OpenZeppelin ERC7984 compatible ACL sharing
#           β”‚         β”‚
#           β”‚         └── Project folder name
#           β”‚
#           └── OpenZeppelin-style confidential token base

β–Έ Production-ready confidential contracts combining OpenZeppelin's battle-tested patterns with Zama FHEVM encryption.

Template OpenZeppelin FHEVM Operations
erc7984-token ERC7984, Ownable2Step FHE.add, FHE.allow, FHE.isInitialized
erc7984-wrapper ERC7984ERC20Wrapper FHE.asEuint64, FHE.allowTransient
swap-erc7984-to-erc20 Ownable, ReentrancyGuard FHE.sub, public decryption
swap-erc7984-to-erc7984 ReentrancyGuard FHE.add, FHE.sub, FHE.allowTransient
lottery-erc7984 Ownable, ReentrancyGuard FHE.randEuint64, encrypted tickets
amm-erc7984 Ownable, ReentrancyGuard FHE.mul, FHE.div, encrypted liquidity
escrow-erc7984 ReentrancyGuard FHE.select, encrypted disputes
prediction-market-erc7984 Ownable, ReentrancyGuard FHE.add, encrypted positions
vesting-wallet Ownable, ReentrancyGuard euint128, encrypted schedules

β–ŽUsage Examples

labz create erc7984-token my-confidential-token
#       ↑         ↑               ↑
#       β”‚         β”‚               └── Your project folder name
#       β”‚         β”‚
#       β”‚         └── OpenZeppelin ERC7984 reference implementation
#       β”‚
#       └── Create standalone project (templates/creatable/openzeppelin/)

labz create erc7984-wrapper my-wrapper
#                 ↑             ↑
#                 β”‚             └── Project name
#                 β”‚
#                 └── Wrap existing ERC20 into confidential ERC7984

labz create amm-erc7984 private-amm
#               ↑           ↑
#               β”‚           └── Project name
#               β”‚
#               └── AMM with FHE-encrypted liquidity pools

cd my-confidential-token && npm install && npx hardhat test
#          ↑                     ↑                 ↑
#          β”‚                     β”‚                 └── Run included tests
#          β”‚                     β”‚
#          β”‚                     └── Install dependencies
#          β”‚
#          └── Enter project folder

β–Έ The build command runs 9 validation phases before generating code:

Phase Check
1 Base Compatibility
2 Module Compatibility
3 Dependency Resolution
4 Slot Validation
5 Type Validation
6 Name Collision
7 Exclusivity
8 Size Estimation
9 Semantic Conflicts
# Check before building
labz build token my-token --with admin/roles --with security/reentrancy --check

β–Έ Copy-paste examples for quick testing after cloning the repo.

β–ŽQuick Create Examples

β€’ Encrypted Counter

labz create counter my-counter

β€’ Blind Auction

labz create auction my-auction

β€’ Private Voting

labz create voting my-voting

β–ŽOpenZeppelin + FHE Examples

β€’ ERC7984 Confidential Token

labz create erc7984-token my-token

β€’ ERC20 to ERC7984 Wrapper

labz create erc7984-wrapper my-wrapper

β€’ Confidential AMM

labz create amm-erc7984 my-amm

β–ŽCustom Build Examples

β€’ Auction + FHE Sharing + Owner

labz build auction my-sealed-auction --with acl/auction-sharing --with admin/ownable

β€’ Token + Encrypted Transfers + Roles

labz build token my-private-token --with acl/transient --with functions/encrypted-add --with admin/roles

β€’ Voting + FHE Compare + Results

labz build voting my-dao-vote --with functions/encrypted-compare --with acl/voting-results

β–ŽRun & Test

cd my-counter && npm install && npx hardhat test

β–ŽOutput Structure

β–Έ Each command creates a folder with:

File Description
contracts/*.sol Solidity contract with FHE
test/*.test.ts Hardhat test file
hardhat.config.ts Pre-configured for FHEVM
package.json Dependencies ready

Lab-Z/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ core/                    # Template engine, registry, search
β”‚   β”œβ”€β”€ cli/                     # Command-line interface
β”‚   └── web/                     # Web UI (Next.js)
β”‚
β”œβ”€β”€ base-template/               # Hardhat project skeleton
β”‚
β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ creatable/               # For `labz create` (44 standalone)
β”‚   β”‚   β”œβ”€β”€ basics/              # counter, add, multiply, boolean, bitwise
β”‚   β”‚   β”œβ”€β”€ encryption/          # single, multiple
β”‚   β”‚   β”œβ”€β”€ decryption/          # user-single, user-multiple, public-single, public-multiple
β”‚   β”‚   β”œβ”€β”€ acl/                 # allow demo
β”‚   β”‚   β”œβ”€β”€ input-proofs/        # input proof security
β”‚   β”‚   β”œβ”€β”€ anti-patterns/       # common mistakes
β”‚   β”‚   β”œβ”€β”€ handles/             # handle lifecycle, debugging
β”‚   β”‚   β”œβ”€β”€ openzeppelin/        # ERC7984 examples
β”‚   β”‚   └── advanced/            # DeFi, gaming, voting, identity
β”‚   β”‚
β”‚   β”œβ”€β”€ buildable/               # For `labz build` (16 + 13)
β”‚   β”‚   β”œβ”€β”€ projects/            # 16 base templates (.tmpl)
β”‚   β”‚   └── modules/             # 13 feature modules
β”‚   β”‚       β”œβ”€β”€ acl/
β”‚   β”‚       β”œβ”€β”€ admin/
β”‚   β”‚       β”œβ”€β”€ security/
β”‚   β”‚       β”œβ”€β”€ functions/
β”‚   β”‚       └── events/
β”‚   β”‚
β”‚   └── _test/                   # Development test environment
β”‚
β”œβ”€β”€ scripts/
β”‚   └── generate-docs.ts         # GitBook documentation generator
β”‚
└── docs/                        # Generated documentation

cd templates/_test
npm install
npx hardhat test

# Generate GitBook-compatible docs
npm run docs:generate

↳ Output in docs/examples/ with SUMMARY.md for navigation.

β–ŽPrerequisites

  • Node.js 18+
  • pnpm 8+

β–ŽSetup

pnpm install
pnpm build

β–ŽAdding Templates

Standalone template (for create):

templates/creatable/{category}/{name}/
β”œβ”€β”€ {Name}.sol
β”œβ”€β”€ {Name}.test.ts
└── meta.json

Composable template (for build):

templates/buildable/projects/{name}/
β”œβ”€β”€ contracts/{Name}.sol.tmpl
β”œβ”€β”€ test/{Name}.test.ts.tmpl
└── meta.json

templates/buildable/modules/{category}/{name}/
β”œβ”€β”€ meta.json
└── inject/

Project Structure and Simplicity

Requirement Implementation Status
Use only Hardhat All templates use Hardhat Complete
One repo per example CLI generates standalone projects Complete
Keep each repo minimal contracts/, test/, hardhat.config.ts Complete
Shared base-template base-template/ directory Complete
Generate documentation scripts/generate-docs.ts Complete

Scaffolding and Automation

Requirement Implementation Status
CLI tool (create-fhevm-example) labz create, labz build Complete
Clone and customize template packages/cli/src/commands/create.ts Complete
Insert contract into contracts/ Automatic during generation Complete
Generate matching tests Every template includes tests Complete
Auto-generate docs from annotations scripts/generate-docs.ts with meta.json Complete

Required Example Templates

Category Requirement Template Status
Basic Simple FHE counter basics/counter Complete
Basic Arithmetic (FHE.add, FHE.sub) basics/add Complete
Basic Equality comparison (FHE.eq) basics/boolean Complete
Encryption Encrypt single value encryption/single Complete
Encryption Encrypt multiple values encryption/multiple Complete
Decryption User decrypt single decryption/user-single Complete
Decryption User decrypt multiple decryption/user-multiple Complete
Decryption Public decrypt single decryption/public-single Complete
Decryption Public decrypt multiple decryption/public-multiple Complete
Access Control FHE.allow acl/allow Complete
Access Control FHE.allowTransient Included in acl templates Complete
Input Proofs Explanation and usage input-proofs/ Complete
Anti-patterns View functions with encrypted anti-patterns/view-encrypted Complete
Anti-patterns Missing FHE.allowThis anti-patterns/missing-allow Complete
Handles Handle lifecycle handles/journey Complete
Handles Symbolic execution handles/symbolic-execution Complete
OpenZeppelin ERC7984 example openzeppelin/erc7984-token Complete
OpenZeppelin ERC7984 to ERC20 Wrapper openzeppelin/erc7984-wrapper Complete
OpenZeppelin Swap ERC7984 to ERC20 openzeppelin/swap-erc7984-to-erc20 Complete
OpenZeppelin Swap ERC7984 to ERC7984 openzeppelin/swap-erc7984-to-erc7984 Complete
OpenZeppelin Vesting Wallet openzeppelin/vesting-wallet Complete
Advanced Blind auction advanced/auction Complete

Additional Implementations

Category Template Description
Advanced batch-reveal Multi-party batch reveal with single proof verification
Advanced prediction-market Polymarket-style encrypted positions
Advanced dark-pool Private DEX order matching
Advanced sealed-tender Sealed-bid procurement system
Advanced quadratic-vote Quadratic voting with encrypted credits
Advanced lottery Encrypted lottery with fair randomness
Advanced dice-game Provably fair dice game
Advanced poker Encrypted poker hands
Advanced mystery-box NFT mystery box with hidden rarity
Advanced escrow Private escrow with dispute resolution
OpenZeppelin amm-erc7984 AMM with confidential liquidity
OpenZeppelin escrow-erc7984 Confidential escrow with ERC7984
OpenZeppelin prediction-market-erc7984 Prediction market with private bets
OpenZeppelin lottery-erc7984 Lottery using ERC7984 tokens

FHE Operations Coverage

Operation Templates Using It
FHE.asEuint64 All encryption templates
FHE.add basics/add, token, escrow
FHE.sub basics/add, token
FHE.mul basics/multiply
FHE.lt, FHE.gt, FHE.eq basics/boolean, voting, auction
FHE.select auction, voting, quadratic-vote
FHE.allow acl/allow, all decryption templates
FHE.allowThis All templates with storage
FHE.allowTransient acl/allow, token templates
FHE.makePubliclyDecryptable All public decryption templates
FHE.checkSignatures All public decryption templates
FHE.fromExternal All templates with input proofs
FHE.randEuint64 lottery, dice-game, mystery-box

Documentation Strategy

Requirement Implementation
JSDoc/TSDoc comments in tests All test files include detailed comments
Auto-generate markdown per repo scripts/generate-docs.ts creates 44 markdown files
Tag examples into docs meta.json with tags, categories, blocks
GitBook-compatible docs/SUMMARY.md, docs/examples/*.md

MIT License

Lab-Z - Composable FHE Smart Contract Templates

About

CLI toolkit for fhEVM: Instant project scaffolding, modular contract builder with 40+ ready templates and plus with interactive frontend-cli - Website : https://labzee.xyz

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors