FHERC20.sol
Overview
FHERC20.sol 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
trueto indicate this is a FHERC20 tokenIntended 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 exampleChainlink Tokenwould becomeConfidential Chainlink Token.
symbol()
Returns the token symbol.
In Redact, the token name of a ConfidentialERC20 is prefixed with
e. For exampleLINKwould becomeeLINK.
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
ctHashof the encrypted total supply.
balanceOfIsIndicator()
Returns
trueto indicate thatbalanceOfreturns 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.
Read more here: Indicated Balances
encBalanceOf(address account)
Returns a
ctHashrepresenting 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
ctHashamount)
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
ctHashamount)
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)
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)
EncTransfer(address indexed from, address indexed to, uint256 value)Emitted on token transfers
Includes the encrypted transfer value as a
ctHash
Confidentiality Considerations
All balance operations use FHE to maintain confidentiality
Traditional allowances are replaced with FHENIX_EIP712 permits to be used during a transaction
Indicated balances are used for UI/UX only and should not be used for any logic
Last updated

