Skip to content

Repository files navigation

AML Shield — Blockchain-Based Anti-Money Laundering Framework

A hybrid AML detection framework combining Isolation Forest anomaly detection with rule-based risk scoring, secured by Ethereum blockchain for immutable audit trails.

Python Solidity License


Overview

Traditional Anti-Money Laundering (AML) systems rely on centralized, rule-based approaches that struggle with adaptability, transparency, and cross-institutional visibility. This project proposes a hybrid AML framework that addresses these limitations through:

  1. Isolation Forest — Unsupervised ML algorithm detecting novel anomalous transaction patterns without labeled data
  2. Rule-Based Risk Scoring — Captures known suspicious patterns (structuring, high-value transfers, rapid-fire transactions)
  3. Hybrid Scoring — Weighted combination S = αA + βR that outperforms either approach alone
  4. Blockchain Ledger — Ethereum-based immutable storage ensuring tamper-proof audit trails

All transaction amounts are in Indian Rupees (₹), with thresholds aligned to Indian AML regulations (PMLA).


Architecture

┌─────────────────────────────────────────────────────────────────┐
│                     Frontend Dashboard                          │
│          (HTML/CSS/JS, Chart.js, Ethers.js)                     │
└────────────────────────┬────────────────────────────────────────┘
                         │ REST API
┌────────────────────────▼────────────────────────────────────────┐
│                   Flask Backend (Orchestration)                  │
│                                                                 │
│  ┌──────────────────┐    ┌──────────────────┐                   │
│  │  Isolation Forest │    │  Rule-Based      │                   │
│  │  (Anomaly Score)  │    │  (Risk Score)    │                   │
│  └────────┬─────────┘    └────────┬─────────┘                   │
│           │      Hybrid Scorer    │                              │
│           └──────┬───────────────┘                              │
│                  ▼                                               │
│         S = αA + βR → Classification                            │
└─────────────────┬───────────────────────────────────────────────┘
                  │ Web3.py
┌─────────────────▼───────────────────────────────────────────────┐
│              Ethereum Blockchain (Hardhat / Sepolia)             │
│              AMLRegistry Smart Contract (Solidity)              │
│              Immutable Transaction + Classification Storage      │
└─────────────────────────────────────────────────────────────────┘

Features

  • Hybrid Detection — Combines ML anomaly detection + rule-based scoring
  • 5 Laundering Patterns — Structuring, layering, round-tripping, large transfers, rapid-fire
  • 50,000 Transaction Dataset — Seed-reproducible synthetic generator (INR-denominated)
  • 4-Method Comparison — Isolation Forest vs. One-Class SVM vs. Rule-Based vs. Hybrid
  • Ablation Study — α/β weight sweep to find optimal hybrid balance
  • Publication-Quality Figures — ROC curves, PR curves, confusion matrices, per-pattern detection
  • Smart Contracts — Solidity-based immutable audit trail on Ethereum
  • State-of-the-Art Dashboard — Dark mode, glassmorphism, real-time charts
  • Full Reproducibility — Single command generates all results

Quick Start

Prerequisites

  • Python 3.9+
  • Node.js 18+ (LTS)
  • Git

1. Clone & Install

git clone <repo-url>
cd AML

# Python dependencies
pip install -r requirements.txt

# Node.js dependencies (Hardhat + Solidity)
npm install

2. Run the ML Experiment Pipeline

python run_experiments.py

This single command:

  • Generates the synthetic dataset (50,000 transactions)
  • Extracts behavioral features
  • Trains Isolation Forest & One-Class SVM
  • Computes rule-based and hybrid scores
  • Runs ablation study
  • Produces all figures and tables in results/

3. Deploy Smart Contract (Local)

# Terminal 1: Start local blockchain
npx hardhat node

# Terminal 2: Deploy contract
npm run deploy:local

4. Start Backend API

python backend/app.py

5. Open Dashboard

Open frontend/index.html in your browser, or serve it:

cd frontend && python -m http.server 8080

Navigate to http://localhost:8080


Sepolia Testnet Deployment

  1. Copy .env.example to .env
  2. Add your Infura/Alchemy RPC URL and wallet private key
  3. Deploy:
npm run deploy:sepolia

Project Structure

AML/
├── contracts/          # Solidity smart contracts
│   └── AMLRegistry.sol
├── scripts/            # Deployment scripts
├── test/               # Smart contract tests
├── ml/                 # Machine learning pipeline
│   ├── config.py           # Centralized configuration
│   ├── data_generator.py   # Synthetic dataset generator
│   ├── feature_engineering.py
│   ├── isolation_forest.py
│   ├── rule_engine.py
│   ├── hybrid_scorer.py
│   └── evaluate.py
├── backend/            # Flask API server
├── frontend/           # Web dashboard
├── notebooks/          # Jupyter notebooks for paper
├── results/            # Generated figures, tables, metrics
├── run_experiments.py  # Master reproducibility script
└── README.md

Results

After running python run_experiments.py, results are saved to:

Output Location
Figures (ROC, PR, confusion matrices) results/figures/
Comparison tables (CSV + LaTeX) results/tables/
All metrics (JSON) results/metrics/
Trained models ml/models/
Dataset data/synthetic_transactions.csv

Technology Stack

Layer Technology
ML Pipeline Python, Scikit-learn, Pandas, NumPy
Visualization Matplotlib, Seaborn, Chart.js
Smart Contracts Solidity 0.8.20
Blockchain Dev Hardhat, Ethers.js
Backend Flask, Web3.py
Frontend HTML5, CSS3, JavaScript
Testnet Ethereum Sepolia

Research Paper Components

This implementation directly supports the following paper sections:

  • Methodology — Hybrid scoring formula, feature engineering, 5 laundering patterns
  • Experiments — 4-method comparison, ablation study, per-pattern detection
  • Results — Publication-quality figures and LaTeX tables
  • Implementation — Full system architecture with blockchain integration

References

  1. H. Farrukh et al., "Blockchain-Based Fraud Detection: A Comparative Study," Electronics, vol. 14, 2025.
  2. A. K. Singh and R. Kumar, "Credit Card Fraud Detection Using Isolation Forest," SSRN, 2021.
  3. S. Sharma et al., "Anomaly Detection in Blockchain Using Machine Learning," ResearchGate, 2024.
  4. R. Patel et al., "Blockchain-Based Fraud Detection Enhanced with AI," IJRASET, 2023.
  5. Y. Zhang et al., "Blockchain-Based Anti-Money Laundering Using ML," Cryptography, vol. 9, 2024.

License

This project is for academic and research purposes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages