Jagadish Writes Logo - Light Theme
Published on

How Machine Learning Detects On-Chain Anomalies

Listen to the full article:

Authors
  • avatar
    Name
    Jagadish V Gaikwad
    Twitter
Source

What are on-chain anomalies?

On-chain anomalies are blockchain activities that differ significantly from expected behavior. The activity might involve an unusual transfer amount, a new relationship between wallets, a sudden burst of transactions, or a smart contract interaction that conflicts with an address’s previous pattern.

The phrase does not automatically mean fraud. A large transfer could belong to an exchange treasury, a protocol migration, or a legitimate institutional user. Machine learning identifies activity that deserves attention; it does not establish intent or liability by itself.

This distinction matters because blockchains are transparent but not inherently self-explanatory. A ledger can show that assets moved between addresses, yet it may not reveal who controls those addresses or why the transfer occurred. Detection systems therefore combine transaction data, graph relationships, timing, contract behavior, and external labels.

Research on Ethereum fraud detection commonly models the blockchain as a graph, where accounts and contracts are connected by transactions. Studies using graph neural networks have reported that relationship structure can improve fraud classification compared with treating each transaction as an isolated record, although results depend heavily on the dataset and labels.Ethereum fraud detection with heterogeneous graph neural networks

What data does a detection model examine?

A model usually receives a feature set rather than a raw blockchain history. Features are measurable properties extracted from blocks, transactions, addresses, tokens, contracts, and their relationships.

Common feature categories include:

  • Transaction features: value, token type, gas used, transaction status, method called, input data, and whether assets moved in or out.
  • Temporal features: transaction frequency, time between transfers, activity bursts, dormant-period reactivation, and behavior by hour or day.
  • Address features: account age, balance changes, number of counterparties, incoming-to-outgoing ratios, and interactions with known services.
  • Graph features: degree, centrality, connected components, transaction paths, shared counterparties, and proximity to labeled entities.
  • Contract features: functions called, bytecode patterns, upgradeability signals, token permissions, and interactions with decentralized-finance protocols.
  • Cross-asset features: whether an address rapidly moves value across several tokens, chains, bridges, or decentralized exchanges.

Feature engineering converts a complex history into signals a model can compare. For example, “this wallet sent funds” is not very informative on its own. “This newly active wallet received funds from several unrelated addresses, consolidated them within minutes, and routed them through a mixer-like service” is a more useful behavioral representation.

The feature design must also respect blockchain differences. Account-based networks such as Ethereum record balances and contract calls differently from UTXO-based networks such as Bitcoin. A model trained on one network may not transfer cleanly to another without new features, labels, and validation.

How machine learning detects unusual behavior

Most systems use several analytical approaches rather than one universal algorithm.

Rule-based screening

Rules are the simplest layer. A system can flag transfers above a threshold, rapid movement through a chain of addresses, interactions with sanctioned entities, or a contract call associated with a known exploit.

Rules are transparent and useful for high-confidence patterns. They are also easy to evade when attackers understand the thresholds. Fixed rules may miss slow-moving schemes, adapt poorly to new tactics, and generate too many alerts when legitimate behavior changes.

Machine learning often supplements rules instead of replacing them. Rules can provide immediate controls, while models rank less obvious activity for investigation.

Statistical and unsupervised detection

Unsupervised models search for observations that are unusual relative to a reference population. Clustering groups addresses or transactions with similar behavior. Isolation-based methods attempt to separate rare observations efficiently. Autoencoders learn to reconstruct common patterns and flag cases with unusually high reconstruction error.

These approaches are useful when labeled fraud data is scarce. However, rare does not mean malicious. A new protocol, a market-making strategy, or a major exchange operation may look anomalous simply because it is uncommon.

A stronger system defines the comparison group carefully. A transaction should not necessarily be compared with every address on a network. It may be more meaningful to compare it with other decentralized-exchange routers, stablecoin traders, bridges, or wallets of a similar age and activity level.

Supervised classification

Supervised models learn from examples labeled as legitimate, suspicious, or fraudulent. Inputs can include transaction features, address histories, graph measurements, and contract characteristics.

The model produces a score or class prediction. Investigators then combine that output with evidence such as transaction traces, known entity information, and contract analysis.

The quality of the labels is a major limitation. Public labels often come from reported phishing addresses, sanctions lists, confirmed incidents, or manually reviewed cases. These labels may be incomplete, biased toward visible activity, or delayed until after the event. A model can therefore perform well on a benchmark while struggling with new attack patterns in production.

Graph neural networks

Blockchains naturally form graphs. Addresses, contracts, tokens, and transactions can be represented as nodes and edges, sometimes with different node and relationship types.

Graph neural networks, or GNNs, learn from both node attributes and neighboring relationships. A wallet’s behavior may look ordinary in isolation but suspicious when viewed as part of a group that shares funding sources, timing patterns, and cash-out routes.

A heterogeneous graph keeps different entity and relationship types separate. For example, a transfer from an externally owned account to a smart contract is not identical to a token approval, a contract-to-contract call, or a bridge transfer. Research comparing graph models for Ethereum phishing detection found that heterogeneous approaches can outperform simpler homogeneous representations in that setting.Ethereum Fraud Detection with Heterogeneous Graph Neural Networks

Other studies have used graph convolutional networks and transaction-network embeddings to classify potentially fraudulent Ethereum addresses. One published framework reported high accuracy on its fraud-versus-legitimate dataset, but that result should not be interpreted as a universal real-world error rate because the dataset, labels, and evaluation design determine what the number means.Ethereum fraud behavior detection based on graph neural networks

Sequence and time-series models

Some anomalies are defined by order rather than by a single transaction. A wallet may receive assets, swap them, bridge them, split them across several addresses, and consolidate the proceeds. Sequence models analyze these ordered events.

Time-aware systems can detect changes in a wallet’s baseline behavior. A dormant address that suddenly performs dozens of contract calls is different from an active trading wallet that performs the same number of calls every day.

The time window is important. A model looking at five minutes may detect transaction bursts but miss a slow laundering pattern. A model looking at six months may capture long-term behavior but respond too slowly to an active exploit. Practical systems often combine short, medium, and long windows.

Source

A practical detection workflow

A production pipeline commonly follows these stages:

  1. Collect ledger data. Index blocks, transactions, logs, traces, token transfers, contract metadata, and relevant cross-chain events.
  2. Normalize entities and events. Standardize timestamps, token amounts, contract methods, chain identifiers, and address formats.
  3. Build features. Calculate behavioral, temporal, transactional, and graph-based signals over defined time windows.
  4. Establish a baseline. Compare activity with the address’s history, peer groups, protocol norms, or network-wide distributions.
  5. Score the activity. Apply rules, anomaly models, classifiers, graph models, or an ensemble of these methods.
  6. Prioritize alerts. Combine model confidence, transaction value, exposure, entity context, and urgency.
  7. Investigate and label. Review the transaction path and supporting evidence, then record the outcome for future evaluation.
  8. Monitor drift. Test whether behavior, data quality, or attacker tactics have changed over time.

A useful alert is not merely a high score. It should explain which signals contributed to the result: unusual funding source, rapid fan-out, new contract interaction, abnormal token approval, or proximity to a known risky cluster. Explainability helps analysts make decisions and helps engineers identify model failures.

Detection approaches compared

ApproachBest useMain strengthMain limitation
RulesKnown addresses and explicit thresholdsEasy to explain and enforceBrittle against novel or adaptive behavior
Unsupervised modelsPreviously unseen patternsWorks with limited labelsRare legitimate activity can look suspicious
Supervised modelsRepeated, labeled threat categoriesCan optimize for measurable outcomesLabels may be incomplete or biased
Graph neural networksConnected fraud and entity behaviorCaptures relationships and transaction contextComputationally demanding and sensitive to graph quality
Sequence modelsMulti-step attacks and behavior changesPreserves event order and timingRequires reliable temporal data and careful windows
Human review with model supportHigh-impact decisionsAdds context and accountabilitySlower and more expensive than automation alone

The appropriate choice depends on the consequence of an error. A monitoring dashboard may tolerate more false positives, while an automatic account restriction requires a higher evidentiary standard and an appeal process.

Why anomaly detection produces false positives

False positives arise because legitimate blockchain activity can be unusual. A treasury may move funds between many addresses. A market maker may execute rapid, high-volume trades. A protocol upgrade can create a sudden increase in contract calls. A new token launch may generate transaction patterns that resemble bot activity.

False negatives are equally serious. Attackers can distribute activity across addresses, delay transfers, use privacy-enhancing tools, exploit bridges, or imitate normal user behavior. A model trained on historical incidents may recognize yesterday’s tactics better than tomorrow’s.

Several evaluation practices reduce overconfidence:

  • Separate training, validation, and testing by time so future information does not leak into the past.
  • Measure precision, recall, and alert volume rather than reporting accuracy alone.
  • Test on addresses and entities that were not present in training data.
  • Evaluate performance across chains, tokens, protocols, and activity levels.
  • Review false positives by category, not only as a single aggregate number.
  • Calibrate scores so a high score has a consistent meaning.
  • Reassess the model after protocol upgrades, data-provider changes, and major incidents.

Reported benchmark performance can look strong while production performance deteriorates when the threat landscape changes. For example, a recent Ethereum fraud-detection study describes a semi-supervised graph approach designed to reduce the dependence on fully labeled data, reflecting a recurring challenge in this field.A scalable and semi-supervised approach for Ethereum fraud detection using Graph Neural Networks and K-Nearest Neighbors clustering

How analysts validate an alert

Machine learning should narrow the investigation, not replace it. Analysts typically inspect:

  • The complete flow of funds rather than only the flagged transaction.
  • Funding and withdrawal sources.
  • Shared counterparties and repeated address clusters.
  • Contract code, permissions, approvals, and event logs.
  • Timing relative to a protocol incident or market event.
  • Whether the behavior is consistent with a known exchange, bridge, treasury, or service.
  • Evidence from multiple chains and off-chain records where lawfully available.

Entity attribution requires special caution. Address clustering is an inference based on observable behavior, not automatic proof that one person or organization controls every related address. A responsible report should distinguish direct ledger facts from model-generated links and analyst judgments.

Industry investigations increasingly use blockchain transparency with advanced analytics to study scams, decentralized-finance exploits, ransomware, and cross-chain activity. Chainalysis describes these categories in its 2026 Crypto Crime Report, but commercial reports should be treated as industry analysis rather than neutral ground truth.Chainalysis 2026 Crypto Crime Report

Source

Privacy, governance, and operational risks

On-chain data is public, but analytics can create sensitive profiles when wallet activity is combined with exchange records, web identifiers, or other personal information. Organizations should define lawful data use, retention periods, access controls, and procedures for correcting inaccurate labels.

Models also inherit bias from their training data. If confirmed fraud reports disproportionately cover certain chains, regions, asset types, or user groups, the system may over-monitor those categories and under-detect less visible threats.

Security controls matter as much as model quality. An attacker who can influence the training data, manipulate labels, or trigger alert floods can degrade the system. Access to labels, investigation notes, and entity mappings should be restricted and audited.

Automation should be proportional to confidence and impact. Low-confidence alerts can enter a queue. High-confidence technical controls may pause a workflow, but irreversible financial or account decisions generally require additional evidence and human review.

How to assess an on-chain anomaly system

Before adopting a vendor or building an internal pipeline, ask:

  • What chains, assets, contracts, and event types does it cover?
  • Are scores based on rules, supervised labels, graph analysis, or a combination?
  • How are labels sourced, verified, updated, and removed?
  • Can analysts see the evidence behind each alert?
  • How are false positives measured and handled?
  • Does evaluation use time-separated and entity-separated test data?
  • How quickly does the system ingest new blocks and re-score activity?
  • What happens when a chain reorganizes or indexed data changes?
  • Can the system detect cross-chain paths rather than isolated activity?
  • How are privacy, retention, access, and regulatory obligations managed?

A strong evaluation focuses on operational outcomes: useful alerts per analyst, time to triage, missed incidents, explainability, and stability after new protocols or attack methods appear. A single benchmark score is not enough.

Conclusion

Machine learning detects on-chain anomalies by comparing blockchain behavior with learned patterns across transactions, time, entities, contracts, and graph relationships. Rules identify known signals, unsupervised methods surface unfamiliar behavior, supervised models classify labeled risks, and graph or sequence models reveal relationships and multi-step activity that isolated transaction analysis can miss.

The most reliable design treats the model as an evidence-ranking system. It combines transparent features, carefully governed labels, time-aware testing, human validation, and continuous monitoring for drift. An unusual transaction is a starting point for investigation—not proof of wrongdoing.

You may also like

Comments: