npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fhenix-confidential-contracts

v0.2.1

Published

Privacy-preserving FHERC-20 token standard for Fhenix Protocol

Downloads

463

Readme

Fhenix Confidential Contracts

NPM Package CI Status License: MIT

A privacy-preserving FHERC-20 token standard implementation built on Fhenix Protocol's Fully Homomorphic Encryption (FHE).

Warning: These contracts are in active development and have not been audited. Use at your own risk.

Overview

This library provides Solidity smart contracts for confidential ERC-20 tokens using FHE. Token balances and transfer amounts remain encrypted on-chain while still supporting standard token operations.

Key Features

  • FHERC20 - Base confidential token with encrypted balances
  • FHERC20Permit - EIP-712 signature-based operator approval
  • FHERC20Wrapper - Wrap standard ERC-20 tokens into confidential tokens
  • FHERC20UnwrapClaim - Claim management for unwrapping back to ERC-20

Installation

Hardhat (npm/yarn/pnpm)

npm install fhenix-confidential-contracts
# or
yarn add fhenix-confidential-contracts
# or
pnpm add fhenix-confidential-contracts

Foundry

forge install FhenixProtocol/fhenix-confidential-contracts

Usage

Basic FHERC20 Token

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { FHERC20 } from "fhenix-confidential-contracts/contracts/FHERC20.sol";

contract MyConfidentialToken is FHERC20 {
    constructor() FHERC20("My Confidential Token", "eMCT", 18) {
        // Mint initial supply to deployer
        _mint(msg.sender, 1000000 * 10**18);
    }
}

FHERC20 with Permit

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { FHERC20 } from "fhenix-confidential-contracts/contracts/FHERC20.sol";
import { FHERC20Permit } from "fhenix-confidential-contracts/contracts/FHERC20Permit.sol";

contract MyPermitToken is FHERC20, FHERC20Permit {
    constructor()
        FHERC20("My Permit Token", "eMPT", 18)
        FHERC20Permit("My Permit Token")
    {
        _mint(msg.sender, 1000000 * 10**18);
    }
}

Wrapping Existing ERC-20 Tokens

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { FHERC20Wrapper } from "fhenix-confidential-contracts/contracts/FHERC20Wrapper.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract MyWrappedToken is FHERC20Wrapper {
    constructor(IERC20 underlyingToken)
        FHERC20Wrapper(underlyingToken, "")
    {}
}

// Usage:
// 1. Deploy with existing ERC-20 address
// 2. Approve the wrapper contract to spend your ERC-20 tokens
// 3. Call wrap(recipient, amount) to mint confidential tokens
// 4. Call unwrap(recipient, encryptedAmount) to initiate unwrapping
// 5. Call claimUnwrapped(ctHash) after decryption completes

Contract Architecture

FHERC20 (base)
├── FHERC20Permit (EIP-712 signatures)
└── FHERC20Wrapper (ERC-20 wrapping)
    └── FHERC20UnwrapClaim (claim management)

Interfaces:
├── IFHERC20
├── IFHERC20Permit
├── IFHERC20Errors
├── IFHERC20Receiver
└── IWETH

Utilities:
├── FHERC20Utils
└── FHESafeMath

Key Concepts

Indicated Balances

FHERC20 tokens use an "indicator" system for backwards compatibility with existing ERC-20 infrastructure (wallets, block explorers). The balanceOf function returns a value between 0.0000 and 0.9999 that indicates balance changes without revealing actual amounts.

This allows wallets to detect when balances change while keeping the actual amounts private.

Operators vs Allowances

Traditional ERC-20 allowances are replaced with time-limited operators to prevent encrypted balance leakage. Unlike allowances where you approve a specific amount, operators can transfer any amount on behalf of a holder until their permission expires.

// Set an operator (replaces approve)
token.setOperator(spender, deadline);

// Check if address is an operator
bool isOp = token.isOperator(holder, spender);

// Transfer as operator (replaces transferFrom with allowance)
token.confidentialTransferFrom(from, to, encryptedAmount);

Confidential Transfers

// Direct encrypted transfer
token.confidentialTransfer(to, encryptedAmount);

// Operator-initiated transfer
token.confidentialTransferFrom(from, to, encryptedAmount);

// Transfer with callback to receiving contract
token.confidentialTransferAndCall(to, encryptedAmount, data);

Security Considerations

FHE-Specific Security

  1. Balance Indicators Are Public: The indicator values (0.0000-0.9999) reveal transfer activity but not amounts
  2. Operator Model: Operators have full transfer authority during their approval period - use short deadlines
  3. Decryption Delays: Unwrapping operations require waiting for FHE decryption to complete

Smart Contract Security

  1. Reentrancy: confidentialTransferAndCall includes callback functionality - receiving contracts should follow checks-effects-interactions
  2. Integer Operations: FHE operations have different overflow behavior than standard Solidity

Audit Status

Warning: These contracts have not been audited. A security audit is planned before v1.0.0 release.

Reporting Vulnerabilities

Please report security vulnerabilities through our Security Policy.

Dependencies

Development

# Install dependencies
pnpm install

# Compile contracts
pnpm compile

# Run tests
pnpm test

# Run tests with gas reporting
pnpm gas

# Format code
pnpm format

# Lint
pnpm lint

Contributing

Contributions are welcome! Please read our Contributing Guide before submitting a Pull Request.

License

Released under the MIT License.