ConfidentialERC20.sol
Last updated
Last updated
(and ) is an implementation of the FHERC20 standard that enables confidential token operations for any ERC20 token. It wraps existing ERC20 tokens to provide confidential balance and transfer functionality while maintaining compatibility with the original token's properties.
ConfidentialERC20 wraps existing ERC20 tokens to provide confidential functionality
The wrapped token maintains the same name (prefixed with "Confidential") and symbol (prefixed with "e")
Decimals are preserved from the original token
The original token can be deposited and withdrawn through the contract using encrypt
and decrypt
Inherits all FHE functionality from FHERC20
Balances are stored as encrypted values (euint128
)
Uses indicated balances for UI/UX compatibility
See FHERC20 Documentation for detailed balance mechanics: FHERC20.sol
The contract implements a claim system through the ConfidentialClaim.sol
contract that enables:
Creation of confidential claims for token amounts
Decryption of claimed amounts
Tracking of user claims
Batch claiming functionality
underlying()
Returns the address of the underlying ERC20 token
Used to identify the original token being wrapped
isConfidentialERC20()
Returns true
to indicate this is a ConfidentialERC20 token
getClaim(uint256 ctHash)
Returns claim information for a specific encrypted amount
Includes requested amount, decrypted amount, and claim status
Only accessible to authorized parties
getUserClaims(address user)
Returns all claims associated with a user
Includes both pending and claimed amounts
Only accessible to authorized parties
encrypt(address to, uint128 amount)
Deposits the specified amount of the underlying token
Mints an equivalent amount of confidential tokens
Requires approval of the underlying ERC20
decrypt(address to, uint128 amount)
Burns the specified amount of confidential tokens
Transfers the equivalent amount of the underlying token
Requires sufficient confidential token balance
ConfidentialETH is a special case of ConfidentialERC20 that wraps the native ETH token. ConfidentialETH allows encrypting of both ETH (using encryptETH
) and WETH (using encryptWETH
). When decrypting ConfidentialETH, it is always decrypted as ETH, never WETH.
Symbol
ConfidentialETH symbol is eETH
Uses msg.value
instead of token approval when encrypting ETH
into eETH
No need for separate token approval
Unwraps WETH back to ETH
Sends native ETH to the recipient
Handles gas considerations for ETH transfers
Creation
A claim is created with an encrypted amount
The claim is associated with a specific recipient
The encrypted amount is stored with its hash
Decryption
The encrypted amount is decrypted using FHE
The decrypted amount is verified against the original request
The claim status is updated
Processing
The decrypted amount is transferred to the recipient
The claim is marked as claimed
The claim is removed from the user's active claims
Users can claim multiple amounts in a single transaction
Gas efficient for processing multiple claims
Maintains confidentiality of individual amounts
Deposit(address indexed user, uint256 amount)
Emitted when underlying tokens are deposited
Includes the deposit amount
Withdraw(address indexed user, uint256 amount)
Emitted when confidential tokens are withdrawn
Includes the withdrawal amount
ClaimCreated(address indexed user, uint256 ctHash, uint256 amount)
Emitted when a new claim is created
Includes the claim hash and amount
ClaimProcessed(address indexed user, uint256 ctHash, uint256 amount)
Emitted when a claim is processed
Includes the claim hash and decrypted amount