Skip to content

feat: Add AI-powered blockchain analyzer #170

@AugustoL

Description

@AugustoL

Summary

Add AI-powered analysis features that help users understand transactions, accounts, and smart contracts with human-readable explanations.

Approach

  • Free by default — Works out of the box using a shared API key
  • Bring your own key — Users can optionally add their own Groq API key in settings for higher rate limits or privacy
  • "Analyze" button on transaction, address, and contract pages
  • Display AI response in a collapsible section or modal

Features

1. Transaction Analysis

Explain what a transaction did in plain English:

  • Swap details (tokens, amounts, DEX used)
  • Token transfers and approvals
  • Contract interactions
  • Failed transaction explanations

2. Account Analysis

Provide insights about an address:

  • Activity summary (trading patterns, protocols used)
  • Notable holdings or interactions
  • Risk indicators (if applicable)
  • Account type detection (EOA, multisig, contract)

3. Smart Contract Analysis

Help users understand contracts:

  • Contract purpose and functionality
  • Key functions explained
  • Security considerations
  • Protocol identification

Tasks

  • Add settings section for optional AI API key (Groq)
  • Create prompt templates for each analysis type (tx, account, contract)
  • Implement API call to Groq with fallback to default key
  • Add UI components for displaying analysis on each page type
  • Handle edge cases (rate limits, API errors)
  • Add loading state and error handling UI
  • Implement result caching to reduce API calls

Prompt Context

Transaction Analysis

  • Transaction hash, from, to, value
  • Decoded function call (if available)
  • Event logs with decoded parameters
  • Gas used and status
  • Contract names (if verified)

Account Analysis

  • Address, balance, transaction count
  • Recent transaction history
  • Token holdings (if fetched)
  • Contract code (if contract)

Contract Analysis

  • Contract source code (if verified)
  • ABI and function signatures
  • Deployment info
  • Recent interactions

Example Outputs

Transaction

This transaction swapped 1.5 ETH for approximately 2,847 USDC on Uniswap V3 using the WETH/USDC 0.3% fee pool.

Account

This appears to be an active DeFi user. The account has interacted with Uniswap, Aave, and Lido over the past month, primarily for token swaps and staking.

Contract

This is an ERC-20 token contract for "Example Token" (EXT). It includes standard transfer functions plus a mint function restricted to the owner address.

Notes

  • Start with Groq support (free tier available, fast inference)
  • Default shared key for free usage, user can override with their own key
  • Could expand to support multiple providers later (Together, OpenRouter, Anthropic, OpenAI)
  • Cache results in localStorage to avoid redundant API calls

Privacy

  • User-provided API keys stored in localStorage only
  • All data sent to AI provider is already public on-chain
  • Users can use their own key if they prefer not to use the shared key

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions