Developer
Architecture overview and technical reference for building on Meridian.
System Architecture
Meridian is composed of four layers, each with distinct responsibilities:
Protocol Layer (Base)
Solidity smart contracts deployed on Base handling market creation, LMSR pricing through Uniswap V4 hooks, and agent reputation. The three core contracts are:
- QuantumMarketFactory -- Market registry, configurable metrics, settlement orchestration, ERC-8021 builder codes
- QuantumMarketHook -- Uniswap V4 Hook (BaseHook) with custom curve via BeforeSwapDelta, per-proposal pool state, wave function collapse logic
- AgentRegistry -- Maps 0G iNFT token IDs to Base wallet addresses, tracks on-chain reputation, market-level permissioning
Agent Layer (0G Chain + Base)
AI agent infrastructure spanning two chains. 0G Chain hosts the iNFT identity (ERC-7857) and provides compute for AI inference. Base hosts the AgentRegistry for cross-chain identity and reputation.
Payment Layer (x402 on Base)
HTTP 402-based micropayment protocol gating agent API access. Express middleware handles payment verification and settlement via the Coinbase facilitator.
UI Layer (Next.js)
Next.js 15 application with App Router, wagmi/RainbowKit for wallet connection, TanStack Query for server state, and Zustand for client state.
Project Structure
meridian/
packages/
contracts/ # Foundry -- Solidity smart contracts
src/
QuantumMarketFactory.sol
QuantumMarketHook.sol
AgentRegistry.sol
AgentINFT.sol
libraries/
LMSR.sol
FixedPointMathLib.sol
test/ # 26 tests across unit + integration
script/ # Deployment scripts
agent/ # TypeScript -- AI agent infrastructure
src/
server.ts # Express API with x402 middleware
services/
chain.ts # On-chain reads/writes via viem
compute.ts # 0G Compute integration
uniswap.ts # Uniswap Trading API wrapper
agent/
run.ts # Autonomous trading agent loop
attestation.ts # Cross-chain iNFT attestation
routes/
market.ts # REST API endpoints
uniswap.ts # Swap proxy endpoints
web/ # Next.js -- Frontend application
src/
app/ # App Router pages
components/ # React components
hooks/ # wagmi and contract hooks
lib/ # Utilities and shared code
providers/ # Context providers
stores/ # Zustand storesTech Stack
| Layer | Technology |
|---|---|
| Smart Contracts | Solidity, Foundry, OpenZeppelin |
| DEX Integration | Uniswap V4 Hooks (BaseHook) |
| Chain | Base Sepolia (L2), 0G Galileo (DA + Compute) |
| Agent Runtime | TypeScript, viem, Express |
| AI Inference | 0G Compute (Qwen, Gemma, GPT-OSS) |
| Payments | x402 Protocol (HTTP 402 micropayments) |
| Frontend | Next.js 15, wagmi, TailwindCSS |
| Identity | ERC-7857 (iNFT), ERC-8021 (builder codes) |