MAS Market is a real-time agentic prediction market platform where specialized AI agents work together to analyze events and make intelligent predictions. The platform leverages a multi-agent architecture powered by the A2A (Agent-to-Agent) protocol, with a host orchestrator coordinating three specialized agents: a Research Agent that analyzes markets using advanced technical indicators (RSI, MACD, Bollinger Bands), real-time events data, and news sentiment; a Polymarket Agent that fetches live market datag and a Bettor Agent that handles blockchain transactions and payouts using the x402 payment protocol on Hedera testnet.
Built with LangChain, LangGraph, and Google Gemini 2.5 Flash, the platform features a Next.js frontend with real-time market grids, WebSocket price updates, and an interactive chat interface where users can research any prediction market with a single click. Users receive comprehensive AI-powered analysis with confidence scores, technical signals, and data-driven recommendations for both binary (yes/no) and continuous (price target) prediction markets. The system enables automated betting execution with non-custodial x402 payments, immutable on-chain bet recording, and automatic payout distribution when markets resolves, providing a seamless end-to-end experience for data-driven crypto predictions and automated trading.
Specialized AI agents work together - Research Agent analyzes markets, Polymarket Agent executes trades, and Bettor Agent handles settlements
Ask questions about any prediction market and get data-driven recommendations with confidence scores
Execute trades automatically based on AI predictions without manual intervention
Secure transaction processing on Hedera testnet with transparent on-chain records
AI analyzes both binary (yes/no) and continuous (specific price) prediction markets
See exactly how AI reached its conclusion with technical signals and data sources used
Natural language interface to discuss markets, ask follow-ups, and refine predictions
mas market uses a multi-agent architecture with A2A (Agent-to-Agent) protocol for distributed intelligence:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Next.js) β
β - Real-time market grids with WebSocket pricing β
β - Interactive chat interface with markdown rendering β
β - One-click AI research for any market β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Host Agent (A2A Client) β
β - LangGraph workflow orchestration β
β - Coordinates all specialized agents β
β - Aggregates responses and returns to frontend β
ββββββββ¬βββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββ ββββββββββββββββ ββββββββββββββββββββ
βResearch β β Polymarket β β Bettor Agent β
βAgent β β Agent β β β
βPort 8002 β β Port 8001 β β Port 8003 β
β β β β β β
βTools: β βTools: β βTools: β
β- Tavily β β- Market Data β β- x402 Payment β
β- CoinGeckoβ β- CLOB API β β- Bet Recording β
β- Technicalβ β- Trading β β- Resolution Checkβ
β Analysisβ β β β- Payout Trigger β
ββββββββββββ ββββββββββββββββ ββββββββββββββββββββ
- User Request β Host Agent (A2A Client)
- Host Agent determines which specialist agents to invoke
- Research Agent (port 8002) analyzes market with technical indicators
- Polymarket Agent (port 8001) fetches real-time market data
- Bettor Agent (port 8003) executes blockchain transactions
- Host Agent aggregates responses and returns to user
- Next.js 15.3.4 - React framework with App Router
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS framework
- Framer Motion - Animation library
- react-markdown - Markdown rendering for AI responses
- LangChain v1 - Agent creation and tool orchestration
- LangGraph - State machine workflow management
- A2A SDK - Agent-to-Agent communication protocol
- Google Gemini 2.5 Flash - Fast LLM inference
- CoinGecko API - Crypto price data (14,000+ coins)
- Tavily Search API - News and market events
- Polymarket API - Prediction market data
- WebSocket (CLOB) - Real-time price updates
- Hedera SDK - Testnet transactions
- x402 Protocol - Non-custodial payment standard
- HCS - Consensus service for bet recording
- Node.js 18+ - JavaScript runtime
- npm/pnpm - Package management
- ESLint - Code linting
- Prettier - Code formatting
- Node.js 18+ and npm/pnpm
- Google API Key (for Gemini LLM)
- Tavily API Key (for search)
- Hedera Account (testnet for betting)
- Git
- Clone the repository
git clone https://github.com/devesh1011/ethonline2025-hack.git
cd ethonline2025-hack- Install dependencies
# Install root dependencies
npm install
# Install frontend dependencies
cd hedera-client-interface
npm install
# Install Research Agent dependencies
cd ../remote_agents/research_agent
npm install
# Install Polymarket Agent dependencies
cd ../polymarket_agent
npm install
# Install Bettor Agent dependencies
cd ../bettor_agent
npm install- Configure environment variables
Create .env files in each agent directory:
Frontend (hedera-client-interface/.env)
NEXT_PUBLIC_POLYMARKET_WS=wss://ws-subscriptions-clob.polymarket.com/ws/marketResearch Agent (remote_agents/research_agent/.env)
GOOGLE_API_KEY=your_google_api_key
TAVILY_API_KEY=your_tavily_api_key
PORT=8002Polymarket Agent (remote_agents/polymarket_agent/.env)
GOOGLE_API_KEY=your_google_api_key
POLYMARKET_API_URL=https://gamma-api.polymarket.com
PORT=8001Bettor Agent (remote_agents/bettor_agent/.env)
GOOGLE_API_KEY=your_google_api_key
HEDERA_NETWORK=testnet
HEDERA_OPERATOR_ID=your_hedera_account_id
HEDERA_OPERATOR_KEY=your_hedera_private_key
BETTING_CONTRACT_ID=your_contract_id
PORT=8003- Start the services
Open 4 separate terminals:
Terminal 1: Research Agent
cd remote_agents/research_agent
npm start
# Runs on http://localhost:8002Terminal 2: Polymarket Agent (optional)
cd remote_agents/polymarket_agent
npm start
# Runs on http://localhost:8001Terminal 3: Bettor Agent (optional)
cd remote_agents/bettor_agent
npm start
# Runs on http://localhost:8003Terminal 4: Frontend
cd hedera-client-interface
npm run dev
# Runs on http://localhost:3000- Open the application
http://localhost:3000
ethonline2025-hack/
βββ hedera-client-interface/ # Next.js Frontend
β βββ src/
β β βββ app/
β β β βββ api/ # API routes
β β β β βββ chat/ # Chat endpoint (Host Agent)
β β β β βββ polymarket/ # Market data endpoint
β β β βββ chat/ # Chat page with markets grid
β β β βββ layout.tsx # Root layout
β β βββ components/ # React components
β β β βββ Chat.tsx # Chat interface with markdown
β β β βββ ...
β β βββ lib/ # Utilities
β βββ public/ # Static assets
β βββ package.json
β
βββ remote_agents/ # A2A Agents
β βββ research_agent/ # Market analysis agent
β β βββ agent.ts # Agent definition with tools
β β βββ tools.ts # CoinGecko, Tavily, Technical Analysis
β β βββ agentExecutor.ts # A2A server implementation
β β βββ index.ts # Entry point
β β βββ package.json
β β
β βββ polymarket_agent/ # Trading execution agent
β β βββ agent.ts
β β βββ tools.ts # Polymarket API integration
β β βββ agentExecutor.ts
β β βββ index.ts
β β βββ package.json
β β
β βββ bettor_agent/ # Blockchain settlement agent
β βββ agent.ts
β βββ tools.ts # Hedera SDK, x402 protocol
β βββ instructions.ts # Agent system prompt
β βββ agentExecutor.ts
β βββ index.ts
β βββ package.json
β
βββ server/ # Host Agent (orchestrator)
β βββ initialize-agent.ts # LangGraph workflow
β βββ ...
β
βββ README.md
Purpose: Market analysis and prediction generation
Tools:
internet_search- Tavily API for news and eventsget_crypto_price_data- Real-time prices from CoinGeckoget_crypto_historical_data- Historical trends and volatilityget_crypto_market_trend- Market sentiment analysiscalculate_technical_indicators- RSI, MACD, Bollinger Bands, Moving Averages
Input: Market question or event ID
Output:
{
"summary": "Analysis with evidence",
"market_type": "binary" | "continuous",
"what_to_bet": "yes" | "no" | 2.75,
"confidence": "high" | "medium" | "low",
"technical_signals": ["MACD bullish", "RSI neutral"],
"data_sources": ["CoinGecko", "Technical Indicators"]
}Purpose: Fetch market data and execute trades
Tools:
- Market data retrieval from Polymarket API
- CLOB order book analysis
- Trade execution interface
Input: User preferences, event data
Output: Market details, prices, trade confirmation
Purpose: Blockchain transaction execution
Tools:
trigger_x402_payment- Create payment requestrecord_bet- Store bet on-chaincheck_market_resolution- Query Polymarket for outcomesget_winning_bets- Fetch winners from backendtrigger_payout- Execute Hedera transfer to winners
Input: Payment intent with user account, amount, market ID
Output: Transaction hash, payment URL, settlement confirmation
POST /api/chat
Request:
{
"messages": [
{
"role": "user",
"content": "Research this prediction market: \"Will Bitcoin reach $100k?\""
}
]
}Response:
{
"output": "**Analysis**: Bitcoin currently at $43,500...",
"transactionBytes": null
}GET /api/polymarket
Response:
[
{
"id": "123",
"title": "Will Bitcoin reach $100k?",
"description": "...",
"end_date": "2025-12-31",
"volume": "1000000"
}
]POST http://localhost:8002/invoke
Request:
{
"messages": [
{
"role": "user",
"content": "Analyze XRP price for October"
}
]
}User: "What price will XRP hit in October?"
AI Response:
**Analysis**: XRP currently at $2.45. Technical indicators show:
- RSI: 58 (neutral momentum)
- MACD: Bullish crossover above signal line
- Support at $2.20, resistance at $2.80
- Historical volatility suggests target range $2.50-$2.95
**Price Target**: $2.75
**Confidence**: Medium
**Technical Signals**: MACD bullish, Support at $2.20, Resistance at $2.80
User: "Will Bitcoin reach $100k by end of 2025?"
AI Response:
**Analysis**: Bitcoin at $43,500, up 56% YTD. Strong bullish momentum:
- RSI at 65 (overbought but holding)
- Price above 50-day MA ($41,200)
- Volume: $28B daily (healthy market)
- News: Institutional adoption increasing
**Recommendation**: YES
**Confidence**: High (72%)
**Reasoning**: Multiple bullish signals align with uptrend continuation
- Browse markets on the main page
- Click "AI Research" button on any market
- Chat input auto-populates with market title
- AI analyzes and returns recommendation in seconds
Each agent can be configured via environment variables:
Model Settings:
GOOGLE_API_KEY- Gemini API key- Temperature (in code): 0.3-0.5 for deterministic responses
API Keys:
TAVILY_API_KEY- For internet searchPOLYMARKET_API_URL- Polymarket API endpoint
Blockchain:
HEDERA_NETWORK- testnet or mainnetHEDERA_OPERATOR_ID- Your Hedera accountHEDERA_OPERATOR_KEY- Private key
WebSocket URL:
NEXT_PUBLIC_POLYMARKET_WS=wss://ws-subscriptions-clob.polymarket.com/ws/marketEnsure all API keys and credentials are set in production environment:
- Google API Key
- Tavily API Key
- Hedera credentials
- Polymarket API URL