DeFi Intel

Build a Personal On-Chain Alert System Using Dune

Quick answerTo build an on-chain alert system with Dune, create SQL queries for specific on-chain events, set up scheduled executions using Dune's API or third-party services like Pipedream, and route notifications to Telegram or email. Use parameters to customize for whale movements or TVL changes.

Building a personal on-chain alert system using Dune lets you monitor blockchain activity in real time without relying on third-party services. Whether you want to track whale movements, sudden TVL changes, or rare smart contract events, Dune's SQL-based platform makes it possible to create highly customized alerts. In this guide, you’ll learn how to set up queries, schedule them, and deliver notifications—all with concrete examples you can adapt for Ethereum, Polygon, or other supported chains.

By the end, you’ll have a fully functional on-chain alert system Dune that notifies you via Telegram or email whenever conditions you define are met. No coding beyond basic SQL required, and you can start free with Dune's publicly available query engine.

Key takeaways
  • Dune’s SQL gives you unmatched flexibility to define exactly which on-chain events trigger alerts.
  • Combine Dune with external services like Pipedream to deliver Telegram or email notifications on a schedule.
  • Always parameterize your queries to reuse them for different assets, chains, or thresholds.
  • Time windows and aggregation are essential to avoid alert fatigue; alert on changes over a period, not each transaction.
  • Test your queries against historical data to ensure correct logic before going live with alerts.
  • Consider Dune’s paid tier if you need sub-5-minute latency or higher query frequency.

What Is an On-Chain Alert System and Why Build One with Dune?

An on-chain alert system automatically notifies you when specific blockchain events occur—such as a whale transferring a large amount of USDC, a DeFi protocol’s TVL dropping by 20%, or a rare interaction with a newly deployed contract. Dune provides the infrastructure to query raw blockchain data using SQL, store results, and trigger actions. Unlike commercial alert services like Nansen or Etherscan email alerts, Dune gives you full control over the logic, data sources, and notification frequency. You’re not limited to pre-built templates; you can combine on-chain data from multiple protocols, add time filters, and even join across chains.

Dune’s public dashboards and query library mean you don’t start from scratch. You can fork existing queries and tweak them for your alerting needs. The platform also offers an API and webhook integrations, making it possible to automate notifications without writing a server.

Core Concepts: Queries, Parameters, and Notifications

Every alert in Dune starts with a SQL query that returns a result set. You can use Dune’s Spellbook (pre-built abstractions) for standard tables like transfers, mints, or swaps. Key concepts:

Example: A simple whale alert query filters for transfer.amount > 1000000 (in wei) and block_time > now() - interval '30 minutes'. If the result set is non-empty, a webhook triggers a Telegram message.

Setting Up Your Dune Workspace for Alerting

Start by creating a free Dune account at dune.com. Navigate to “Create” > “Query” to open the SQL editor. For alerting, you’ll typically create a query that returns only rows that should trigger a notification. Follow these steps:

Building Your First Whale Movement Alert

Let’s build a real-world whale alert for USDC on Ethereum. The goal: get notified whenever a single transfer of over 1 million USDC occurs.

Query:

SELECT tx_hash, "from", "to", value / 1e6 AS amount_usdc, block_time
FROM ethereum.transfers
WHERE contract_address = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
  AND block_time >= now() - interval '1 hour'
  AND value / 1e6 > 1000000
ORDER BY block_time DESC

Scheduling: In the query editor, click “Schedule” and set it to run every 15 minutes. Check “Notify if results” – but Dune doesn’t have built-in push. Instead, you’ll integrate with a webhook.

Webhook integration with Telegram: Use Pipedream (free) to connect Dune’s API to Telegram. Create a Pipedream workflow that runs on a cron schedule identical to your Dune query. Within the workflow, make an HTTP request to Dune’s API to execute the query and parse results. If results exist, send a Telegram bot message with the details.

Alternatively, use Dune’s own webhook feature (under Settings > Webhooks) – but note that it only triggers when the query itself is updated (not on schedule). For true cron-based alerts, the Pipedream approach is more reliable.

Advanced Alert: Tracking TVL Spikes and Drops

TVL (Total Value Locked) alerts require querying protocol-specific tables or using Dune’s DefiLama integration. For example, to monitor the TVL of a Uniswap v3 pool:

Query for pool TVL change over last 24 hours:

WITH tvl_today AS (
  SELECT SUM(pool_amount_usd) AS tvl_now
  FROM uniswap_v3_ethereum.Pool_day
  WHERE pool_address = '0x8ad599c3a0ff1de082011efddc58f8520a63c0d1'
    AND day = CURRENT_DATE
),
tvl_yesterday AS (
  SELECT SUM(pool_amount_usd) AS tvl_before
  FROM uniswap_v3_ethereum.Pool_day
  WHERE pool_address = '0x8ad599c3a0ff1de082011efddc58f8520a63c0d1'
    AND day = CURRENT_DATE - INTERVAL '1' DAY
)
SELECT 
  tvl_now,
  tvl_before,
  (tvl_now - tvl_before) / NULLIF(tvl_before, 0) * 100 AS pct_change
FROM tvl_today, tvl_yesterday

To make it an alert, schedule it daily and check whether pct_change exceeds a threshold (e.g., -10%). For intraday changes, use hourly aggregates from hourly tables.

Note: Some protocols update TVL every hour; others daily. Check the underlying table refresh frequency on Dune.

Catching Rare On-Chain Events (e.g., Large Liquidations, Contract Interactions)

Rare events often involve unique transaction traces or events. For example, detecting when a whale’s position gets liquidated on Aave:

Query for Aave liquidations:

SELECT evt_tx_hash, evt_block_time, user, liquidator, repayed_amount / 1e18 AS amount_eth
FROM aave_v2_ethereum.LiquidationCall_evt
WHERE evt_block_time >= now() - interval '1 day'
ORDER BY repayed_amount DESC

Set a threshold on repayed_amount to filter only large liquidations (>100 ETH).

Another example: Monitor a specific contract for interactions from a known address. Use ethereum.traces with a filter on from or to address and type = 'CALL'. This is useful for tracking when a foundation wallet moves tokens.

Parameterization: Make your alert reusable by adding parameters for min_amount and lookback_hours. For example:

SELECT ... WHERE value / 1e18 > {{min_amount_eth}} AND evt_block_time >= now() - interval '{{lookback_hours}} hours'

You can then define different parameter sets for different rare events.

Comparison Table: Dune vs. Other Alert Tools

FeatureDune (Free)Dune (Paid)NansenEtherscan AlertsCustom Bot (Tenderly, Alchemy)
Real-timeDelayed (15 min)Near real-time (1-5 min)Near real-timeReal-timeReal-time
Customizable SQLFull SQLFull SQLPre-built queriesNo SQLRequires dev skills
CostFree$$$ per month$$$ per monthFree (limited)Free tier (limited) / Pay-as-you-go
ComplexityMediumMediumLowVery lowHigh
Whale trackingEasy via SQLEasy via SQLEasy (prebuilt)Basic address monitoringFlexible
TVL alertsRequires DefiLama tablesSameIncluded (limited)Not availableManual setup

Dune is the best compromise for those who want full control without building infrastructure from scratch.

Scheduling and Automating with Dune API and Webhooks

To move beyond manual checking, you need automation. Dune provides a REST API (with keys under Account Settings) and webhook endpoints. Steps:

For those without a server, use Pipedream as mentioned. Alternatively, set up a simple Node.js script using Dune’s official API client library and run it on a cron service like Cron-Job.org.

Example: A Pipedream workflow that runs every 10 minutes, calls Dune API to execute a whale alert query, and sends a Telegram message if the result set is non-empty. The entire workflow is free for moderate usage.

Optimizing Alerts to Avoid Notification Fatigue

Too many false positives will make you ignore alerts. Strategies to keep notifications meaningful:

With Dune’s paid tier, you can run queries more frequently and benefit from query caching, reducing the chance of missing events while still avoiding bombardment.

Security and Data Accuracy Considerations

When building an on-chain alert system with Dune, trust the index but verify. Dune indexes data from RPC nodes, and while extremely reliable, there can be brief delays (especially on free tier).

Finally, test your queries historical before enabling alerts. Run a query that covers the past week and verify it catches known events (e.g., a recent large transfer you manually found on Etherscan).

Step-by-step

  1. Create a Dune account and navigate to the Query editor.
  2. Write a SQL query that filters for your event (e.g., token transfers above a threshold) with a time filter.
  3. Save the query and note its Query ID from the URL.
  4. Add parameters for threshold amount and lookback hours to make the query reusable.
  5. Schedule the query: click Schedule and set a frequency (every 15 minutes on free tier).
  6. Generate a Dune API key from your Account Settings (API Keys).
  7. Set up a Pipedream workflow (or similar) that runs on a cron schedule, calls the Dune API to execute the query, and checks if results exist.
  8. If results exist, use a Telegram Bot API call or email service to send a notification with relevant details (tx_hash, amount, addresses).
  9. Test the alert by manually triggering the query and verifying the notification arrives.
  10. Adjust thresholds and time windows to reduce false positives and ensure alerts are actionable.

Common mistakes to avoid

Frequently asked questions

How do I get notified when a whale moves more than 10 ETH?

Write a Dune query on the ethereum.transfers table for the Wrapped ETH contract (0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2) with a filter for value / 1e18 > 10 and a time window of the last 15 minutes. Then set up a Pipedream workflow to execute that query every 15 minutes and send a Telegram notification if results exist.

Can I use Dune alerts for free?

Yes, Dune’s free tier allows you to run queries on a schedule (every 15 minutes) and access the API. You can build a free alert system by combining Dune with Pipedream’s free tier and a Telegram bot. However, free tier has query execution limits, so choose your intervals wisely.

What’s the easiest way to get alerts for TVL changes?

Use Dune’s pre-built DefiLama integration tables (e.g., defillama.ethereum.tvl) and write a query that compares the latest hourly TVL with the previous hour. Set a percent change threshold. Schedule the query daily or hourly and use a webhook to notify you.

How often does Dune update its data?

On the free tier, data is updated approximately every 15 minutes (block-by-block). Paid plans offer near real-time updates (1-5 minute delay). For second-level precision, consider using Alchemy or Tenderly webhooks instead.

Do I need to know programming to set up alerts?

You need basic SQL knowledge for the queries. For the notification layer, some familiarity with JSON and webhook configuration is helpful, but tools like Pipedream have visual interfaces that minimize coding.

Track the entities behind the concepts

DeFi Intel maps 11,000+ protocols, tokens and companies to a typed knowledge graph — with live data, incidents and regulation.

Entities mentioned