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.
// 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)
// 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
// 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
| Tool | Cost | What It Covers |
|---|---|---|
| Tenderly (Team plan) | $99/month | Transaction alerts, simulation, debugging |
| Forta (self-hosted) | Free (pay per detection agent) | Automated threat detection |
| The Graph (hosted) | $0–$49/month | Historical query anomaly detection |
| PagerDuty | $21/user/month | On-call rotation for security alerts |
| Uptime monitoring | $20–$50/month | RPC endpoint, front-end availability |
| Total monthly | ~$200–$350 | Full monitoring stack |