Back to blog
February 13, 2024 · 6 min · SQD Team

Analyzing Blockchain Data with LLMs and Subsquid

AI Tutorial Data Analytics
Analyzing Blockchain Data with LLMs and Subsquid

Overview

This article demonstrates how to combine Language Learning Models with blockchain indexing tools to create intelligent data agents. The tutorial shows developers how to leverage LlamaIndex, Langchain, and Subsquid SDK for analyzing on-chain data.

Subsquid’s Role

Subsquid functions as a blockchain indexing SDK and a distributed data lake optimized for serving large volumes of historical on-chain data from over 100+ chains. It provides GraphQL API endpoints that agents can query for structured blockchain data.

Implementation Approach

The tutorial walks through several steps:

1. Deploy an Indexing Squid

Uses a Uniswap squid example to index swap events and pools, creating a queryable GraphQL endpoint with structured blockchain data.

2. Create Agent Tools

Implements functions for GraphQL queries and schema introspection in under 50 lines of code. These tools allow the LLM agent to understand what data is available and how to query it.

3. Query Execution

Enables both structured and unstructured queries through natural language prompts. The agent translates human questions into appropriate GraphQL queries and interprets the results.

Multi-Framework Support

The guide covers integration with both frameworks:

  • LlamaIndex: For basic agent functionality and straightforward query-answer workflows
  • Langchain: For expanded analysis capabilities and metric proposal, enabling more complex analytical chains

Value Proposition

By combining AI with blockchain indexing, developers can conduct in-depth analysis over any schema, providing insights on available entities, fields, and combinations for querying — all without complex manual query construction.

Requirements

An OpenAI API key is needed to follow the tutorial, as both LlamaIndex and Langchain agents use OpenAI models for natural language understanding and query generation.

Want to learn more about SQD?