Skip to content

heetprox/Midway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

89 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŒ‰ Midway - Cross-Chain Payment Infrastructure

Midway Banner

Seamless cross-chain payments across 8 blockchain networks

License Chains Status

πŸš€ Live Demo β€’ πŸ“– Documentation β€’ πŸ”§ Deploy β€’ 🀝 Contribute


🎯 What is Midway?

Midway is a revolutionary cross-chain payment infrastructure that enables seamless token transfers and balance management across multiple blockchain networks. Think of it as a universal wallet that abstracts away the complexity of managing assets across different chains.

✨ Key Benefits

  • πŸ”„ Unified Balance Management - Single balance tracked across all chains
  • ⚑ Instant Cross-Chain Transfers - No bridges, no waiting
  • πŸ’° Gas Optimization - Deposit on cheap chains, withdraw anywhere
  • πŸ›‘οΈ Secure Architecture - Battle-tested smart contracts
  • 🌐 Multi-Chain Native - Built for a multi-chain future

πŸ—οΈ Core Architecture

Midway operates on a hub-and-spoke model with Optimism Sepolia as the central hub:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Ethereum      β”‚    β”‚   Base Sepolia  β”‚    β”‚  Polygon Amoy   β”‚
β”‚   Sepolia       β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ MidPay    │◄─┼────┼─►│ MidPay    │◄─┼────┼─►│ MidPay    β”‚  β”‚
β”‚  β”‚ Client    β”‚  β”‚    β”‚  β”‚ Client    β”‚  β”‚    β”‚  β”‚ Client    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β–²                       β–²                       β–²
        β”‚                       β”‚                       β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚    Optimism Sepolia     β”‚
                    β”‚      (Core Hub)         β”‚
                    β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
                    β”‚   β”‚   MidPay Core   β”‚   β”‚
                    β”‚   β”‚  (Balances &    β”‚   β”‚
                    β”‚   β”‚   Management)   β”‚   β”‚
                    β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
                    β”‚                         β”‚
                    β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
                    β”‚   β”‚ Cross-Chain     β”‚   β”‚
                    β”‚   β”‚    Relayer      β”‚   β”‚
                    β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Component Overview

Component Location Purpose
MidPay Core Optimism Sepolia Central balance management & coordination
MidPay Client All other chains Local operations & message routing
External Routers All chains Cross-chain message passing
Cross-Chain Relayer Off-chain service Automated message relay between chains

🌐 Supported Chains

Chain Chain ID Status Features
πŸ”΄ Optimism Sepolia 11155420 βœ… Hub Core contracts, balance management
⚫ Ethereum Sepolia 11155111 βœ… Active Full deposit/withdraw support
🟣 Zora Sepolia 999999999 βœ… Active NFT-focused ecosystem integration
πŸ”΅ Base Sepolia 84532 βœ… Active Coinbase L2 integration
🟠 Polygon Amoy 80002 βœ… Active Low-cost transactions
🌍 Worldchain Sepolia 4801 βœ… Active Identity-verified network
πŸ–‹οΈ Ink Sepolia 763373 βœ… Active Creator economy focus
πŸ¦„ Unichain Sepolia 1301 βœ… Active DeFi-optimized network

πŸ”„ How It Works

1. Deposit Flow πŸ’°

sequenceDiagram
    participant User
    participant ChainA as Any Chain
    participant Core as Optimism Core
    participant Relayer

    User->>ChainA: Deposit FUSD
    ChainA->>ChainA: Lock tokens locally
    ChainA->>Relayer: Send cross-chain message
    Relayer->>Core: Update balance on Optimism
    Core->>Core: Credit user account
    Core->>User: Balance updated βœ…
Loading

2. Withdrawal Flow πŸ’Έ

sequenceDiagram
    participant User
    participant ChainB as Target Chain
    participant Core as Optimism Core
    participant Relayer

    User->>ChainB: Request withdrawal
    ChainB->>Relayer: Send withdrawal message
    Relayer->>Core: Verify & debit balance
    Core->>Relayer: Confirm withdrawal
    Relayer->>ChainB: Execute token release
    ChainB->>User: Tokens transferred βœ…
Loading

3. Cross-Chain Messaging πŸ“‘

  • External Routers handle message queuing and routing
  • Automated Relayer processes messages between chains
  • Message verification ensures security and prevents double-spending
  • Retry logic handles network failures gracefully

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and Bun
  • MetaMask or compatible wallet
  • Testnet ETH on supported chains

Frontend Setup

# Clone the repository
git clone https://github.com/heetprox/midway.git
cd midway

# Install frontend dependencies
cd client
bun install

# Start development server
bun run dev

Backend Setup (Relayer)

# Navigate to server directory
cd server
bun install

# Set up environment variables
cp .env.example .env
# Add your private keys and RPC URLs

# Start the relayer
bun run start

Environment Configuration

Create .env files with the following:

# Backend (.env)
BOT_PRIVATE_KEY=your_relayer_private_key
OPTIMISM_SEPOLIA_RPC_URL=https://sepolia.optimism.io
ETH_SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/your-key
ZORA_SEPOLIA_RPC_URL=https://sepolia.rpc.zora.energy
BASE_SEPOLIA_RPC_URL=https://sepolia.base.org
POLYGON_AMOY_RPC_URL=https://rpc-amoy.polygon.technology
WORLDCHAIN_SEPOLIA_RPC_URL=https://worldchain-sepolia.g.alchemy.com/public
INK_SEPOLIA_RPC_URL=https://rpc-gel-sepolia.inkonchain.com
UNICHAIN_SEPOLIA_RPC_URL=https://sepolia.unichain.org

πŸ’‘ Key Features

🎨 Beautiful UI/UX

  • Responsive design that works on all devices
  • Real-time balance updates
  • Intuitive network switching
  • Clear transaction status feedback

πŸ”’ Security First

  • Multi-signature architecture
  • Automated security checks
  • Rate limiting and spam protection
  • Comprehensive error handling

⚑ Performance Optimized

  • Smart contract gas optimization
  • Efficient message routing
  • Parallel transaction processing
  • Caching for improved UX

πŸ› οΈ Developer Friendly

  • TypeScript throughout
  • Comprehensive testing
  • Clear documentation
  • Modular architecture

🎯 Use Cases

πŸͺ For Merchants

  • Accept payments on any supported chain
  • Settle in preferred currency/chain
  • Reduce gas costs through optimal routing
  • Simplified multi-chain treasury management

πŸ‘€ For Users

  • Unified balance across all chains
  • Pay with tokens on cheapest available chain
  • Seamless cross-chain experience
  • No manual bridging required

🏒 For dApps

  • Integrate cross-chain payments easily
  • Access liquidity from multiple chains
  • Reduce user onboarding friction
  • Enable chain-agnostic user experiences

πŸ”§ Technical Specifications

Smart Contracts

Contract Network Address Purpose
MidPayCore Optimism Sepolia 0x895cCb... Central balance management
MidPayClient Ethereum Sepolia 0x9E86ca... Local operations
MidPayClient Zora Sepolia 0xfd0A25... Local operations
External Router All chains Various Message routing

Token Standard

  • FUSD: Custom testnet token for demonstration
  • Decimals: 18
  • Mintable: Yes (testnet only)

Gas Optimization

  • Batch operations where possible
  • Efficient storage patterns
  • Minimal cross-chain message size
  • Smart retry mechanisms

πŸ§ͺ Testing

Run Tests

# Frontend tests
cd client
bun test

# Smart contract tests
cd contracts
forge test

# Integration tests
bun run test:integration

Test Coverage

  • βœ… Unit tests for all components
  • βœ… Integration tests for cross-chain flows
  • βœ… End-to-end testing
  • βœ… Security audit preparation

🚧 Roadmap

Phase 1: Foundation βœ…

  • Core architecture implementation
  • 8-chain support
  • Basic UI/UX
  • Cross-chain messaging

Phase 2: Enhancement 🚧

  • Mainnet deployment preparation
  • Advanced security features
  • Performance optimizations
  • Mobile app development

Phase 3: Expansion πŸ“‹

  • Additional chain integrations
  • DeFi protocol integrations
  • Governance token launch
  • DAO formation

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Process

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Code Style

  • Use TypeScript for type safety
  • Follow ESLint configuration
  • Add comprehensive comments
  • Write tests for new features

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ”— Links


Built with ❀️ for the multi-chain future

Midway - Bridging the gap between chains, one transaction at a time.

Twitter Follow GitHub stars

About

Midway - Cross-Chain Payment Infrastructure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages