Overview
FHERC20Wrapper enables you to convert standard ERC20 tokens into confidential FHERC20 tokens and vice versa. This creates a privacy layer on top of existing tokens, allowing users to transact privately while maintaining interoperability with the broader DeFi ecosystem.Privacy Layer
Transform transparent ERC20 balances into encrypted FHERC20 balances for confidential transactions.
Reversible
Unwrap confidential tokens back to standard ERC20 at any time through a secure claim process.
1:1 Backing
Each wrapped token is backed 1:1 by the underlying ERC20 token held in the wrapper contract.
DeFi Bridge
Bridge between transparent DeFi protocols and confidential trading/transfers.
How It Works
1
Wrap Tokens
User deposits standard ERC20 tokens into the wrapper contract, which mints an equivalent amount of confidential FHERC20 tokens.
2
Confidential Transfers
User can now transfer the wrapped tokens confidentially using all FHERC20 features while balances remain encrypted.
3
Unwrap Request
When ready to exit, user burns confidential tokens and requests decryption of the burned amount.
4
Claim Tokens
After decryption completes, user claims their original ERC20 tokens from the wrapper contract.
Wrapping Tokens
Function Signature
to: Address to receive the wrapped (confidential) tokensvalue: Amount of ERC20 tokens to wrap
How Wrapping Works
- User approves wrapper contract to spend ERC20 tokens
- Wrapper transfers ERC20 tokens from user to itself
- Wrapper mints equivalent confidential FHERC20 tokens to recipient
- Wrapped tokens can now be used confidentially
Example
Unwrapping Tokens
Unwrapping is a two-step process due to the asynchronous nature of FHE decryption.Step 1: Unwrap (Burn and Request Decryption)
to: Address to receive the unwrapped ERC20 tokensvalue: Amount of confidential tokens to unwrap
- Burns the specified amount of confidential tokens from caller
- Requests decryption of the burned amount
- Creates a claim for the recipient
Due to the zero-replacement behavior, if you attempt to unwrap more than your balance, zero tokens will be burned and you’ll have a claim for zero tokens.
Step 2: Claim Unwrapped Tokens
After decryption completes, claim your ERC20 tokens:Claim Specific Amount
ctHash: The ciphertext hash identifying the specific claim
Claim All Unwrapped Tokens
Claim Management
Getting Claim Information
Getting User Claims
Complete Example
Symbol Management
The wrapper owner can update the token symbol:- Distinguishing wrapped versions (e.g., “wUSDC” vs “USDC”)
- Rebrand if needed
- Fix initial symbol mistakes
Security Considerations
Token Compatibility
Token Compatibility
Always test with the specific token before deploying to production.
Unwrap Timing
Unwrap Timing
Unwrapping requires waiting for decryption:Implement proper UI feedback for this waiting period.
Zero-Replacement
Zero-Replacement
If you unwrap more than your balance, you get zero:Always ensure sufficient balance before unwrapping.
Claim Management
Claim Management
Users can accumulate multiple pending claims:Provide UI to track and manage multiple claims.
Use Cases
DEX Privacy
Wrap tokens before trading on a confidential DEX, then unwrap profits. Your trading activity and positions remain private.
Private Payments
Wrap stablecoins for confidential payments, then unwrap to cash out to bank accounts or fiat on-ramps.
Confidential Payroll
Companies can wrap tokens, distribute salaries confidentially, and employees unwrap to receive standard tokens.
Privacy Pools
Create pools where users deposit tokens for privacy, transact confidentially, and withdraw when desired.
Related Topics
- Understand Unwrap Claims for detailed claim management
- Learn about Core Features for confidential transfers
- Review Best Practices for secure implementations