Pengembangan Smart Contract Discovery System Berbasis Konteks Semantik
π Tugas Akhir - Institut Teknologi Bandung
Kenneth Ezekiel Suprantoni (13521089)
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.
- π§ 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
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 β β β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
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
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
- Python 3.8+
- Node.js 18+
- Rust 2021 edition
- Docker & Docker Compose
- OpenAI API Key
-
Clone the repository
git clone https://github.com/username/tugas-akhir.git cd tugas-akhir -
Setup DgraphDB (Data Storage)
cd impl/eth2dgraph docker-compose up -d -
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
-
Setup Frontend
cd impl/web npm install
-
Start the Backend API
cd impl/system python -m uvicorn src.api.api:app --reload --host 0.0.0.0 --port 8000 -
Start the Frontend
cd impl/web npm run dev -
Access the Application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- DgraphDB UI (Ratel): http://localhost:8001
Query: "ERC20 token with mint and burn functions"
Results: Smart contracts that implement ERC20 standard with minting/burning capabilities
Query: "DeFi lending protocol with liquidation mechanism and oracle integration"
Results: Detailed analysis of DeFi contracts with specific functionalities
curl -X POST "http://localhost:8000/search" \
-H "Content-Type: application/json" \
-d '{
"query": "NFT marketplace with royalty system",
"limit": 10,
"data": true
}'- Extraction: eth2dgraph extracts Smart Contract data from Ethereum Archive Node
- Storage: Raw data stored in DgraphDB
- Enrichment: LLM processes contracts for semantic understanding
- Vectorization: Embeddings create vector representations
- Search: ChromaDB enables semantic similarity search
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
This work is part of the final thesis:
"Pengembangan Smart Contract Discovery System Berbasis Konteks Semantik"
Kenneth Ezekiel Suprantoni (13521089)
Institut Teknologi Bandung, 2025
Kenneth Ezekiel Suprantoni
- Institution: Institut Teknologi Bandung
- Program: Teknik Informatika