Autonomous AI-powered defense that detects DeFi exploits and coordinates on-chain rescue.
DeFi protocols operate in an increasingly hostile environment where exploits can drain millions of dollars within minutes. Traditional security mechanisms are largely reactive: they generate alerts, depend on human intervention, and often respond too slowly to prevent catastrophic losses.
Heartbeat Protocol is an autonomous, AI-powered security and emergency-response system designed to detect, investigate, and respond to threats targeting decentralized finance protocols.
Inspired by the human cardiovascular system, Heartbeat continuously monitors the health of DeFi protocols, identifies abnormal activity, diagnoses potential exploits, and coordinates emergency responses before vulnerabilities escalate into catastrophic financial losses.
The system operates through six interconnected stages:
Detect — Continuous Threat Monitoring Heartbeat monitors blockchain transaction activity, smart contract events, and protocol telemetry to identify suspicious behavior, abnormal transaction patterns, and potential exploit indicators.
Diagnose — AI-Powered Security Analysis When suspicious activity is detected, the system uses AI-powered analysis to investigate transaction data, event logs, and relevant contract information. Local AI inference through Ollama enables security analysis without depending entirely on external AI services.
Investigate — Protocol-Wide Risk Assessment Heartbeat extends beyond individual transactions by scanning DAO portfolios and associated protocols to identify shared vulnerabilities, interconnected risks, and potential systemic exposure.
Respond — Autonomous Emergency Intervention When a critical threat is identified, the system coordinates emergency response through its HeartbeatGuardian smart contract. Its rescue mechanism is designed to facilitate emergency fund protection and recovery operations.
Record — Immutable Security Audit Trail VitalRegistry records security events, detected anomalies, and intervention outcomes on-chain, providing a transparent and verifiable history of security operations.
Visualize — Real-Time Security Intelligence A web-based monitoring dashboard brings together protocol health, threat detection, investigation results, and emergency-response activity.
The architecture combines smart contract enforcement, autonomous blockchain workflows, and AI-powered threat intelligence to move DeFi security from reactive monitoring toward proactive, automated defense.
Heartbeat Protocol aims to give decentralized financial systems something they have historically lacked: an autonomous defense mechanism capable of detecting a threat, understanding its implications, and coordinating an emergency response when every second matters.
Heartbeat Protocol is built using a combination of Solidity smart contracts, Chainlink Runtime Environment (CRE), local AI inference, and a modern Web3 frontend.
The architecture is divided into four primary layers:
It consists of three core contracts:
HeartbeatGuardian.sol: The primary emergency-response contract responsible for coordinating security interventions and emergency fund-rescue operations.
VitalRegistry.sol: Maintains an immutable on-chain record of security incidents, anomalies, and intervention events.
ArrhythmicVault.sol: Provides the vault infrastructure used in the emergency-response and fund-rescue architecture.
These contracts establish the on-chain foundation for security enforcement, response coordination, and auditability.
The CRE workflow is organized into specialized modules:
exploitDetector.js: Identifies suspicious blockchain activity and potential exploit indicators.
aiAnalyzer.js: Coordinates AI-powered investigation and threat analysis.
portfolioScanner.js: Examines DAO portfolios and associated protocol exposure.
responseExecutor.js: Coordinates the appropriate emergency-response operations.
index.ts: Connects the individual components into the overall CRE workflow.
Chainlink CRE provides the infrastructure for orchestrating off-chain computation and interacting with on-chain smart contracts.
Rather than making every security-analysis operation dependent on third-party AI APIs, the architecture supports local model execution for analyzing suspicious transactions, security telemetry, and potential exploit scenarios.
This approach offers greater control over inference, data handling, and model selection while allowing the intelligence layer to operate alongside the blockchain infrastructure.
Wagmi, Viem, and RainbowKit provide the Web3 integration layer for wallet connectivity and smart contract interactions.
The dashboard brings together protocol monitoring, security intelligence, detected threats, and emergency-response activity in a unified interface.
What Makes the Architecture Interesting
The most interesting engineering challenge is connecting autonomous off-chain intelligence with on-chain emergency execution.
AI analysis cannot directly enforce blockchain security. It must operate within a carefully designed execution architecture where smart contracts remain responsible for enforcing permissions and validating critical operations.
Heartbeat separates detection, diagnosis, investigation, and execution into distinct components. This modular approach makes it possible to evolve the AI models and detection mechanisms without having to redesign the entire on-chain infrastructure.
The result is an integrated security architecture combining AI-driven intelligence, decentralized workflow orchestration, and smart contract-based emergency response.

