RedactCore.sol
Last updated
Last updated
is the central management contract for the Redact protocol. It handles the deployment and tracking of confidential tokens (ConfidentialERC20) and manages special cases like ConfidentialETH. The contract maintains a registry of all deployed confidential tokens and their relationships with underlying ERC20 tokens.
Maintains a mapping between ERC20 tokens and their confidential wrappers
Uses EnumerableMap
for efficient iteration and lookup
Prevents duplicate deployments of confidential wrappers
Manages ConfidentialETH (eETH) as a special case
Tracks stablecoins separately for potential special handling
Maintains WETH integration for ETH operations
Implements Ownable2Step
for secure ownership management
Restricts critical operations to the contract owner (EX: renaming ConfidentialERC20s)
getFherc20(address erc20)
Returns the address of the confidential wrapper for a given ERC20 token
Returns address(0)
if no wrapper exists
Used to look up confidential token addresses
getIsStablecoin(address erc20)
Returns whether a token is registered as a stablecoin
Used for special handling of stablecoin tokens
getIsWETH(address erc20)
Returns whether a token is the WETH contract
Used for ETH-specific operations
getDeployedFherc20s()
Returns an array of all deployed confidential tokens
Includes both the original ERC20 and its confidential wrapper
Useful for UI integration and monitoring
deployFherc20(IERC20 erc20)
Deploys a new ConfidentialERC20 wrapper for the specified token
Prevents deployment for:
Already wrapped tokens
Stablecoins
WETH (handled separately)
Emits Fherc20Deployed
event
updateStablecoin(address stablecoin, bool isStablecoin)
Updates the stablecoin status of a token
Restricted to contract owner
Emits StablecoinUpdated
event
updateFherc20Symbol(ConfidentialERC20 fherc20, string memory updatedSymbol)
Updates the symbol of a deployed confidential token
Restricted to contract owner
Emits Fherc20SymbolUpdated
event
Pre-configured during contract deployment
Uses WETH as the underlying token
Handles native ETH wrapping/unwrapping
Special gas optimizations for ETH operations
Can be marked as stablecoins for special handling
Prevents deployment of confidential wrappers for stablecoins
Allows for future implementation of stablecoin-specific features
Prepares for a future unified encrypted stablecoin.
Fherc20Deployed(address indexed erc20, address indexed fherc20)
Emitted when a new confidential token is deployed
Includes both the original and confidential token addresses
StablecoinUpdated(address indexed erc20, bool isStablecoin)
Emitted when a token's stablecoin status is updated
Includes the token address and new status
Fherc20SymbolUpdated(address indexed fherc20, string symbol)
Emitted when a confidential token's symbol is updated
Includes the token address and new symbol
Invalid_AlreadyDeployed()
: Attempted to deploy wrapper for already wrapped token
Invalid_Stablecoin()
: Attempted to deploy wrapper for stablecoin
Invalid_WETH()
: Invalid WETH address provided
Invalid_eETH()
: Invalid eETH address provided
Deploy WETH contract if not already deployed
Deploy ConfidentialETH (eETH) contract
Deploy RedactCore with WETH and eETH addresses
Check if token is already wrapped using getFherc20
If not wrapped, call deployFherc20
with the token address
Monitor Fherc20Deployed
event for confirmation
Use getDeployedFherc20s
to list all available confidential tokens
Use getFherc20
to look up specific token wrappers
Handle special cases for ETH and stablecoins appropriately
Access Control
Critical functions restricted to owner
Two-step ownership transfer process
Careful management of stablecoin status
Deployment Safety
Prevention of duplicate deployments
Validation of WETH and eETH addresses
Protection against stablecoin wrapping
Token Management
Secure symbol updates
Proper event emission for tracking
Safe handling of special cases