Back to How-To Guides
HOW-TO12 min read2025-06-23

How to Set Up Blockchain Monitoring — Tenderly, Forta, and On-Chain Alerts

Production blockchain systems require real-time monitoring for security anomalies, unusual transaction patterns, and circuit breaker events. Here is the complete monitoring stack.

ClickMasters Team
Step-by-step implementation
Expert Assistance

Ready to Set Up Blockchain Monitoring?

Get expert guidance on setting up production-grade blockchain monitoring.

Complete Guide

Quick Answer

Blockchain monitoring requires 3 layers: Tenderly Alerts (transaction-level — webhook alerts for large withdrawals, $99/month), The Graph (historical query monitoring — detect anomalies like large withdrawals and rapid repayments, $0–$49/month), and On-Chain Circuit Breakers (automated pause on threshold exceedance). Total monitoring cost: ~$200–$350/month. With Tenderly webhooks, exploits can be detected in 1-3 minutes; with automated circuit breakers, in milliseconds.

Layer 1: Tenderly Alerts (Transaction-Level Monitoring)

Tenderly provides real-time transaction simulation, alerting, and debugging for EVM contracts.

Example
// Tenderly webhook alert configuration
const tenderlyAlert = {
    name: "Large Withdrawal Alert",
    conditions: [
        {
            contract_address: "0x...",   // Your protocol contract
            method: "withdraw",
            // Alert when withdrawal > $100,000 equivalent
            parameters: { amount: { gt: "100000000000" } } // USDC 6 decimals
        }
    ],
    targets: [
        { type: "webhook", url: "https://yourapp.com/webhooks/tenderly" }
    ],
    deliveryChannels: ["email", "slack", "pagerduty"]
};

// Webhook handler for Tenderly alerts
app.post('/webhooks/tenderly', async (req, res) => {
    const alert = req.body;
    
    console.log(`Alert: ${alert.name}`);
    console.log(`Transaction: ${alert.transaction.hash}`);
    console.log(`Block: ${alert.transaction.block_number}`);
    
    // High-value withdrawal: notify on-call team immediately
    if (alert.name === "Large Withdrawal Alert") {
        await pagerduty.trigger({
            title: `Large withdrawal detected: ${alert.transaction.hash}`,
            severity: 'warning'
        });
    }
    
    res.status(200).send('OK');
});

Layer 2: The Graph (Historical Query Monitoring)

Example
// GraphQL query for suspicious activity monitoring
const SUSPICIOUS_ACTIVITY_QUERY = `
  query CheckAnomalies($threshold: BigInt!, $timeWindow: Int!) {
    largeWithdrawals: withdrawals(
      where: { 
        amount_gt: $threshold,
        timestamp_gt: $timeWindow
      }
      orderBy: amount
      orderDirection: desc
    ) {
      id
      user
      amount
      timestamp
      transaction
    }
    
    rapidRepayments: repayments(
      where: { timestamp_gt: $timeWindow }
      orderBy: timestamp
    ) {
      id
      user
      amount
    }
  }
`;

// Run hourly anomaly detection
async function detectAnomalies() {
    const oneHourAgo = Math.floor(Date.now() / 1000) - 3600;
    const HIGH_VALUE_THRESHOLD = "1000000000000"; // $1M in USDC
    
    const { data } = await apolloClient.query({
        query: SUSPICIOUS_ACTIVITY_QUERY,
        variables: { threshold: HIGH_VALUE_THRESHOLD, timeWindow: oneHourAgo }
    });
    
    if (data.largeWithdrawals.length > 0) {
        await alertSecurityTeam(data.largeWithdrawals);
    }
}

Layer 3: Custom Circuit Breaker

Example
// On-chain circuit breaker that pauses the protocol
contract CircuitBreaker is Ownable {
    uint256 public maxWithdrawalPerHour;
    uint256 public withdrawalThisHour;
    uint256 public hourStart;
    
    event CircuitBreakerTripped(uint256 amount, uint256 limit);
    
    function checkWithdrawalLimit(uint256 amount) internal {
        if (block.timestamp >= hourStart + 1 hours) {
            hourStart = block.timestamp;
            withdrawalThisHour = 0;
        }
        
        withdrawalThisHour += amount;
        
        if (withdrawalThisHour > maxWithdrawalPerHour) {
            emit CircuitBreakerTripped(withdrawalThisHour, maxWithdrawalPerHour);
            // Trigger automatic pause
            _pause(); // Assumes Pausable mixin
        }
    }
}

Monitoring Stack Costs

ToolCostWhat It Covers
Tenderly (Team plan)$99/monthTransaction alerts, simulation, debugging
Forta (self-hosted)Free (pay per detection agent)Automated threat detection
The Graph (hosted)$0–$49/monthHistorical query anomaly detection
PagerDuty$21/user/monthOn-call rotation for security alerts
Uptime monitoring$20–$50/monthRPC endpoint, front-end availability
Total monthly~$200–$350Full monitoring stack

Frequently Asked Questions

Common questions before following this guide

Clear answers to the most common practical, technical, and implementation questions.

1

Answers

How quickly can an exploit be detected with proper monitoring?

With Tenderly webhook alerts: typically 1–3 minutes from the first suspicious transaction (webhook latency + manual review). With automated circuit breakers: milliseconds (the protocol pauses itself before the next block). The difference: automated circuit breakers are faster but require defining the anomaly threshold correctly in advance; Tenderly alerts require human decision-making but can catch more novel patterns.

Expert Assistance

Ready to Set Up Blockchain Monitoring?

Get expert guidance on setting up production-grade blockchain monitoring.