Final Project - Smart Contract Data Analysis With LLMs
Overview
This project aims to provide graduate students with hands-on experience analyzing deployed smart contracts, extracting on-chain data via GraphQL, designing APIs to organize data into structured formats (e.g., spreadsheets), and leveraging Large Language Models (LLMs) to derive insights. Students will work with real-world contracts (e.g., OpenSea’s NFT marketplace) to index, analyze, and predict trends using LLMs like ChatGPT or DeepSeek.
Specifically, you can
● Analyze NFT trading data (e.g., sales volume, floor prices) from OpenSea’s smart contract.
● Use an LLM to generate insights or predictions about NFT market trends.
Objectives
1. Smart Contract Analysis: Understand the functionality of a deployed contract (e.g., OpenSea’s Seaport Protocol).
2. On-Chain Data Extraction: Learn to query blockchain data using GraphQL (e.g., via The Graph Protocol).
3. API Design: Build custom APIs to fetch and structure data into spreadsheets.
4. LLM Integration: Use structured data to prompt LLMs for predictive or analytical tasks.
Project Requirements
1. Final report due date: May 12th, 2025. Project team members: <= 5 members; For a larger team, more contributions and completeness are expected.
2. The development should be based on Ethereum. We have created discord channels for the students to consult the TAs and Professors for questions and instructions.
Please join us athttps://discord.gg/oortech. Join channel #CU-Project-2025
3. You need to submit a final report of no more than 5 pages, excluding references and figures. Only one member in your team needs to submit the report. All authors’ UNI needs to be included in the report.
4. You need to submit your code to your own github and share it with the instructor . Your github link should be included in your final report.
5. Your final report should follow the structure below:
5.1. Title, Authors, Abstract.
5.2. Summary of your work: goal, procedure, methodology, results, etc.
5.3. Showcase of your work (e.g., figures showing the outcome of your program)
5.4. Conclusion (including contributions of each team member)
Detailed Instructions:
You can follow the following procedure for your project.
Phase 1: Select and Understand a Deployed Smart Contract
Task: Select a deployed smart contract (e.g., OpenSea’s Seaport, Uniswap V3, or ERC-
721 NFT contracts) and analyze its functionality.
Steps:
1. Contract Selection:
。 Choose a contract from Etherscan
。 Example:OpenSea Seaport Contract
2. Contract Understanding:
。 Study the contract’s functions (e.g., fulfillOrder, cancelOrder).
。 Identify key events (e.g., OrderFulfilled, OrderCancelled).
3. Deliverable:
。 A short report explaining the contract’s purpose, key functions, and events.
Note: Before proceeding to Phase 2, students must include the following in the report:
1. The address and name of the selected smart contract.
2. A brief statement of what they intend to accomplish by the end of the semester (e.g., "Predict NFT floor price trends using sales data").
Phase 2: Data Extraction & API Design
Task: Use GraphQL to index on-chain data and design APIs to fetch and organize it into a spreadsheet.
Steps:
1. GraphQL Setup:
。 Use The Graph Protocolto index the contract’s events. Understand its advantages over traditional REST APIs.
。 Example: Query OpenSea’s OrderFulfilled events for NFT sales data.
。 Tutorias:
i. Indexing Smart Contract Data Using The Graph Protocol
ii. Querying EVM-based smart contracts with GraphQL
2. GraphQL Query Example:
#query GetNFTSales {
orderFulfilleds(first: 100) {
id
offerer
startTime
endTime
tokenId price
}
}
#
3. API Design:
。 Build a Python/Node.js script. to fetch data from The Graph’s GraphQL endpoint.
。 Use libraries like pandas (Python) or axios (Node.js) to format data into CSV/Google Sheets.
4. Spreadsheet Integration
。 Automate data export using Google Sheets API or Excel libraries.
。 Example code
#import requests
import pandas as pd
# GraphQL Query
"""
query =
{
orderFulfilleds(first: 100) { id
offerer price }
}
"""
# Fetch data
response = requests.post("https://api.thegraph.com/subgraphs/name/opensea/seaport", json={"query": query}) data = response.json()["data"]["orderFulfilleds"]
# Save to CSV
df = pd.DataFrame(data)
df.to_csv("opensea_sales.csv")
#
Phase 3: LLM Integration
Task: Use the spreadsheet data to prompt an LLM for analysis (e.g., trend prediction, anomaly detection).
Steps:
1. Data Preparation:
。 Clean and structure the spreadsheet (e.g., add timestamps, normalize prices).
2. LLM Prompt Design:
。 Example: “Analyze the NFT sales data in opensea_sales.csv and predict the next 30-day trend.”
3. Integration:
。 You can just drag-and-drop to the ChatGPT or DeepSeek chatbox and input the prompts.
。 Using OpenAI’s API or DeepSeek’s API to process the data is Optional.
Grading Policy
1. Smart Contract Understanding (20%): Contract description and analysis.
2. GraphQL/API Implementation (30%): Functionality and efficiency.
3. Data Organization (20%): Spreadsheet clarity and structure.
4. LLM Application (20%): Relevance and creativity of use case.
5. Report/Demo (10%): Clarity and presentation.