OptimismPay is a groundbreaking project designed to revolutionize cross-chain transactions by:
- Eliminating the need for users to hold native tokens for gas.
- Ensuring privacy and security through Fully Homomorphic Encryption (FHE) powered by Zama FHEVM.
- Enabling seamless interoperability across networks in the Optimism Superchain.
By combining advanced encryption techniques, a modular SDK, and compatibility with the OP Stack, OptimismPay is a developer-friendly solution for wallets, dApps, and exchanges.
-
Gasless Experience:
- Automatically deducts gas fees from the token being transferred, simplifying user interactions with blockchain networks.
-
Privacy-Preserving Transactions:
- Utilizes Zama’s Fully Homomorphic Encryption (FHE) to encrypt sensitive transaction details, ensuring they remain private throughout the transfer process.
-
Cross-Chain Interoperability:
- Built on the L2StandardBridgeInterop, enabling seamless token transfers across networks in the Optimism Superchain (e.g., Optimism, Base, Sepolia).
-
Developer-Friendly SDK:
- A TypeScript-based SDK simplifies integration with wallets and dApps by abstracting contract interactions.
-
Modular Architecture:
- Composed of reusable components, including gas management, encryption layers, and token validation.
Transacting across multiple blockchain networks often requires users to hold native tokens to pay gas fees. This creates several challenges:
- New Users: Frustration due to insufficient gas tokens.
- Accessibility: Limited on-ramps for acquiring native tokens in certain regions.
- Fragmentation: Unused native tokens accumulating across different networks.
OptimismPay solves these problems by enabling users to pay gas fees directly from the token being transferred, providing a seamless, gasless, and private cross-chain experience.
The system combines multiple smart contracts and Zama’s FHE to ensure private, gasless, and cross-chain token transfers.
graph TD
A[User Initiates Transfer] -->|Sender, Receiver, Token, Amount| B[OptimismPay SDK]
B --> C[PrivacyLayer: Encrypt Transaction Data]
C -->|Encrypted Data| D[GasPaymaster: Calculate and Deduct Gas]
D -->|Net Amount| E[OptimismPayBridge]
E -->|Call L2StandardBridge| F[L2StandardBridge: Cross-Chain Transfer]
F -->|Send Encrypted Data to Destination| G[OptimismPayBridge_Destination]
G -->|Decrypt Transaction Data with PrivacyLayer| H[Finalize Transfer]
H -->|Release Tokens to Receiver| I[Receiver Wallet]
- Privacy Preservation:
- Sensitive transaction data is encrypted on-chain using Zama's FHE before transfer initiation.
- Gas Fee Deduction:
- The
GasPaymaster
contract dynamically calculates and deducts gas fees from the user's token balance.
- The
- Cross-Chain Messaging:
- The
OptimismPayBridge
contract interacts with theL2StandardBridge
to handle token and encrypted data transfers.
- The
- Decryption and Finalization:
- On the destination chain, encrypted data is decrypted to finalize the transfer securely.
The OptimismPay project is organized as a monorepo for better modularity and scalability.
📦 optimismpay-monorepo
├── 📁 apps
│ ├── 📁 frontend # Demo wallet interface (Next.js)
│ ├── 📁 backend # API for managing transactions (Node.js)
├── 📁 packages
│ ├── 📁 contracts # Smart contracts and deployment scripts (Hardhat)
│ │ ├── ConfigManager.sol
│ │ ├── GasPaymaster.sol
│ │ ├── OptimismPayBridge.sol
│ │ └── PrivacyLayer.sol
│ ├── 📁 sdk # Developer SDK for interacting with the system (TypeScript)
│ │ ├── integrations
│ │ │ ├── dAppAPI.ts # APIs for dApp integrations
│ │ │ └── walletAPI.ts # APIs for wallet integrations
│ │ ├── encryption
│ │ │ ├── fheEncrypt.ts # Zama FHE encryption utilities
│ │ │ └── fheDecrypt.ts # Zama FHE decryption utilities
│ │ └── utils
│ │ ├── networkUtils.ts # Network utilities for fetching gas prices
│ │ └── tokenUtils.ts # Token validation utilities
│ ├── 📁 shared # Shared constants, types, and helpers
├── turbo.json # TurboRepo configuration for monorepo management
├── pnpm-workspace.yaml # Workspace configuration for pnpm
└── package.json # Global dependencies and project metadata
- Node.js (v16+)
pnpm
for monorepo management- Infura, Alchemy, or other RPC provider for network access
-
Clone the Repository:
git clone https://github.com/AndreaDiazCorreia/Optimism-pay.git cd Optimism-pay
-
Install Dependencies:
pnpm install
-
Set Up Environment Variables: Create a
.env
file in the root directory using the provided.env.example
template. -
Run the Development Environment:
pnpm dev
-
Unit Tests:
pnpm test
-
Manual Testing: Deploy the contracts on testnets like Optimism Goerli or Sepolia and initiate transactions via the SDK.
🟢 Cross-chain token transfers using Optimism's L2StandardBridge
.
🟢 Privacy-preserving transactions with Zama FHE.
🟢 Initial SDK with core functionalities.
🟡 Enhanced API documentation and modularization. 🟡 Improved error handling and token validation logic.
🟡 Add support for zkSync, Polygon Supernets, and other Superchain networks.
🔵 Integrate zk-SNARKs for zero-knowledge transaction proofs.
🔵 Build browser extensions and plugins for ecommerce platforms.
This project leverages the following technologies:
- Zama FHEVM: For privacy-preserving encryption and decryption.
- Optimism L2StandardBridge: For seamless cross-chain interoperability.
- Hardhat: For contract development and testing.
- TurboRepo: For efficient monorepo management.
Developed during the Aleph de Verano Hackathon 2024, the project aims to enhance blockchain accessibility and usability.
This project is licensed under the MIT License.
For questions or issues, open an issue on GitHub.
Follow us on Social Media for updates and announcements.
Happy Building 🚀!