ERC7984 to ERC20 Wrapper
Bridge between public ERC20 and confidential ERC7984 tokens. Enables wrapping (public → private) and unwrapping (private → public) of tokens, facilitating migration into the confidential ecosystem.
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.27;
import {ZamaEthereumConfig} from "@fhevm/solidity/config/ZamaConfig.sol";
import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";
import {
ERC7984ERC20Wrapper as ERC7984ERC20WrapperBase,
ERC7984
} from "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol";
/**
* @notice Bridge between public ERC20 and confidential ERC7984 tokens.
* Enables wrapping (public → private) and unwrapping (private → public)
* of tokens, facilitating migration into the confidential ecosystem.
*
* @dev WRAP: Public → Private (instant); UNWRAP: Private → Public (KMS proof).
*/
contract ERC7984ERC20WrapperExample is
ERC7984ERC20WrapperBase,
ZamaEthereumConfig
{
/// @notice Creates a new ERC20-to-ERC7984 wrapper
/// @param token The ERC20 token to wrap
/// @param name Name for the wrapped ERC7984 token
/// @param symbol Symbol for the wrapped ERC7984 token
/// @param uri Metadata URI for the wrapped token
constructor(
IERC20 token,
string memory name,
string memory symbol,
string memory uri
) ERC7984ERC20WrapperBase(token) ERC7984(name, symbol, uri) {}
// 📦 Inherited from ERC7984ERC20Wrapper:
//
// wrap(address to, uint256 amount)
// - User approves this contract for ERC20
// - ERC20 is escrowed, ERC7984 is minted
//
// unwrap(address from, address to, euint64 amount)
// - ERC7984 is burned
// - Decryption is requested
// - After proof, ERC20 is released
}
Last updated