Paper 2025/1634

BlockLens: Detecting Malicious Transactions in Ethereum Using LLM Techniques

Chi Feng, Shanghai Jiao Tong University
Lei Fan, Shanghai Jiao Tong University
Abstract

This paper presents BlockLens, a supervised, trace-level framework for detecting malicious Ethereum transactions using large language models. Unlike previous approaches that rely on static features or storage-level abstractions, our method processes complete execution traces, capturing opcode sequences, memory information, gas usage, and call structures to accurately represent the runtime behavior of each transaction. This framework harnesses the exceptional reasoning capabilities of LLMs for long input sequences and is fine-tuned on transaction data. We present a tokenization strategy aligned with Ethereum Virtual Machine (EVM) semantics that converts transaction execution traces into tokens. Each transaction captures its complete execution trace through simulated execution and is sliced into overlapping chunks using a sliding window, allowing for long-range context modeling within memory constraints. During inference, the model outputs both a binary decision and a probability score indicating the likelihood of malicious behavior. We implemented the framework based on LLaMA 3.2-1B and fine-tuned the model using LoRA. We evaluated it on a curated dataset that includes both real-world attacks and normal DeFi transactions. Our model outperforms representative baselines, achieving higher F1 scores and recall at top-k thresholds. Additionally, this work offers interpretable chunk-level outputs that enhance explainability and facilitate actionable decision-making in security-critical environments.

Metadata
Available format(s)
PDF
Category
Applications
Publication info
Published elsewhere. ISC2025
Keywords
EthereumMalicious Transaction DetectionLarge Language Models
Contact author(s)
0xfionaf @ gmail com
fanlei @ sjtu edu cn
History
2025-09-12: approved
2025-09-10: received
See all versions
Short URL
https://ia.cr/2025/1634
License
Creative Commons Attribution
CC BY

BibTeX

@misc{cryptoeprint:2025/1634,
      author = {Chi Feng and Lei Fan},
      title = {{BlockLens}: Detecting Malicious Transactions in Ethereum Using {LLM} Techniques},
      howpublished = {Cryptology {ePrint} Archive, Paper 2025/1634},
      year = {2025},
      url = {https://eprint.iacr.org/2025/1634}
}
Note: In order to protect the privacy of readers, eprint.iacr.org does not use cookies or embedded third party content.