Overview
FHERC20 Wrappers enable you to convert standard ERC20 tokens or native tokens (e.g., ETH) 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 or native token balances into encrypted FHERC20 balances for confidential transactions.
Reversible
Unshield confidential tokens back to standard ERC20 or native tokens at any time through a secure claim process.
1:1 Backing
Each shielded token is backed by the underlying token held in the wrapper contract, with a rate-based conversion for decimal normalization.
DeFi Bridge
Bridge between transparent DeFi protocols and confidential trading/transfers.
Wrapper Types
FHERC20 provides two wrapper contracts:
Both wrappers share the same unshielding flow via the
FHERC20WrapperClaimHelper.
Rate and Decimal Conversion
Wrappers normalize token decimals to fit within theeuint64 type. The maximum confidential decimals default to 6 (configurable via _maxDecimals()).
rate() = 10^(18 - 6) = 10^12- Shielding
1,000,000,000,000(1e12) underlying tokens produces1confidential token - Amounts are truncated to the nearest multiple of
rate()during shielding
Some non-standard tokens such as fee-on-transfer or other deflationary-type tokens are not supported by the wrapper.
ERC20 Wrapper (FHERC20ERC20Wrapper)
How It Works
1
Shield Tokens
User deposits standard ERC20 tokens into the wrapper contract, which mints an equivalent amount of confidential FHERC20 tokens (divided by the rate).
2
Confidential Transfers
User can now transfer the shielded tokens confidentially using all FHERC20 features while balances remain encrypted.
3
Unshield Request
When ready to exit, user burns confidential tokens. The burned amount is marked as publicly decryptable via
FHE.allowPublic, and a claim is created.4
Decrypt Off-Chain
The user (or anyone) requests decryption of the burned amount off-chain via
decryptForTx, receiving the plaintext and a decryption proof.5
Claim Tokens
The user submits the plaintext and proof on-chain via
claimUnshielded. The contract verifies the proof and transfers the underlying ERC20 tokens (multiplied by the rate).Shielding Tokens
to: Address to receive the shielded (confidential) tokensamount: Amount of ERC20 tokens to shield (will be truncated to nearest multiple ofrate())
ERC1363 Direct Shielding
The ERC20 wrapper also implements the ERC1363onTransferReceived callback, allowing users to shield tokens in a single transaction without a separate approval step:
Native Wrapper (FHERC20NativeWrapper)
The native wrapper shields native tokens (e.g., ETH) or WETH into confidential FHERC20 tokens.Shield Native Tokens
to: Address to receive the shielded tokensvalue: Amount of WETH to shield (forshieldWrappedNative)msg.value: Amount of native currency to shield (forshieldNative)
rate(). Any dust below the threshold is refunded to the caller.
Unshielding Tokens
Unshielding is a three-step process shared by both wrapper types: burn on-chain, decrypt off-chain, then claim with proof.Step 1: Unshield (Burn and Create Claim)
from: Address whose confidential tokens to burn (caller must befromor an operator forfrom)to: Address to receive the underlying tokens after claimingamount: Amount of confidential tokens to unshield
- Burns the specified amount of confidential tokens from
from - Calls
FHE.allowPublic(burned)so anyone can request decryption of the burned amount - Creates a claim for the recipient
Due to the zero-replacement behavior, if you attempt to unshield more than your balance, zero tokens will be burned and you’ll have a claim for zero tokens.
Step 2: Decrypt Off-Chain
Retrieve the claim’sctHash using getUserClaims, then request decryption via decryptForTx. Since FHE.allowPublic was called, no permit is needed:
Step 3: Claim Unshielded Tokens
Submit the plaintext and proof to the contract. The contract verifies the proof viaFHE.verifyDecryptResult and transfers the underlying tokens (multiplied by the rate):
unshieldRequestId: The ciphertext hash identifying the claimunshieldAmountCleartext: The plaintext value returned bydecryptForTxdecryptionProof: The proof proving the plaintext is authentic
Batch Claiming
You can claim multiple unshield requests in a single transaction:Claim Management
Claim Structure
Getting Claim Information
Getting User Claims
Events
Complete Examples
ERC20 Wrapper
Native Wrapper
Security Considerations
Token Compatibility
Token Compatibility
Always test with the specific token before deploying to production.
Claim Flow
Claim Flow
Claiming requires completing the off-chain decryption step first:Implement proper UI feedback for the decryption step.
Zero-Replacement
Zero-Replacement
If you unshield more than your balance, you get zero:Always ensure sufficient balance before unshielding.
Rate Conversion
Rate Conversion
Be aware of the rate conversion when shielding and unshielding:
Claim Management
Claim Management
Users can accumulate multiple pending claims. Use batch claiming for efficiency:Provide UI to track and manage multiple claims.
Use Cases
DEX Privacy
Shield tokens before trading on a confidential DEX, then unshield profits. Your trading activity and positions remain private.
Private Payments
Shield stablecoins for confidential payments, then unshield to cash out to bank accounts or fiat on-ramps.
Confidential Payroll
Companies can shield tokens, distribute salaries confidentially, and employees unshield to receive standard tokens.
Privacy Pools
Create pools where users deposit tokens for privacy, transact confidentially, and withdraw when desired.
Related Topics
- Learn about Core Features for confidential transfers
- Review Best Practices for secure implementations