Skip to content

FhenixProtocol/cofhe-foundry-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoFHE Foundry Starter

A starter template for developing Fully Homomorphic Encryption (FHE) smart contracts using Fhenix CoFHE and Foundry.

Prerequisites

Quick Start

# Clone the repository
git clone <repo-url>
cd cofhe-foundry-starter

# Install Solidity dependencies
npm install

# Compile contracts
forge build

# Run tests
forge test -vvv

Project Structure

├── src/
│   └── Counter.sol           # Example FHE counter contract
├── test/
│   └── Counter.t.sol         # Comprehensive Solidity tests
├── script/
│   ├── DeployCounter.s.sol   # Deployment script
│   ├── IncrementCounter.s.sol # Increment interaction
│   └── ResetCounter.s.sol    # Reset with encrypted input
├── foundry.toml              # Foundry configuration
├── package.json              # npm dependencies
└── remappings.txt            # Solidity import remappings

How FHE Testing Works

Tests use CoFheTest from @cofhe/mock-contracts, which provides mock contract deployment, encrypted input creation, plaintext assertions, and permission testing -- all in Solidity with no JS SDK needed.

For the full testing guide covering all helper functions, FHE operations, ACL, permits, and patterns, see TESTING.md.

Deployment

Setup

cp .env.example .env
# Edit .env with your private key and RPC URLs

Deploy to Testnet

# Ethereum Sepolia
npm run deploy:eth-sepolia

# Arbitrum Sepolia
npm run deploy:arb-sepolia

# Base Sepolia
npm run deploy:base-sepolia

Interact with Deployed Contract

# Set the deployed contract address
export COUNTER_ADDRESS=0x...

# Increment the counter
source .env && forge script script/IncrementCounter.s.sol --rpc-url eth-sepolia --broadcast

Gas Report

npm run test:gas

Dependencies

Package Purpose
@fhenixprotocol/cofhe-contracts FHE type definitions and operations (FHE.sol)
@cofhe/mock-contracts Mock contracts for local testing + Foundry helpers
@openzeppelin/contracts Standard contract utilities
forge-std Foundry standard library (Test, Script, cheatcodes)

Configuration Notes

  • EVM Version: cancun — required for MockACL's transient storage (tstore/tload)
  • Code Size Limit: 100000 — mock contracts exceed the default 24KB limit
  • Solidity Version: 0.8.25 — compatible with CoFHE contracts

Resources

About

Public Starter repository for Fhenix CoFHE contract development using Foundry

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors