Skip to content

ChainNarratorAgent is a Python-based blockchain analysis tool built on the Sentient Agent Framework. It analyzes transactions on Ethereum, Polygon, BSC, and Solana, delivering detailed, narrative-style explanations and summaries. The agent supports conversational queries (What is a nonce?) and handles casual inputs gracefully, with streaming.

Notifications You must be signed in to change notification settings

MAYANK-MAHAUR/Chainnarrator

Repository files navigation

ChainNarratorAgent

ChainNarratorAgent is a Python-based blockchain analysis tool built on the Sentient Agent Framework. It analyzes transactions on Ethereum, Polygon, Binance Smart Chain (BSC), and Solana, delivering narrative-style explanations and summaries. The agent supports conversational queries (e.g., "What is a nonce?") and streams responses in real-time for an interactive experience. Designed for crypto enthusiasts, developers, and researchers.

Features

  • Transaction Analysis: Processes transaction hashes to provide step-by-step stories, including nonce, gas fees, block number, and token transfers.
  • Blockchain Education: Answers blockchain-related questions with context-aware responses.
  • Conversational Handling: Responds to casual inputs and supports a "help" command.
  • Real-Time Streaming: Streams LLM-generated responses sentence-by-sentence.
  • Session Management: Stores up to 15 messages per session and cleans up sessions after 5 minutes of inactivity.
  • Cross-Chain Support: Handles Ethereum, Polygon, BSC, and Solana, including bridge detection for cross-chain transactions.

Prerequisites

  • Python 3.9+
  • Git (for cloning the repository)
  • API keys for Etherscan, PolygonScan, BSCScan, and Solana RPC
  • LLM API access (e.g., Qwen-72B via GaiaNet or OpenAI-compatible client)

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/ChainNarratorAgent.git
    cd ChainNarratorAgent
  2. Install dependencies:

    pip install -r requirements.txt
  3. Set up environment variables using a .env file (see .env.example).

Usage

  1. Start the server:

    python server.py
  2. Run the interactive client:

    python test.py
  3. Interact with the agent:

    • Analyze a transaction: 0x4c12bb80... on ethereum
    • Ask blockchain questions: What is a nonce?
    • Casual input: ok thanks
    • Help: help

Sessions automatically clean up after inactivity.

Project Structure

  • agent.py: Core transaction analysis and session management
  • server.py: FastAPI server for streaming responses
  • test.py: CLI client for testing
  • database.py: Session persistence with SQLite
  • adapters/: Blockchain adapters (evm_adapter.py, solana_adapter.py)
  • config.py: API key and LLM configuration
  • requirements.txt: Python dependencies

Example -

example.png

Deployment

  • Local: Run server.py and access via http://127.0.0.1:8000

Contributing

  • Fork the repository and submit pull requests
  • Test your changes before submitting
  • Suggested enhancements: real-time transaction polling, web UI integration

Contact

Open a GitHub issue or contact [mayankgaming179@gmail.com]. thanks to rex for his awesome product xero ai leveraging sentient ROMA

About

ChainNarratorAgent is a Python-based blockchain analysis tool built on the Sentient Agent Framework. It analyzes transactions on Ethereum, Polygon, BSC, and Solana, delivering detailed, narrative-style explanations and summaries. The agent supports conversational queries (What is a nonce?) and handles casual inputs gracefully, with streaming.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages