You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable payment acceptance from multiple L2 chains (Base, Arbitrum, Optimism, Polygon) with dynamic chain selection and unified verification.
Motivation
Currently, MicroAI Paygate only supports Base (Chain ID 8453). As L2 adoption grows, users may prefer paying from their primary chain. Supporting multiple chains:
Reduces friction - Users don't need to bridge funds
Increases adoption - Access wider user base
Future-proofs - Easy to add new chains
Proposed Architecture
flowchart TB
subgraph Client[Client Layer]
WEB[Web Frontend]
AGENT[Agent Bot]
end
subgraph Gateway[Multi-Chain Gateway]
GW[Gateway Service]
subgraph Registry[Chain Registry]
BASE[Base - 8453]
ARB[Arbitrum - 42161]
OP[Optimism - 10]
POLY[Polygon - 137]
end
end
subgraph Verifier[Verification Layer]
VER[Verifier Service]
end
WEB --> GW
AGENT --> GW
GW --> Registry
GW <--> VER
BASE -.-> VER
ARB -.-> VER
OP -.-> VER
POLY -.-> VER
Loading
Request Flow
sequenceDiagram
participant C as Client
participant G as Gateway
participant V as Verifier
C->>G: POST with X-402-ChainId: 42161
G->>G: Validate chainId in registry
G->>V: Verify with Arbitrum domain
V-->>G: is_valid
G-->>C: 200 OK
Summary
Enable payment acceptance from multiple L2 chains (Base, Arbitrum, Optimism, Polygon) with dynamic chain selection and unified verification.
Motivation
Currently, MicroAI Paygate only supports Base (Chain ID 8453). As L2 adoption grows, users may prefer paying from their primary chain. Supporting multiple chains:
Proposed Architecture
flowchart TB subgraph Client[Client Layer] WEB[Web Frontend] AGENT[Agent Bot] end subgraph Gateway[Multi-Chain Gateway] GW[Gateway Service] subgraph Registry[Chain Registry] BASE[Base - 8453] ARB[Arbitrum - 42161] OP[Optimism - 10] POLY[Polygon - 137] end end subgraph Verifier[Verification Layer] VER[Verifier Service] end WEB --> GW AGENT --> GW GW --> Registry GW <--> VER BASE -.-> VER ARB -.-> VER OP -.-> VER POLY -.-> VERRequest Flow
sequenceDiagram participant C as Client participant G as Gateway participant V as Verifier C->>G: POST with X-402-ChainId: 42161 G->>G: Validate chainId in registry G->>V: Verify with Arbitrum domain V-->>G: is_valid G-->>C: 200 OKSupported Chains (Phase 1)
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA029130xaf88d065e77c8cC2239327C5EDb3A432268e58310x0b2C639c533813f4Aa9D7837CAf62653d097Ff850x3c499c542cEF5E3811e1192ce70d8cC03d5c3359Implementation Details
Chain Configuration
Create
config/chains.json:{ "chains": [ { "id": 8453, "name": "Base", "enabled": true, "rpcUrl": "${BASE_RPC_URL}", "usdc": { "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "decimals": 6 }, "blockTime": 2, "explorer": "https://basescan.org" }, { "id": 42161, "name": "Arbitrum", "enabled": true, "rpcUrl": "${ARBITRUM_RPC_URL}", "usdc": { "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "decimals": 6 }, "blockTime": 0.25, "explorer": "https://arbiscan.io" } ] }Updated 402 Response
{ "error": "Payment Required", "paymentContext": { "recipient": "0x...", "amount": "0.001", "token": "USDC", "nonce": "uuid" }, "supportedChains": [ { "id": 8453, "name": "Base", "recommended": true }, { "id": 42161, "name": "Arbitrum" }, { "id": 10, "name": "Optimism" }, { "id": 137, "name": "Polygon" } ] }New Request Headers
X-402-ChainId42161X-402-Signature0x...X-402-NonceuuidEIP-712 Domain Updates
The domain separator must include the correct chainId:
Verifier Updates (Rust)
Acceptance Criteria
Backend
config/chains.json)supportedChains[]X-402-ChainIdheader parsing in GatewayFrontend
Testing & Docs
Frontend Chain Selector UX
Future Considerations
PR Requirements
go test -v ./...,cargo test, andbun test