Skip to main content

SolAgent-FHE

AI-powered FHE (Fully Homomorphic Encryption) smart contract generator for Fhenix CoFHE.

Generate privacy-preserving Solidity contracts from natural language descriptions. The AI understands FHE patterns, encrypted types, access control, and compiles contracts automatically using Hardhat.

Installation

pip install solagent-fhe

Requirements: Node.js 18+ and the cofhe-hardhat-starter project for compilation.

Quick Start

CLI

# Generate a contract from description
solagent-fhe "Create a private voting contract with encrypted vote counts"

# Use a predefined task
solagent-fhe --task-key voting

# Run benchmark (all 9 contract types)
solagent-fhe --benchmark

# List available tasks
solagent-fhe --list-tasks

# Use Groq instead of DeepSeek
solagent-fhe --provider groq "Create a sealed-bid auction"

Python API

import asyncio
from solagent_fhe import generate, benchmark, FHE_TASKS

async def main():
    # Generate a single contract
    result = await generate(
        task="Create a private token with encrypted balances",
        contract_name="MyToken",
        provider="deepseek",  # or "groq"
    )

    if result['compiled']:
        print(f"Contract generated: {result['name']}.sol")
        print(f"Refine rounds: {result['rounds']}")
        print(result['code'])

    # Run full benchmark
    results = await benchmark(provider="deepseek")

asyncio.run(main())

Environment Variables

Variable Required Description
DEEPSEEK_API_KEY Yes* DeepSeek API key for code generation
GROQ_API_KEY Yes* Groq API key (alternative provider)
SOLAGENT_HARDHAT_DIR No Path to cofhe-hardhat-starter (auto-detected)

*At least one LLM provider key required.

Supported Contract Types

Key Contract Description
voting ConfidentialVoting Encrypted vote counts, admin-controlled
auction SealedBidAuction Hidden bids, FHE comparison for winner
token PrivateToken ERC20-like with encrypted balances
lottery BlindLottery FHE random number for winner selection
threshold SecretThreshold Encrypted threshold comparison
payroll ConfidentialPayroll Hidden salaries, batch payments
dex PrivateDEX Encrypted swap amounts and balances
dao PrivateDAO Encrypted voting power and tallies
vault FHESavingsVault Encrypted deposits with interest

How It Works

Description ──→ [Code Agent] ──→ Solidity ──→ [Hardhat Compile]
                  (DeepSeek)        │              │
                                    │         ✓ Success → Done
                                    │              │
                                    │         ✗ Errors
                                    │              │
                                    └──→ [Refine Agent] ──→ Fix ──→ Recompile
                                          (Groq/DeepSeek)     (up to 10 rounds)

Benchmark: 5/5 contracts compile successfully (100%)

FHE Patterns

The generator understands all Fhenix CoFHE patterns:

  • Encrypted types: euint8–euint256, ebool, eaddress
  • Operations: FHE.add, FHE.sub, FHE.select, FHE.gte, etc.
  • Access control: FHE.allowThis(), FHE.allow(ct, addr)
  • Decryption: Async FHE.decrypt() + getDecryptResultSafe()
  • Random: FHE.randomEuint32() for on-chain randomness
  • Input: InEuint64 for client-encrypted values

License

MIT

Metadata

Release files for solagent-fhe 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for solagent-fhe 0.1.0
File Size Uploaded Provenance
solagent_fhe-0.1.0.tar.gz 10.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for solagent-fhe 0.1.0
File Interpreter ABI Platform
solagent_fhe-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.5 kB

Release files / solagent_fhe-0.1.0.tar.gz

Download URL solagent_fhe-0.1.0.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bedac791c054f7ce8dc8ed9e33e00aaa8926991082cfbbc1722b9c5b5f359178
BLAKE2b-256 checksum
How to use checksums
096dad96b2f0bb5220b50f2d373d02833f6aae35ee793cee4712371aa23e7b35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / solagent_fhe-0.1.0-py3-none-any.whl

Download URL solagent_fhe-0.1.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76a2e4e7dec6f9da1f8a7fa963a32f5f549be9e28aeb2bfcab1d95ed73234535
BLAKE2b-256 checksum
How to use checksums
7c5d9188fb18926bfd1e49654d06cb03cc19b065d1b399b17a1b91fbf5757e45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for solagent-fhe 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page