← Back to home

BlockScoutLens

AI-powered blockchain analysis bot using Blockscout MCP. Ask questions, get insights! 🔍⛓️

Problem Statement

BlockscoutLens is an AI-powered Telegram bot that makes blockchain data accessible through natural language conversations. Instead of navigating complex blockchain explorers, users simply ask questions and receive intelligent, contextual answers.The ProblemTraditional blockchain explorers present raw data (transaction hashes, hex values, gas fees) that requires technical expertise to interpret. Users must navigate multiple pages, understand complex terminology, and manually piece together information.Our SolutionBlockscoutLens combines OpenAI's GPT-4o model with Blockscout's MCP (Model Context Protocol) server to provide:Natural Language Queries: Ask "Is vitalik.eth a trader or holder?" instead of manually analyzing transaction historyAI Reasoning: Not just data dumps - the bot identifies patterns, assesses risks, and explains what the data actually meansMulti-Chain Support: One interface for Ethereum, Optimism, Base, Arbitrum, Polygon, and moreInstant Insights: "This wallet appears to be a long-term DeFi holder based on its interaction patterns" vs just showing numbersTechnical ImplementationThe bot uses OpenAI's Responses API with native MCP support to connect to Blockscout's MCP server. This is crucial: we're using theModel Context Protocol(not raw REST APIs) which allows the AI to intelligently discover tools, chain multiple queries, and reason about blockchain data contextually.Flow:User asks a question via TelegramOpenAI Responses API receives the queryAI connects to Blockscout MCP server and discovers available toolsAI intelligently selects and calls relevant tools (get_address_info, get_transactions, etc.)AI analyzes the returned blockchain dataBot delivers synthesized insights to the userWhy MCP matters:It's designed for AI consumption with structured schemas and clear tool descriptions, enabling better reasoning than raw API calls. Blockscout can track our MCP usage through their analytics, validating proper implementation.Key FeaturesWallet behavior analysis (trader/holder/bot detection)Transaction explanations in simple termsSmart contract interaction breakdownMulti-chain blockchain queriesPattern and anomaly detectionRisk assessmentTech StackNode.js, OpenAI Responses API (GPT-4o), Blockscout MCP Server, Model Context Protocol, Telegram Bot APIImpactMakes blockchain data accessible to everyone - from newcomers learning about crypto to experienced traders needing quick analysis. Demonstrates practical AI reasoning over blockchain data using standardized protocols (MCP), not just API wrappers.

Solution

Tech StackCore Technologies:Node.js- Runtime environmentOpenAI Responses API- LLM with native MCP support (GPT-4o model)Blockscout MCP Server- Blockchain data via Model Context ProtocolTelegram Bot API- User interface (node-telegram-bot-api)ArchitectureThe bot follows a simple three-layer architecture:Telegram User → Bot (Node.js) → OpenAI Responses API → Blockscout MCP Server → Blockchain DataKey Implementation Detail:We use OpenAI'snative MCP integrationthrough the Responses API, not custom REST wrappers. This is critical because:The AI automatically discovers available tools from BlockscoutIt can intelligently chain multiple MCP tool callsResults in better reasoning vs traditional function callingCode Flow// Simple but powerful - OpenAI handles all MCP communication const resp = await openai.responses.create({ model: "gpt-4o", tools: [{ type: "mcp", server_url: "https://mcp.blockscout.com/mcp", // AI discovers and calls tools automatically }], input: userQuestion });The magic happens behind the scenes: OpenAI connects to the MCP server, discovers 18+ tools (get_address_info, get_transactions, get_tokens, etc.), and intelligently selects which ones to call based on the user's natural language query.Smart Prompt EngineeringWe crafted a system prompt that makes the AI context-aware:For simple queries (latest block) → concise answersFor complex queries (wallet analysis) → deep insightsAutomatically detects when analysis adds value vs when it's just fluffThis prevents the AI from over-explaining simple data points while ensuring complex questions get thorough analysis.Partner Technology: Blockscout MCPUsing Blockscout's official MCP server (mcp.blockscout.com) gave us:18+ blockchain toolsout of the box (address lookup, transaction analysis, token data, NFTs, contract ABIs, etc.)Multi-chain supportwithout writing any chain-specific codeValidated implementation- Blockscout tracks MCP usage through their analytics, proving we're using the protocol correctlyNotable/Hacky BitsMarkdown Fallback:Telegram's Markdown parsing can be strict. We try to send with Markdown formatting first, then gracefully fallback to plain text if it fails:try { await bot.sendMessage(chatId, answer, { parse_mode: 'Markdown' }); } catch { await bot.sendMessage(chatId, answer); // Fallback to plain text }Zero Custom Blockchain Code:The entire bot is ~100 lines. No web3 libraries, no RPC calls, no chain-specific logic. Everything is handled through the MCP protocol - we just ask questions and get intelligent answers.Why This Approach WorksTraditional approach would require:Multiple blockchain libraries (ethers.js, viem, etc.)RPC endpoint managementChain-specific logic for each networkCustom data parsing and formattingSeparate AI integrationOur approach:One API call to OpenAIMCP handles all blockchain complexityAI does the reasoning automaticallyWorks across all Blockscout-supported chainsThe result: more time building features, less time wrestling with blockchain infrastructure.

Hackathon

ETHOnline 2025

2025

Contributors