LogoLogo
  • Introduction
  • Motivation
  • Roadmap
  • FAQ
  • Technical Walkthrough
  • Using Redact
    • Confidential Balances (Wallet)
    • Encrypting
    • Decrypting
    • Confidential Transfer (Sending)
  • Architecture
    • FHERC20 Token Standard
    • FHERC20.sol
    • ConfidentialERC20.sol
      • RedactCore.sol
    • CoFHE Overview
Powered by GitBook
On this page
  • Overview
  • External Functions
  • Events
  • Confidentiality Considerations
  1. Architecture

FHERC20.sol

PreviousFHERC20 Token StandardNextConfidentialERC20.sol

Last updated 16 days ago

Overview

is an implementation of the ERC20 standard that incorporates Fully Homomorphic Encryption (FHE) to enable confidential token balances and confidential transfers. To read more about the design of the FHERC20 standard go here: FHERC20 Token Standard

External Functions

View Functions

isFherc20()

  • Returns true to indicate this is a FHERC20 token

  • Intended to be used by explorers and wallets in the future to change how the encrypted balances and encrypted transactions are displayed.

name()

  • Returns the token name.

  • In Redact, the token name of a ConfidentialERC20 is prefixed with Confidential . For example Chainlink Token would become Confidential Chainlink Token.

symbol()

  • Returns the token symbol.

  • In Redact, the token name of a ConfidentialERC20 is prefixed with e . For example LINK would become eLINK.

decimals()

  • Returns the number of decimals for token display

  • In Redact, the number of decimals of a ConfidentialERC20 is the same as the underlying ERC20.

totalSupply()

  • Returns the indicated total supply

encTotalSupply()

  • Returns the ctHash of the encrypted total supply.

balanceOfIsIndicator()

  • Returns true to indicate that balanceOf returns an indicator value rather than a true balance value.

indicatorTick()

  • Returns the size of the indicator tick

balanceOf(address account)

  • Returns the indicated balance for an account

  • Value ranges from 0.0000 to 0.9999

  • Increases by 0.0001 when receiving confidential tokens, reduces by 0.0001 when sending.

encBalanceOf(address account)

  • Returns a ctHash representing the true encrypted balance of an account

State-Changing Functions

encTransfer(address to, InEuint128 memory inValue)

encTransfer(address to, euint128 inValue)

  • Transfers encrypted tokens from sender to recipient

  • Can either accept an encrypted input variable, or an encrypted uint128, as the amount to transfer.

  • Emits both a Transfer event (with an indicated amount) and an EncTransfer event (with an encrypted ctHash amount)

encTransferFrom(address from, address to, InEuint128 memory inValue, FHERC20_EIP712_Permit calldata permit)

  • Transfers encrypted tokens on behalf of another address

  • Requires valid FHERC20_EIP712 permit signature

  • Emits both a Transfer event (with an indicated amount) and an EncTransfer event (with an encrypted ctHash amount)

Restricted Functions

The following standard ERC20 functions are intentionally restricted to prevent accidental usage:

  • transfer(address, uint256)

  • allowance(address, address)

  • approve(address, uint256)

  • transferFrom(address, address, uint256)

These functions will revert with FHERC20IncompatibleFunction() to prevent the contract from being treated as a standard ERC20.

Events

Transfer(address indexed from, address indexed to, uint256 value)

  • Emitted on token transfers

  • Uses indicated balance values for compatibility

EncTransfer(address indexed from, address indexed to, uint256 value)

  • Emitted on token transfers

  • Includes the encrypted transfer value as a ctHash

Confidentiality Considerations

  1. All balance operations use FHE to maintain confidentiality

  2. Traditional allowances are replaced with FHENIX_EIP712 permits to be used during a transaction

  3. Indicated balances are used for UI/UX only and should not be used for any logic

Read more here:

FHERC20.sol
Indicated Balances