Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Guides

Setting Up On-Chain Analytics and Monitoring for EVM Apps

A technical guide for developers to implement a production-grade monitoring stack for tracking EVM application health, user activity, and key performance metrics.
Chainscore © 2026
introduction
DEVELOPER GUIDE

Setting Up On-Chain Analytics and Monitoring for EVM Apps

Learn how to implement a robust monitoring system for your Ethereum Virtual Machine applications using real-time data and alerting tools.

On-chain monitoring is the practice of programmatically observing and analyzing blockchain data to track application health, user activity, and security events. For EVM-based dApps, this involves listening to smart contract events, tracking wallet interactions, and monitoring gas prices and transaction success rates. Unlike traditional web analytics, on-chain data is public, immutable, and requires specialized tools to parse and interpret. A well-configured monitoring stack is essential for detecting bugs, understanding user behavior, and responding to exploits or unexpected contract interactions in real time.

The foundation of any monitoring system is a reliable data source. You can use a node provider like Alchemy or Infura for basic JSON-RPC calls, but for scalable analytics, dedicated indexing services are superior. The Graph Protocol allows you to create subgraphs that index specific events from your contracts into a queryable API. For more flexible, real-time streaming, consider using Chainscore's Webhooks or Ponder to listen for on-chain events and trigger custom logic. Setting up a listener for a Transfer event from an ERC-20 contract is a common starting point for tracking token flows.

Here is a basic example using ethers.js to listen for events directly from a node, though this method is not scalable for production:

javascript
const provider = new ethers.providers.WebSocketProvider('wss://mainnet.infura.io/ws/v3/YOUR_KEY');
const contract = new ethers.Contract(contractAddress, abi, provider);
contract.on('Transfer', (from, to, value, event) => {
  console.log(`Transfer: ${value} tokens from ${from} to ${to}`);
  // Add your alerting logic here
});

For production, you should offload this event processing to a dedicated backend service to avoid missing blocks or overwhelming your node connection.

After capturing data, you need to define key metrics and set up alerts. Critical metrics for most dApps include: Daily Active Users (DAU), Total Value Locked (TVL), transaction failure rate, and contract function call frequency. Tools like Chainscore Alerts or Tenderly can monitor these metrics and send notifications via Slack, Discord, or email when thresholds are breached. For instance, you can configure an alert to trigger if the withdraw function of your vault contract is called more than 10 times in an hour, which could indicate abnormal activity or an attack.

Finally, visualize your data to gain operational insights. You can build custom dashboards using data from your indexed subgraph or monitoring service with tools like Dune Analytics, Flipside Crypto, or Grafana. These dashboards help you track growth trends, identify bottlenecks, and report on protocol performance. Combining real-time alerting with historical analytics creates a full-spectrum monitoring solution that allows developers to maintain, debug, and improve their EVM applications proactively, ensuring reliability and security for users.

prerequisites
FOUNDATION

Prerequisites and Tech Stack

The essential tools and knowledge required to build effective on-chain analytics and monitoring systems for EVM applications.

Before implementing analytics, you need a solid foundation in the Ethereum Virtual Machine (EVM) ecosystem. This includes a working understanding of core concepts like smart contracts, transactions, events, and logs. You should be comfortable with a primary development language such as JavaScript/TypeScript (using ethers.js or viem) or Python (using web3.py). Familiarity with JSON-RPC calls and the structure of transaction receipts is crucial, as this data forms the raw material for all subsequent analysis.

Your tech stack begins with reliable access to blockchain data. For development and testing, you can use a local node like Hardhat or Foundry. For production-grade analytics, you will need a connection to an EVM-compatible node provider. Services like Alchemy, Infura, QuickNode, or running your own Erigon or Geth archive node provide the necessary JSON-RPC endpoints. An archive node is often required to query historical state, which is essential for comprehensive analytics beyond the most recent blocks.

For processing and storing the extracted data, you will need a database. PostgreSQL and TimescaleDB (its time-series extension) are popular choices for their reliability and performance with sequential data. To interact with the node and populate your database, you'll use an indexing framework. While you can build a custom indexer from scratch using the libraries mentioned, using a dedicated tool like The Graph (for subgraphs) or Covalent can significantly accelerate development by handling the complex logic of chain reorganization and data normalization.

Finally, consider the tools for analysis and visualization. For ad-hoc querying and business intelligence, SQL proficiency is non-negotiable. To build dashboards and alerts, you can integrate with platforms like Grafana (for visualization), Datadog (for application monitoring), or PagerDuty (for incident response). The complete stack forms a pipeline: Node Provider -> Indexing Layer -> Database -> Analysis/Visualization Tool. Setting this up correctly from the start prevents data gaps and ensures your monitoring is both real-time and historically accurate.

key-concepts-text
DEVELOPER GUIDE

Setting Up On-Chain Analytics and Monitoring for EVM Apps

A practical guide to implementing robust data pipelines and real-time monitoring for Ethereum and EVM-compatible applications.

On-chain analytics and monitoring are essential for understanding user behavior, ensuring protocol health, and making data-driven decisions. For EVM applications, this involves programmatically querying blockchain data to track key metrics like transaction volume, unique active wallets (UAW), gas consumption, and smart contract interactions. Unlike traditional web analytics, on-chain data is public, verifiable, and requires tools designed for blockchain's event-driven and stateful architecture. Setting up a basic system involves three core components: a data indexer, a storage/processing layer, and a visualization dashboard.

The first step is establishing a reliable data ingestion pipeline. While you can run your own archive node and parse logs directly, using a specialized indexer is more efficient for production apps. Services like The Graph (for historical data via subgraphs) or Chainscore (for real-time event streaming and alerts) abstract away node management. For example, to monitor a Uniswap V3 pool, you would create a subgraph that indexes Swap, Mint, and Burn events, calculating derived metrics like daily volume and liquidity changes. For real-time monitoring, you can set up a Chainscore webhook to listen for specific event signatures and receive instant alerts.

Once data is indexed, you need to store, process, and analyze it. For time-series data like daily active users or TVL, a database like TimescaleDB (PostgreSQL extension) or ClickHouse is optimal. A simple processing script might aggregate raw swap events into hourly summaries. Here's a conceptual snippet for calculating hourly volume from an indexed dataset:

sql
-- Example aggregation query
SELECT 
    date_trunc('hour', block_timestamp) as hour,
    SUM(amount_usd) as hourly_volume
FROM swap_events
WHERE pool_address = '0x...'
GROUP BY 1
ORDER BY hour DESC;

This processed data then feeds into dashboards using tools like Grafana or Metabase.

Monitoring for anomalies and security is critical. Beyond tracking KPIs, you should set up alerts for unexpected contract activity. This includes monitoring for large, unusual withdrawals, function call failures, gas price spikes, or deviations from normal interaction patterns. Using an RPC provider like Alchemy or QuickNode, you can leverage their enhanced APIs to set up alerting on specific conditions. For instance, you can create a cron job that checks the contract's balance or the emission of specific error events (Error(string)) and triggers a notification via Slack or PagerDuty. This proactive monitoring can help detect exploits or bugs early.

Finally, consider the architecture's scalability and cost. Processing every block for multiple contracts can become expensive. Optimize by filtering for only the relevant contract addresses and event signatures at the indexer level. For historical analysis, batch processing is cost-effective, while real-time alerts require streaming pipelines. The best setup often combines both: a subgraph for rich historical queries and a real-time alerting system for operational monitoring. By implementing these components, developers gain a comprehensive view of their application's on-chain footprint, enabling better product decisions, improved security, and enhanced user transparency.

monitoring-tools-overview
EVM APP DEVELOPMENT

Essential Monitoring Tools and Platforms

A guide to the core tools and platforms for monitoring smart contract health, user activity, and security on EVM-compatible chains.

ON-CHAIN ANALYTICS

Monitoring Tool Comparison: Features and Use Cases

A comparison of popular tools for monitoring EVM smart contracts, transactions, and network health.

Feature / MetricChainscoreTenderlyAlchemyBlocknative

Real-time Transaction Monitoring

Smart Contract Error Tracking

Custom Alert Logic (Webhooks)

Gas Price & Optimization Insights

Advanced

Basic

Basic

Advanced

MEV Protection Monitoring

Free Tier API Calls/Month

1,000,000

500

300,000,000

10,000

Time to First Alert

< 2 sec

< 1 sec

3-5 sec

< 1 sec

Supported Chains (EVM)

20+

30+

15+

10+

step-1-indexing-with-subgraph
FOUNDATION

Step 1: Indexing Data with a Subgraph

A subgraph is the core data layer for on-chain analytics, transforming raw blockchain data into a queryable GraphQL API. This step is essential for building dashboards, tracking protocol metrics, and powering application features.

A subgraph defines how to index data from a specific set of smart contracts on an EVM-compatible chain like Ethereum, Polygon, or Arbitrum. It consists of three core components: a manifest (subgraph.yaml) that maps data sources, a GraphQL schema (schema.graphql) that defines the shape of your indexed data, and mapping scripts (written in AssemblyScript) that translate blockchain events into entities in your schema. The Graph Node indexing service processes blocks, executes your mappings, and stores the resulting entities in a PostgreSQL database, making them accessible via a GraphQL endpoint.

To start, you define your data model in the GraphQL schema. For example, to track a DEX, you might create entities like Pool, Swap, and LiquidityProvider. Each entity has typed fields, such as id: ID!, token0: Bytes!, and totalValueLockedUSD: BigDecimal!. The @entity directive marks a type for storage, and relationships are defined via field types (e.g., pool: Pool!). This schema dictates the structure of your final API and the tables in the underlying database.

The subgraph manifest connects your schema to the blockchain. In subgraph.yaml, you specify the network (e.g., mainnet), the smart contract addresses to index, and the ABIs for those contracts. For each data source, you list the specific events and functions to watch, linking each to a handler function in your mapping. A typical entry includes the contract address, start block (to begin indexing from), and the events to process, such as Swap(address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to).

Mapping scripts, written in a subset of TypeScript called AssemblyScript, contain the logic for transforming event data into entities. When the Graph Node detects a Swap event, it calls the corresponding handleSwap function. Inside this function, you load relevant entities (like the Pool), update their fields (e.g., increment trade volume), create new entities (like a Swap record), and save everything back to the store using entity.save(). This is where raw transaction data becomes structured, queryable business logic.

After defining your subgraph, you deploy it using the Graph CLI. The command graph deploy --node <node-url> --ipfs <ipfs-url> <subgraph-name> compiles your mappings, uploads the files to IPFS, and registers the subgraph with a Graph Node. The node then begins syncing, scanning blocks from the defined start block, applying your mappings, and indexing the data. You can query the live API at https://api.thegraph.com/subgraphs/name/your-name/your-subgraph using GraphQL to fetch real-time, aggregated on-chain data for your application.

step-2-building-dashboards
IMPLEMENTATION

Step 2: Building Analytics Dashboards

Learn how to transform raw blockchain data into actionable insights by building custom analytics dashboards for your EVM application.

An analytics dashboard is the central interface for monitoring your application's on-chain health and user behavior. It visualizes key performance indicators (KPIs) derived from the data indexed in Step 1. For EVM apps, essential dashboard components include: - User Activity: Daily active wallets, transaction volume, and new user acquisition. - Financial Metrics: Total value locked (TVL), protocol revenue, and fee generation. - Contract Performance: Gas usage patterns, successful vs. failed transaction rates, and popular function calls. Tools like Grafana, Metabase, or custom React/Vue applications with charting libraries (Chart.js, D3) are commonly used to build these interfaces.

To populate your dashboard, you need to query your indexed data. If you're using a subgraph with The Graph, you can query it directly using GraphQL from your frontend or a backend service. For more complex, real-time analytics, consider setting up a dedicated query layer. A common architecture involves a Node.js or Python backend that polls your database or subgraph, performs aggregations (e.g., calculating 24-hour volume), and exposes the results via a REST or WebSocket API. This decouples data processing from the frontend, ensuring dashboards load quickly even with complex queries.

Implement real-time updates to keep dashboards current. For live transaction monitoring, subscribe to new blockchain events using WebSocket connections from providers like Alchemy or Infura. When a new event for your contract is emitted, your backend can process it, update aggregated metrics, and push the new data to connected dashboard clients via Server-Sent Events (SSE) or WebSockets. This allows you to display live feeds of trades, liquidity additions, or governance proposals as they happen on-chain, providing immediate insight into protocol activity.

Effective dashboards also include alerting systems. Configure your backend to monitor specific thresholds, such as a sudden drop in TVL, a spike in failed transactions, or an unexpected contract interaction. When a threshold is breached, trigger notifications via email, Slack, or PagerDuty. For example, you could write a script that checks the balance of your protocol's treasury wallet every hour and alerts if it falls below a minimum operational level. This proactive monitoring is critical for security and operational reliability.

Finally, ensure your dashboard is actionable. Each chart and metric should inform a business or technical decision. A spike in gas costs per transaction might indicate a need to optimize smart contract functions. A decline in new users could trigger a review of onboarding flows. Document the purpose of each KPI for your team. By building a tailored, real-time analytics dashboard, you move from simply collecting data to actively understanding and improving your application's performance and user experience in the EVM ecosystem.

step-3-configuring-alerts
ON-CHAIN MONITORING

Step 3: Configuring Smart Contract Alerts

Learn how to set up real-time alerts for critical on-chain events, from failed transactions to governance proposals, to maintain operational security and user trust.

Smart contract alerts are automated notifications triggered by specific on-chain events or state changes. Unlike traditional server monitoring, these alerts operate on a decentralized data layer, requiring you to define the conditions that matter for your application's health and security. Common alert triggers include failed user transactions, large token transfers, governance proposal submissions, contract ownership changes, or deviations from expected protocol parameters. Setting up a robust alert system transforms reactive incident response into proactive protocol management.

To configure alerts effectively, you must first identify your key risk vectors and operational metrics. For a DeFi lending protocol, critical alerts might monitor for: a collateral factor dropping below a safe threshold, a sudden drop in liquidity pool reserves, or a governance vote to change a core interest rate model. For an NFT project, alerts could track minting activity, royalty fee accrual, or transfers of admin keys. Use tools like Chainscore's Alert Manager or Tenderly to define these conditions without writing custom indexer code.

Here is a basic example of defining an alert for a failed transaction due to slippage on a DEX, using a pseudo-configuration format common to monitoring platforms:

code
alert: "High-Slippage Swap Failure"
type: transaction
network: ethereum-mainnet
condition:
  status: failed
  to_contract: "0x...UniswapV3Router"
  error_message: contains "INSUFFICIENT_OUTPUT_AMOUNT"
  value_greater_than: 1 ETH
action:
  - notify_slack: "#alerts-trading"
  - log_incident: database

This alert would notify your team whenever a user loses over 1 ETH in a failed swap attempt, indicating potential UI issues or market volatility.

For more complex logic, such as detecting a governance attack, you may need to monitor a sequence of events. An alert could watch for: 1) A new proposal created by a previously inactive address, 2) Rapid, scripted voting from a cluster of new delegate addresses, and 3) The proposal passing within an unusually short time frame. Setting up multi-event correlation alerts requires more advanced tooling but is essential for protecting decentralized autonomous organizations (DAOs) from malicious proposals.

Finally, integrate your alerts into your team's workflow. Route critical security alerts (e.g., owner key changes) to high-priority channels like SMS or PagerDuty. Send operational and business intelligence alerts (e.g., volume spikes) to Slack or Discord. Regularly review and tune your alert thresholds to minimize noise and prevent alert fatigue. A well-configured alert system acts as a continuous audit, providing transparency into your application's on-chain activity and enabling swift response to anomalies.

PRACTICAL GUIDES

Implementation Examples by Use Case

Real-Time DeFi Dashboard

Monitor key metrics for a lending protocol like Aave or Compound. This example uses The Graph for indexing and a frontend framework like Next.js for display.

Core Metrics to Track:

  • Total Value Locked (TVL) per market
  • Borrow/Supply APYs and rates
  • Liquidation thresholds and health factors
  • Gas costs for common user interactions

Implementation Steps:

  1. Define subgraph schemas for User, Market, and Transaction entities.
  2. Write mapping handlers in your subgraph to index deposit/borrow/repay events.
  3. Use Apollo Client or a similar library to query the subgraph from your frontend.
  4. Visualize data with charts (using Recharts or D3.js) and display real-time updates via polling or subscriptions.

Key Insight: Indexing historical data with The Graph is more efficient for dashboards than making repeated eth_getLogs RPC calls.

ON-CHAIN ANALYTICS & MONITORING

Troubleshooting Common Issues

Common challenges and solutions for developers implementing analytics and monitoring for EVM-based applications.

Timeouts and inconsistent data from RPC nodes are common when querying large block ranges or complex event logs. This is often due to node provider rate limits, insufficient archive data access, or the inherent latency of public endpoints.

Solutions:

  • Use a dedicated node provider with higher rate limits and archive node support, like Alchemy, Infura Pro, or Chainstack.
  • Implement client-side pagination for historical queries instead of requesting all data at once. Use fromBlock and toBlock parameters incrementally.
  • Cache frequent queries (e.g., token balances for common addresses) to reduce redundant RPC calls.
  • Consider using The Graph for complex historical event indexing, which is purpose-built for this use case.
ON-CHAIN ANALYTICS & MONITORING

Frequently Asked Questions

Common questions and troubleshooting for developers implementing analytics and monitoring for EVM-based applications.

On-chain analytics processes data that is permanently recorded on the blockchain ledger, such as transaction hashes, smart contract events, token transfers, and wallet balances. Tools like The Graph index this data into queryable subgraphs.

Off-chain analytics involves data generated outside the blockchain, like server logs, API response times, user session data from a frontend, or RPC node performance metrics. This requires traditional monitoring tools (e.g., Prometheus, Datadog).

For a complete view, you need both: on-chain data reveals user interactions with your contracts, while off-chain data shows application health and frontend performance.

How to Set Up On-Chain Analytics and Monitoring for EVM Apps | ChainScore Guides