ChainSentinel
ChainSentinel: Fortifying Web3 Security with AI-Powered Reactive Smart Contracts.
Created on 15th March 2025
•
ChainSentinel
ChainSentinel: Fortifying Web3 Security with AI-Powered Reactive Smart Contracts.
The problem ChainSentinel solves
ChainSentinel addresses the growing security issues in Web3 and decentralized finance (DeFi). While blockchain technology offers many advantages, it also introduces significant security risks. Fraudulent transactions, malicious wallets, and smart contract exploits are increasingly common, and traditional security mechanisms are often insufficient in the decentralized environment. Fraudulent Transactions: In Web3 environments, there is no centralized authority to detect and prevent fraudulent activities. Transactions can easily be manipulated, leading to financial losses. ChainSentinel uses AI-driven fraud detection to assess transaction risk in real-time and flag suspicious transactions before they occur. Malicious Wallets: Blockchain anonymity allows malicious actors to exploit systems without detection. Manually identifying these bad actors is challenging, especially with the high volume of transactions. ChainSentinel automatically flags and blacklists malicious wallets based on transaction patterns using AI algorithms. Reactive Security: Traditional security measures are reactive, allowing malicious actors to exploit vulnerabilities before they are noticed. ChainSentinel offers real-time, proactive security by using reactive smart contracts (RSCs) that automatically take action when suspicious activity is detected. How ChainSentinel Solves These Problems: ChainSentinel combines AI and blockchain technology to offer real-time security for Web3 platforms. AI models predict the risk of each transaction based on historical data, while RSCs automatically execute actions like blacklisting wallets when fraud is detected. This ensures faster, more accurate fraud prevention. By using machine learning and blockchain, ChainSentinel reduces the time window for malicious activities, enhances Web3 security, and makes decentralized environments safer for users and platforms.
User Interaction and Data Flow
User Interaction and Data Flow
ChainSentinel provides seamless interaction through both its AI-powered backend and blockchain smart contract functionality.
- Transaction Risk Prediction
Interaction: Users (platforms or wallet addresses) initiate transactions on a blockchain.
Data Flow:
Transaction data (e.g., sender, receiver, amount, type) is collected by the backend.
The AI model analyzes transaction features, such as transaction frequency, wallet history, and other factors.
The model predicts the transaction’s risk score (safe or suspicious).
Response:
If the transaction score is high risk, the backend returns a warning to the user.
If safe, the transaction proceeds. - Blacklist Management
Interaction: If a transaction is flagged as suspicious or risky, the user can choose to blacklist the malicious wallet address.
Data Flow:
The backend uses the Ethereum-based Reactive Smart Contract (RSC) to update the blacklist.
A request to trigger the blacklist action is sent to the blockchain.
Once confirmed, the contract updates the blacklist in real-time.
Response: The user receives a confirmation that the wallet has been blacklisted, and the address is now blocked from further interactions. - Blacklist Monitoring
Interaction: Users can check if a wallet is blacklisted through the /blacklisted endpoint.
Data Flow:
The system queries the smart contract to check if the wallet is blacklisted.
Response: The user receives a "yes" or "no" indicating whether the wallet is blacklisted. - Proactive Security via RSCs
Interaction: As transactions are detected, ChainSentinel continuously monitors the network for suspicious activity.
Data Flow:
If a transaction or wallet is flagged, RSCs are triggered to block malicious wallets and secure the ecosystem.
Response: The blockchain automatically updates without user intervention, preventing fraud in real-time.
The project architecture and development process
ChainSentinel is an AI-powered security system integrated with blockchain. It uses Reactive Smart Contracts (RSCs) on the Ethereum network and machine learning to detect fraudulent transactions and prevent malicious activities in real-time.
- Core Architecture
Frontend: A web interface (React.js or similar) for user interactions.
Backend: Built using FastAPI, it connects to the AI model and Ethereum blockchain for transaction risk prediction and blacklist management.
AI Model: A machine learning model that predicts transaction risk based on data patterns.
Blockchain: Ethereum network, deploying Reactive Smart Contracts to blacklist malicious wallets.
Smart Contracts: Solidity contracts to manage blacklisting and trigger actions like adding/removing wallets. - Core Functionality
Transaction Risk Prediction: AI evaluates transaction data (e.g., sender, receiver, amount) to generate a risk score.
Reactive Smart Contracts: If a high-risk transaction is detected, RSCs automatically blacklist the wallet.
Blacklist Management: Add/remove wallets from the blacklist using blockchain-powered contracts. - Development Process
Smart Contracts: Written in Solidity to interact with the Ethereum blockchain.
Backend: FastAPI handles requests for transaction prediction, blacklisting, and interacting with the blockchain.
AI Model: Trained using transaction data to identify fraud patterns. Integrated into the backend for real-time predictions.
Frontend: Allows users to interact with the platform, view blacklist status, and submit transaction data. - Key Implementation Details
Blockchain Interaction: Web3.py connects the backend with Ethereum for executing smart contract actions.
Machine Learning: AI model predicts risk scores, flagging suspicious transactions for further action.
Security: Private keys are securely stored, and blockchain transactions are optimized for cost-efficiency.
Product Integrations
ChainSentinel integrates several APIs and services to offer blockchain-based transaction monitoring and fraud detection.
- Ethereum Network (Web3)
Role: Web3.py facilitates interaction with Ethereum, enabling smart contract execution and wallet blacklisting. It connects the backend with the Ethereum network.
Use: Monitors wallet activities and triggers actions like adding/removing wallets from the blacklist via Reactive Smart Contracts (RSCs). - AI Fraud Detection Model
Role: The AI model analyzes transaction features to predict the likelihood of fraud. This helps in identifying high-risk wallets.
Use: It calculates risk scores for transactions and flags suspicious behavior. - Alchemy (Ethereum Node Provider)
Role: Alchemy provides Ethereum node access for blockchain interactions, ensuring scalability and security in production.
Use: Used to query data, send transactions, and deploy smart contracts on the Ethereum network. - Joblib (Model Serialization)
Role: Joblib serializes and deserializes the AI fraud detection model for efficient storage and retrieval.
Use: Ensures that the AI model can be loaded and used during backend operations for real-time fraud detection.
Key differentiators and uniqueness of the project
Key Differentiators and Uniqueness of the Project
ChainSentinel stands out with its unique integration of AI-powered fraud detection and blockchain-based security. Key differentiators include:
- AI-Driven Fraud Detection
Feature: Utilizes machine learning models to analyze transaction data and predict fraud risk.
Benefit: Unlike traditional systems that rely on simple pattern recognition, ChainSentinel offers data-driven, accurate fraud detection to minimize false positives. - Reactive Smart Contracts (RSCs)
Feature: Implements RSCs on Ethereum to blacklist wallets and perform real-time actions based on AI predictions.
Benefit: Provides immediate, automated responses to fraud, unlike systems that only alert after the fact, significantly reducing response time and damage. - Ethereum Integration
Feature: Directly integrates with Ethereum using Web3 for secure contract interactions.
Benefit: Ensures decentralized and transparent blockchain operations, unlike centralized services that introduce single points of failure. - Scalability and Reliability
Feature: Leverages Alchemy for seamless blockchain connectivity.
Benefit: Scalable to handle high transaction volumes, offering greater reliability and performance compared to self-hosted nodes. - Comprehensive Security Solution
Feature: Combines wallet blacklisting, real-time fraud detection, and automated blockchain actions in one integrated platform.
Benefit: Offers a more holistic solution compared to other tools that focus only on monitoring or auditing, providing an end-to-end security approach.
Trade-offs and shortcuts while building
Trade-offs and Shortcuts While Building
Building ChainSentinel required balancing complexity, time constraints, and available resources. Below are key decisions made during the development:
- AI Model Complexity
Trade-off: We opted for a pre-trained machine learning model for fraud detection instead of building a custom model from scratch, prioritizing speed over complexity.
Quick Fix: Basic transaction features (e.g., amount, frequency) were used instead of more advanced data points to reduce development time.
Future Improvements: Future iterations will incorporate more advanced features, such as transaction history and network analysis, to improve model accuracy. - Smart Contract Design
Trade-off: The smart contract was kept simple, focusing only on wallet blacklisting and reactive actions, with more complex fraud-handling features left out.
Quick Fix: Gas optimization was prioritized by limiting contract state modifications.
Future Improvements: Additional functionalities, like multi-signature support and dynamic triggers based on fraud patterns, will be added. - Blockchain Network Selection
Trade-off: Ethereum was chosen due to its widespread adoption, despite higher gas fees and slower transaction times compared to newer blockchains.
Quick Fix: Basic gas optimizations were implemented to manage costs effectively.
Future Improvements: Layer 2 solutions (e.g., Polygon) will be explored to reduce fees and enhance scalability. - Backend Scalability
Trade-off: We kept the backend simple with synchronous functions for fraud detection and avoided complex features like multi-threading or asynchronous processing.
Quick Fix: Synchronous processing was chosen for simplicity, and future scalability was planned.
Future Improvements: Asynchronous task queues (e.g., Celery) will be integrated for improved performance.
Additional Features
The project was created during hackathon itself and 1. AI-Powered Fraud Detection
Integrated an AI model that analyzes transaction patterns to detect fraudulent activities in real-time, improving security.
- Reactive Smart Contracts (RSC)
Implemented RSCs that automatically take actions, like blacklisting wallets, based on AI risk signals, making the system more efficient and autonomous.
- Real-Time Blockchain Event Monitoring
Added functionality to monitor and alert users of potential security breaches in real-time, enhancing the system’s responsiveness.
- Automated Wallet Blacklisting
Developed an automatic system to blacklist wallets flagged by AI, reducing manual effort and increasing the speed of response.
- Improved UI for Real-Time Data
Refined the frontend to provide better visualizations of blockchain security events, offering users easy-to-understand charts and alerts.
- Expanded API Endpoints
Introduced new API endpoints to fetch detailed security reports, including blacklist status and transaction analysis, for enhanced user interaction.
Tracks Applied (2)
Innovative ways to leverage Reactive Smart Contracts (RSCs)
Reactive Network
Incorporate Reactive Smart Contracts (RSCs) in your applications
Reactive Network
Technologies used
Ethereum Blockchain Used for deploying and interacting with Reactive Smart Contracts (RSCs) to secure blockchain transactions and blacklist fraudulent wallets in real-time.
Smart Contracts (Solidity) Used to write and deploy the smart contracts that facilitate automated blacklisting and the triggering of reactive actions on the Ethereum blockchain.
Web3.py Python library used to interact with the Ethereum blockchain
FastAPI Used for creating the backend REST API to facilitate communication between the frontend
AI/ML Model (Fraud Detection) A machine learning model built using Python and scikit-learn to predict fraudulent transactions based on certain features extracted from transaction data.
Joblib Used to load pre-trained models (fraud detection and scaling models) efficiently in the backend.
Alchemy API Used to connect the project to the Ethereum mainnet for interacting with deployed smart contracts and performing blockchain operations.
Node.js & npm Used for managing JavaScript dependencies and running the frontend development environment.
Tailwind CSS Utilized for building a responsive and user-friendly frontend interface that interacts with the backend to visualize transaction risks and blacklisted wallets.
JSON Used for reading and writing blacklist data and smart contract ABIs. Also
Cheer Project
Cheering for a project means supporting a project you like with as little as 0.0025 ETH. Right now, you can Cheer using ETH on Arbitrum, Optimism and Base.
