Seamless cross-chain payments multi-blockchain powered by LayerZero
π Quick Start β’ π Documentation β’ π Networks β’ π§ Development
Midway is a revolutionary cross-chain payment infrastructure that enables users to deposit funds on any supported blockchain and have them instantly available on the core network. Built on LayerZero's omnichain protocol, Midway eliminates the friction of managing multiple wallets and bridging funds across different chains.
- π Multi-Chain Support: Deploy across 8+ blockchain networks
- β‘ Instant Settlements: LayerZero-powered cross-chain messaging
- π Secure: Trusted remote validation and external routing
- π° Unified Balance: Single balance accessible from any chain
- π οΈ Developer Friendly: Comprehensive tooling and debugging scripts
- Multiple Wallets: Users need separate wallets for each chain
- Bridge Complexity: Manual bridging is slow and expensive
- Fragmented Liquidity: Funds locked on specific chains
- Poor UX: Complex multi-step processes
User Deposits on Chain A β LayerZero Message β Core Balance Updated
User Withdraws on Chain B β LayerZero Message β Core Balance Verified
- Unified Core: All balances managed on Optimism Sepolia
- Smart Routing: External routers handle non-LayerZero chains
- Instant Messaging: Real-time cross-chain communication
- Seamless UX: Deposit anywhere, spend everywhere
Midway is deployed across 8 blockchain networks:
Network | Type | Chain ID | External Router ID | Status |
---|---|---|---|---|
Optimism Sepolia | Core | 11155420 | 420 | π’ Live |
Ethereum Sepolia | Client | 11155111 | 111 | π’ Live |
Zora Sepolia | Client | 999999999 | 9999 | π’ Live |
Base Sepolia | Client | 84532 | 845 | π’ Live |
Worldchain Sepolia | Client | 4801 | 480 | π’ Live |
Ink Sepolia | Client | 763373 | 763 | π’ Live |
Unichain Sepolia | Client | 1301 | 130 | π’ Live |
Polygon Amoy | Client | 80002 | 800 | π’ Live |
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Client Net A β β Optimism Core β β Client Net B β
β β β β β β
β ββββββββββββββββ βββββββββββββββββββββ ββββββββββββββββ β
β β MidPayClientββββββΊββ MidPayCore ββββββΊββ MidPayClientβ β
β ββββββββββββββββ βββββββββββββββββββββ ββββββββββββββββ β
β ββββββββββββββββ βββββββββββββββββββββ ββββββββββββββββ β
β βExtRouter/LZ ββ ββ LayerZero ββ ββExtRouter/LZ β β
β ββββββββββββββββ βββββββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββ
# Node.js v18+ and npm
node --version && npm --version
# Install dependencies
npm install
Create .env
file:
# Required: Private key for deployments
PRIVATE_KEY=your_private_key_here
# Network RPC URLs (add as needed) (get from alchmey or any other provider)
OPTIMISM_SEPOLIA_RPC_URL=
ETH_SEPOLIA_RPC_URL=
ZORA_SEPOLIA_RPC_URL=
BASE_SEPOLIA_RPC_URL=
WORLDCHAIN_SEPOLIA_RPC_URL=
INK_SEPOLIA_RPC_URL=
UNICHAIN_SEPOLIA_RPC_URL=
POLYGON_AMOY_RPC_URL=
npm run compile
# Deploy MidPayCore on Optimism Sepolia
npm run deploy:core
# Deploy to all client networks
npm run deploy:eth # Ethereum Sepolia
npm run deploy:zora # Zora Sepolia
npm run deploy:base # Base Sepolia
npm run deploy:worldchain # Worldchain Sepolia
npm run deploy:ink # Ink Sepolia
npm run deploy:unichain # Unichain Sepolia
npm run deploy:polygon # Polygon Amoy
# Fix and configure all trusted remote connections
npm run fix:remotes
Your Midway infrastructure is now deployed across all networks with proper cross-chain connections configured.
# Check trusted remote configurations
npm run debug:remotes
# Debug cross-chain message flow
npm run debug:flow
# Check user balance on core
npm run check:balance
npm run debug:remotes
Output:
- β Correct trusted remote configurations
- β Missing or incorrect configurations
- π§ Expected vs actual address combinations
npm run debug:flow
Output:
- π¬ Message queue status
- π¨ Recent cross-chain events
- π Endpoint configurations
- β Connection issues
npm run check:balance
Output:
- π° User balance on core network
- π΅ USDC token information
- π Formatted balance displays
MidPayCore
: Central balance management on OptimismMidPayClient
: Client-side deposit/withdrawal handlingExternalRouter
: Routes messages for non-LayerZero chainsFakeUSDC
: Test USDC token for development
// Deposit funds (triggers cross-chain message)
function deposit(uint256 amount) external
// Withdraw funds (requires core balance)
function withdraw(uint256 amount) external
// Cross-chain message handling
function lzReceive(uint16 srcChainId, bytes memory srcAddress, bytes memory payload) external
- Trusted Remote Validation: Only authorized contracts can send messages
- Address Verification: Packed address validation for message authenticity
- Replay Protection: Prevents message replay attacks
- Access Control: Owner-only administrative functions
- Update
scripts/network-config.ts
:
"new-network": {
chainId: 123456,
externalRouterChainId: 123,
layerZeroEndpoint: "0x..." // or null
}
- Add to
hardhat.config.ts
:
"new-network": {
url: process.env.NEW_NETWORK_RPC_URL,
accounts: [process.env.PRIVATE_KEY]
}
- Deploy contracts:
npm run deploy:new-network
- Update trusted remotes:
npm run fix:remotes
# Run all tests
npm test
# Compile contracts
npm run compile
# Clean build artifacts
npm run clean
We welcome contributions! Please see our contributing guidelines:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License.
- Documentation: GitHub Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with β€οΈ by the Midway Team
Bridging the gap between blockchains, one payment at a time.