Book a free call

How to Add AI Threat Monitoring to a Web3 App

AI threat monitoring watches your Web3 app's on-chain activity and flags attacks in progress. Learn the signals, the scoring, and how to build the pipeline.

Hertiv engineering teamReviewed by a senior engineer
7 min read
How to Add AI Threat Monitoring to a Web3 App
On this page

Short answer

AI-based threat monitoring in a Web3 app watches on-chain activity, contract events and wallet behaviour in real time, and uses machine learning to flag the patterns that look like an attack. You build it by indexing the data your app produces, scoring each event against a baseline of normal behaviour, and wiring high scores to alerts and automated responses such as pausing a contract.

What is AI-based threat monitoring in a Web3 app?

AI-based threat monitoring in a Web3 app is a system that watches on-chain activity, contract events and user behaviour in real time, and uses machine learning to flag the patterns that look like an attack. Instead of relying only on fixed rules, it learns what normal activity looks like for your app and raises an alert when something moves away from that baseline.

A Web3 app is exposed in ways a normal web app is not. Transactions are public, anyone can call a contract, and a bad transaction is final once it is confirmed. That means the time between spotting an attack and stopping it is measured in blocks, not hours. Monitoring has to run continuously and react fast, because there is no undo button after funds move.

The AI part is usually a mix of anomaly detection and scoring. The system builds a picture of normal behaviour — typical transaction sizes, common callers, usual gas prices, normal withdrawal patterns — and scores each new event against it. Events with high scores go to a human or trigger an automated response, such as pausing a contract or blocking a wallet.

What should the monitor watch?

A monitor is only useful if it watches the right signals. The table below lists the signals that matter most for a Web3 app, and what each one can reveal.

SignalWhat to watchWhat it can reveal
Mempool transactionsPending calls, gas spikes, repeated attemptsAn attack being prepared before it lands
Contract eventsLarge withdrawals, admin calls, ownership changesUnusual fund movement or a takeover
Wallet behaviourNew wallets, repeated small transfers, mixer useTesting, laundering or sybil activity
Price and oracle feedsSudden price moves, stale or missing feedsManipulation or a feed failure
Governance and admin actionsProposal votes, key changes, timelock callsA governance or admin takeover attempt

Start with the signals that map to money leaving your app. Large withdrawals, admin calls and price moves are the events that cause the biggest losses, so they deserve the fastest alerts. Lower-risk signals, such as new wallet registrations, can feed a daily summary instead of waking anyone up.

How does the AI part actually work?

The AI part works in three stages: learn what normal looks like, score new activity against that picture, and improve the picture as the app changes. None of the three needs a large research team, but each needs clean data.

First, the system builds a baseline from past activity. It records typical transaction volumes, the wallets that interact most often, the functions that get called and the times of day when activity peaks. A baseline built from a few weeks of real traffic is far more useful than one built from guesses.

Then each new event gets a risk score, as in cybersecurity threat detection. A large withdrawal from a new wallet at an unusual hour scores higher than a routine deposit from a known user. Scores combine several signals at once, so a single odd value does not trigger an alert on its own. Teams set thresholds for each score band, and only the top band pages someone.

Finally, the model is retrained on a schedule, because normal behaviour changes. A new feature, a marketing campaign or a market rally all shift the baseline. If the model is not updated, it starts flagging normal growth as suspicious, and the team stops trusting it.

Which tools do teams use?

Most teams combine a monitoring network, an alerting service and their own rules, rather than building everything from scratch. The table below shows the common options and what each one covers.

ToolWhat it coversBest for
FortaDetection bots and an alert networkWatching common attack patterns fast
TenderlyAlerts, simulations and transaction monitoringChecking a transaction before it runs
OpenZeppelin DefenderAutomated actions, pausing and admin controlsResponding without a person in the loop
HypernativeRisk scoring and attack preventionFlagging risky transactions early
Custom pipelineOwn indexers, models and dashboardsApps with unusual logic to watch

Forta is the usual starting point, because its network of detection bots already watches common attack patterns and can send alerts to a webhook or chat channel. Tenderly and Defender add the response side: simulating a transaction before it runs, or pausing a contract when an alert fires, which is where a smart contract audit also helps. Hypernative focuses on scoring and prevention, flagging risky transactions before they are confirmed.

A custom pipeline makes sense when the app has unusual logic that off-the-shelf bots do not understand. It costs more to build and maintain, so most teams start with a managed service and add custom rules on top, rather than building a whole platform on day one.

How do you build the monitoring pipeline?

A monitoring pipeline has five parts: collect the data, score it, alert on it, respond to it, and review what happened. Build them in that order, and keep each part simple enough to test on its own.

  1. Index the data you need. Stream contract events, mempool transactions and price feeds into one store.
  2. Define the baseline. Record normal volumes, callers and patterns for at least two weeks.
  3. Add detection rules. Start with fixed rules for known attacks, then add anomaly scoring.
  4. Wire alerts to people. Route high-severity alerts to a phone or pager, lower ones to a chat channel.
  5. Connect automated responses. Add pause functions, blocklists or withdrawal limits that trigger on the highest scores.
  6. Review and retrain. Check false alarms weekly and update the baseline monthly.

Test the pipeline with a rehearsal before you rely on it. Send a test transaction that mimics a known attack pattern and check that the alert arrives, the right person sees it and the response runs. A monitor that has never been tested is a guess, not a control.

How do you handle alerts without drowning in them?

Alert fatigue is the most common reason monitoring fails. If the team gets dozens of alerts a day, the real one gets ignored along with the noise. The fix is to sort alerts by severity and to make each one actionable.

Use three severity levels. Critical alerts mean money may be leaving the app now, and they page a person at any hour. High alerts mean something unusual is happening and need a check within the working day. Low alerts are patterns worth watching and go into a daily digest that nobody has to read at 3 a.m.

Every alert should say what happened, why it scored high and what to do next. An alert that only says 'anomaly detected' forces the responder to start from zero, which wastes the minutes that matter. Link each alert to the transaction, the contract and the runbook step that applies, as smart contracts in Web3 security explains.

Review the false alarms every week. If a rule fires ten times and nine are harmless, change the rule or raise its threshold. A monitor that cries wolf teaches the team to ignore it, and the one alert that matters will be the one they skip.

Example (hypothetical): a lending app catches a drain attempt

Example (hypothetical): a small lending app holds deposits worth 2,000,000 in its main contract. Its monitor watches withdrawals, price feed updates and new borrower wallets, and scores each event.

At 2 a.m. a new wallet borrows 400,000 against collateral, then a second wallet borrows 350,000 within the same block. The price feed for the collateral token drops by a fifth in the same minute. Each event alone is unusual; together they push the risk score into the critical band.

The monitor pages the on-call engineer and triggers a pause on new borrows. The engineer checks the transactions, confirms the price move came from a thin market rather than a real sale, and keeps the pause on for two hours while the feed is checked. The arithmetic adds up: the two borrows total 750,000, which is more than a third of the 2,000,000 in the contract, so stopping new borrows protected the remaining 1,250,000.

Without the monitor, the pattern would have been found in the morning, after more wallets had copied it. The pause cost the app two hours of new borrows and no deposits, because withdrawals were never blocked.

What are the common mistakes?

The most common threat-monitoring mistakes are watching the wrong signals, trusting scores blindly, and having alerts with no response attached.

  • Monitoring only the chain and ignoring the front end. Phishing pages and fake interfaces drain wallets without touching your contract.
  • Treating every high score as an attack. Scores are a ranking, not a verdict, and a human should confirm before funds are frozen.
  • Alerts with no runbook. An alert that nobody knows how to act on is just noise.
  • Never retraining the model. Baselines go stale, false alarms rise, and the team stops reading alerts.
  • Testing the monitor only once. Attack patterns change, so rehearsals need to happen on a schedule.

Key takeaways

  • AI threat monitoring learns what normal looks like for your app and flags the activity that breaks the pattern
  • Watch the signals that map to money leaving: withdrawals, admin calls, price moves and new wallets
  • Score events and route only the top band to a person; the rest goes to a daily digest
  • Pair alerts with automated responses such as pausing borrows, so minutes matter instead of hours
  • Retrain the baseline monthly and rehearse the alert loop, or false alarms will teach the team to ignore it

Frequently asked questions

What is AI-based threat monitoring in Web3?

It is a system that watches on-chain activity, contract events and user behaviour, and uses machine learning to spot patterns that look like an attack. It learns what normal activity looks like for your app and raises an alert when new activity moves away from that baseline.

How is it different from a normal security audit?

An audit checks the code once before launch, while monitoring watches live activity after launch. Audits find bugs in the contract; monitoring finds attacks in progress, such as price manipulation or unusual withdrawals, and gives the team time to respond.

Which Web3 apps need AI threat monitoring most?

Apps that hold user funds need it most: lending protocols, exchanges, bridges and staking services. Any app where a single bad transaction can move a large sum should monitor live activity, not just rely on an audit.

What does AI threat monitoring cost?

Costs vary by vendor and by how many contracts and chains you monitor, so check the vendor site for current pricing. A custom pipeline costs engineering time to build and maintain, which is why most teams start with a managed service and add custom rules only where the app has unusual logic.

Can AI monitoring stop an attack on its own?

It can trigger automated responses such as pausing a contract or blocking a wallet, but a human should confirm the decision for anything that freezes user funds. The monitor buys minutes; the team still decides what happens next.

How do you avoid alert fatigue?

Sort alerts into three severity levels, send only critical alerts to a phone, and put the rest in a daily digest. Review false alarms weekly and adjust thresholds, so the team trusts the alerts that do arrive.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a Web3 app that needs live threat monitoring? Talk to Hertiv.

A senior engineer replies within one business day. Or see our AI Security service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call