Skip to content

KenEzekiel/tugas-akhir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

185 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Smart Contract Discovery System

Pengembangan Smart Contract Discovery System Berbasis Konteks Semantik

License: Apache 2.0 Python 3.8+ Next.js Rust

πŸ“ Tugas Akhir - Institut Teknologi Bandung
Kenneth Ezekiel Suprantoni (13521089)

🎯 Overview

Smart Contract Discovery System adalah sistem pencarian Smart Contract berbasis semantik yang memungkinkan pengguna menemukan Smart Contract yang relevan menggunakan query dalam bahasa alami. Sistem ini memanfaatkan Semantic Enrichment dengan Large Language Models (LLM) untuk memberikan hasil pencarian yang lebih akurat dan kontekstual dibandingkan metode pencarian berbasis kata kunci tradisional.

πŸš€ Key Features

  • 🧠 Semantic Search: Pencarian berbasis makna menggunakan vector embeddings dan LLM
  • πŸ” Natural Language Queries: Mendukung pencarian dengan bahasa alami
  • πŸ“Š Smart Contract Analysis: Analisis mendalam terhadap kode Smart Contract
  • πŸ›‘οΈ Security Insights: Deteksi potensi risiko keamanan
  • 🎨 Modern UI: Interface yang user-friendly dengan Next.js dan Tailwind CSS
  • ⚑ Real-time Search: Pencarian cepat dengan caching dan optimisasi

πŸ—οΈ Architecture

Sistem ini terdiri dari beberapa komponen utama:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚    β”‚   Backend API    β”‚    β”‚   Data Sources  β”‚
β”‚   (Next.js)     │◄──►│   (FastAPI)      │◄──►│   - DgraphDB    β”‚
β”‚                 β”‚    β”‚                  β”‚    β”‚   - ChromaDB    β”‚
β”‚   - Search UI   β”‚    β”‚   - Retriever    β”‚    β”‚   - Ethereum    β”‚
β”‚   - Results     β”‚    β”‚   - Enrichment   β”‚    β”‚     Archive     β”‚
β”‚   - Details     β”‚    β”‚   - Vector DB    β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Technology Stack

Frontend:

  • Next.js 15 with App Router
  • TypeScript
  • Tailwind CSS + Radix UI
  • React Hook Form

Backend:

  • FastAPI (Python)
  • LangChain for LLM integration
  • OpenAI GPT models
  • HuggingFace embeddings

Databases:

  • DgraphDB (Graph database untuk Smart Contract data)
  • ChromaDB (Vector database untuk semantic search)

Data Extraction:

  • eth2dgraph (Rust) untuk ekstraksi data dari Ethereum
  • Alchemy Archive Node sebagai data source

πŸ“ Project Structure

tugas-akhir/
β”œβ”€β”€ impl/                          # Implementation code
β”‚   β”œβ”€β”€ eth2dgraph/               # Rust-based Ethereum data extractor
β”‚   β”‚   β”œβ”€β”€ src/                  # Rust source code
β”‚   β”‚   β”œβ”€β”€ Cargo.toml           # Rust dependencies
β”‚   β”‚   └── docker-compose.yml   # DgraphDB setup
β”‚   β”œβ”€β”€ system/                   # Python backend system
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ api/             # FastAPI endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ core/            # Core business logic
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ data_access/ # Database clients
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ data_processing/ # LLM enrichment
β”‚   β”‚   β”‚   β”‚   └── data_retrieval/ # Search & retrieval
β”‚   β”‚   β”‚   └── utils/           # Utility functions
β”‚   β”‚   β”œβ”€β”€ config/              # Configuration files
β”‚   β”‚   β”œβ”€β”€ requirements.txt     # Python dependencies
β”‚   β”‚   └── openapi.yaml         # API documentation
β”‚   └── web/                      # Next.js frontend
β”‚       β”œβ”€β”€ app/                 # App router pages
β”‚       β”œβ”€β”€ components/          # React components
β”‚       β”œβ”€β”€ hooks/               # Custom React hooks
β”‚       β”œβ”€β”€ lib/                 # Utility libraries
β”‚       └── package.json         # Node dependencies
└── src/                          # LaTeX thesis documentation
    β”œβ”€β”€ thesis.tex               # Main thesis document
    β”œβ”€β”€ chapters/                # Thesis chapters
    └── config/                  # LaTeX configuration

πŸš€ Getting Started

Prerequisites

  • Python 3.8+
  • Node.js 18+
  • Rust 2021 edition
  • Docker & Docker Compose
  • OpenAI API Key

πŸ”§ Installation

  1. Clone the repository

    git clone https://github.com/username/tugas-akhir.git
    cd tugas-akhir
  2. Setup DgraphDB (Data Storage)

    cd impl/eth2dgraph
    docker-compose up -d
  3. Setup Backend System

    cd impl/system
    pip install -r requirements.txt
    
    # Configure environment variables
    cp .env.example .env
    # Edit .env file with your API keys
  4. Setup Frontend

    cd impl/web
    npm install

πŸƒβ€β™‚οΈ Running the System

  1. Start the Backend API

    cd impl/system
    python -m uvicorn src.api.api:app --reload --host 0.0.0.0 --port 8000
  2. Start the Frontend

    cd impl/web
    npm run dev
  3. Access the Application

πŸ“– Usage

Basic Search

Query: "ERC20 token with mint and burn functions"
Results: Smart contracts that implement ERC20 standard with minting/burning capabilities

Advanced Search

Query: "DeFi lending protocol with liquidation mechanism and oracle integration"
Results: Detailed analysis of DeFi contracts with specific functionalities

API Usage

curl -X POST "http://localhost:8000/search" \
     -H "Content-Type: application/json" \
     -d '{
       "query": "NFT marketplace with royalty system",
       "limit": 10,
       "data": true
     }'

πŸ”¬ Data Pipeline

  1. Extraction: eth2dgraph extracts Smart Contract data from Ethereum Archive Node
  2. Storage: Raw data stored in DgraphDB
  3. Enrichment: LLM processes contracts for semantic understanding
  4. Vectorization: Embeddings create vector representations
  5. Search: ChromaDB enables semantic similarity search

πŸ§ͺ Testing

The system includes comprehensive testing methodologies:

  • Relevansi Hasil Pencarian (UK1): Accuracy measurement using labeled datasets
  • Kualitas Semantik Data (UK2): Semantic expressiveness evaluation
  • Kemiripan Hasil (UK3): Semantic similarity scoring
  • Konsistensi Hasil (UK4): Jaccard Index for result consistency

πŸ“š Research Publication

This work is part of the final thesis:

"Pengembangan Smart Contract Discovery System Berbasis Konteks Semantik"
Kenneth Ezekiel Suprantoni (13521089)
Institut Teknologi Bandung, 2025

πŸ“§ Contact

Kenneth Ezekiel Suprantoni

  • Institution: Institut Teknologi Bandung
  • Program: Teknik Informatika

Made with ❀️ for the advancement of blockchain technology and semantic search

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors