◈   ⋇ analysis · Intermediate

Dune SQL Crypto Examples for On-Chain Analysis

Learn how to use Dune Analytics SQL to analyze on-chain crypto data, track wallets, and find trading edges with real query examples.

Uncle Solieditor · voc · 06.05.2026 ·views 22
◈   Contents
  1. → What Is Dune Analytics and Why Should Traders Care
  2. → Getting Started: The Dune SQL Basics You Actually Need
  3. → Real Dune SQL Examples You Can Use Right Now
  4. → Building a Whale Wallet Tracker from Scratch
  5. → Using Dune SQL to Analyze DeFi Protocol Health
  6. → Turning Dune Queries Into Trading Signals
  7. → Frequently Asked Questions
  8. → Where to Go From Here

Most traders look at price charts. Smart traders look at what's actually happening on-chain — and Dune Analytics gives you the raw SQL power to do exactly that. Dune lets you query blockchain data like a database: wallets, transactions, DEX swaps, token flows, everything. If you've ever wondered where the big money is moving before price reacts, this is your answer.

What Is Dune Analytics and Why Should Traders Care

Dune Analytics is a blockchain data platform that indexes on-chain data from Ethereum, Solana, Polygon, Base, Arbitrum, and more — then lets you query it using SQL (specifically a dialect called DuneSQL, which is based on Trino). Think of it as a giant spreadsheet of everything that's ever happened on these blockchains, and you get to run your own queries against it.

For traders, this is massive. You can answer questions that no price chart will ever tell you: How many wallets are holding a token for the first time? Are whales accumulating or distributing? Is liquidity growing or shrinking on a particular DEX pool? These signals often appear on-chain hours or days before they show up in price on Binance or Bybit.

Key Takeaway: On-chain data is the blockchain's financial statement. Traders who read it have information that the majority of retail traders simply don't have access to.

Getting Started: The Dune SQL Basics You Actually Need

DuneSQL is SQL with some blockchain-specific flavor. If you've used SQL before, you'll feel at home within minutes. If you haven't, don't worry — the queries you need for trading analysis are actually pretty simple. The hardest part is knowing which tables to use.

Dune organizes its data into schemas. The most important ones for crypto traders are: `ethereum.transactions` for raw ETH transactions, `dex.trades` for aggregated DEX trading activity across protocols, `tokens.transfers` for ERC-20 token movements, and `prices.usd` for historical price data. These four tables alone will cover 80% of what you want to know.

Real Dune SQL Examples You Can Use Right Now

Let's skip the theory and get into actual queries. These examples work in the Dune query editor today — just copy, paste, and modify the contract address or wallet for whatever you're researching.

Example 1: Find the top token holders and their recent activity. This is useful when you're researching a new token and want to know if the distribution looks healthy or if a few wallets control everything.

-- Top 20 holders of a token and their last transfer date
SELECT
    "to" AS wallet,
    SUM(value / 1e18) AS total_received,
    MAX(block_time) AS last_active
FROM tokens.transfers
WHERE contract_address = 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984  -- UNI token
    AND block_time >= NOW() - INTERVAL '90' DAY
GROUP BY 1
ORDER BY total_received DESC
LIMIT 20

Example 2: Track DEX volume for a specific token pair over time. This shows you whether trading activity is growing, which often precedes price moves that you'd eventually see listed on Coinbase or OKX.

-- Daily DEX volume for a token
SELECT
    DATE_TRUNC('day', block_time) AS day,
    COUNT(*) AS trade_count,
    SUM(amount_usd) AS volume_usd
FROM dex.trades
WHERE (token_bought_address = 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984
    OR token_sold_address = 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984)
    AND block_time >= NOW() - INTERVAL '30' DAY
GROUP BY 1
ORDER BY 1 ASC

Example 3: Identify whale accumulation by finding wallets that have been buying consistently without selling. This pattern often appears during accumulation phases before a major pump.

-- Wallets buying a token repeatedly (potential accumulators)
SELECT
    taker AS wallet,
    COUNT(*) AS buy_count,
    SUM(amount_usd) AS total_bought_usd,
    MIN(block_time) AS first_buy,
    MAX(block_time) AS last_buy
FROM dex.trades
WHERE token_bought_address = 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984
    AND block_time >= NOW() - INTERVAL '14' DAY
    AND amount_usd > 10000  -- only meaningful trades
GROUP BY 1
HAVING COUNT(*) >= 3  -- bought at least 3 times
ORDER BY total_bought_usd DESC
LIMIT 50
Key Takeaway: Replace the contract address `0x1f9840...` in any query with the token you're researching. You can find contract addresses on Etherscan or CoinGecko.

Building a Whale Wallet Tracker from Scratch

One of the highest-value things you can do with Dune SQL is track specific whale wallets. The idea is simple: find wallets that consistently make profitable trades, then watch what they're buying before the crowd figures it out. Traders who do this on Binance spot markets and catch a move early can ride it all the way up.

The process has three steps: find profitable wallets, monitor their recent buys, and set up alerts when they make a move. Here's a query that scores wallets by their realized PnL on DEX trades — a useful starting point for identifying skilled traders.

-- Find wallets with high win-rate on token trades in the last 30 days
WITH buys AS (
    SELECT
        taker AS wallet,
        token_bought_address AS token,
        SUM(amount_usd) AS spent_usd,
        MIN(block_time) AS first_buy
    FROM dex.trades
    WHERE block_time >= NOW() - INTERVAL '30' DAY
        AND amount_usd BETWEEN 5000 AND 500000
    GROUP BY 1, 2
),
sells AS (
    SELECT
        taker AS wallet,
        token_sold_address AS token,
        SUM(amount_usd) AS received_usd
    FROM dex.trades
    WHERE block_time >= NOW() - INTERVAL '30' DAY
        AND amount_usd BETWEEN 5000 AND 500000
    GROUP BY 1, 2
)
SELECT
    b.wallet,
    COUNT(DISTINCT b.token) AS tokens_traded,
    SUM(COALESCE(s.received_usd, 0) - b.spent_usd) AS net_pnl_usd
FROM buys b
LEFT JOIN sells s ON b.wallet = s.wallet AND b.token = s.token
GROUP BY 1
HAVING SUM(COALESCE(s.received_usd, 0) - b.spent_usd) > 50000
ORDER BY net_pnl_usd DESC
LIMIT 30

Once you have a list of consistently profitable wallets, add them to a watchlist. Platforms like VoiceOfChain can complement this by alerting you to price momentum signals in real time — so you're watching both on-chain wallet activity and live market movement simultaneously. When a whale you're tracking starts buying and VoiceOfChain shows a bullish signal on the same token, that's a high-conviction setup.

Using Dune SQL to Analyze DeFi Protocol Health

Beyond whale tracking, Dune SQL is invaluable for evaluating DeFi protocols before you commit capital. Is TVL actually growing, or is one whale inflating the numbers? Are users returning or churning? Is the protocol generating real revenue? These questions matter whether you're yield farming or trading the protocol's governance token on platforms like Gate.io or KuCoin.

Here's a query pattern for checking unique active users on a protocol — a far more honest health metric than TVL alone:

-- Weekly unique users interacting with a protocol contract
SELECT
    DATE_TRUNC('week', block_time) AS week,
    COUNT(DISTINCT "from") AS unique_users,
    COUNT(*) AS total_transactions
FROM ethereum.transactions
WHERE "to" = 0x7a250d5630b4cf539739df2c5dacb4c659f2488d  -- Uniswap V2 Router
    AND success = TRUE
    AND block_time >= NOW() - INTERVAL '180' DAY
GROUP BY 1
ORDER BY 1 ASC
Dune SQL Use Cases for Traders
Use CaseWhat to QueryTrading Insight
Whale trackingdex.trades by walletFront-run large accumulation
Token distributiontokens.transfersSpot unhealthy concentration
DEX volume trendsdex.trades by tokenIdentify rising interest early
Protocol healthethereum.transactionsEvaluate DeFi before aping in
New wallet growthtokens.transfers unique sendersGauge new user adoption

Turning Dune Queries Into Trading Signals

Running queries manually is useful, but the real power comes from scheduling them and building alerts. Dune lets you schedule queries to run automatically and has an API you can connect to your own systems. A common workflow is: run a query every hour, check if whale accumulation crossed a threshold, send an alert to Telegram.

Here's how this plays out practically. Say you're monitoring a mid-cap token listed on both Bybit and OKX. You have a Dune query that tracks net token flow for wallets holding over $100k. When that number turns sharply positive — whales buying significantly more than they're selling — you get an alert. You check VoiceOfChain to see if there's a corresponding price signal forming. If both align, you have a data-driven entry rather than a gut-feel trade.

Key Takeaway: On-chain data alone isn't enough — combine it with price action signals. On-chain tells you WHAT is happening; price action tells you WHEN the market is reacting.

Frequently Asked Questions

Do I need to know SQL to use Dune Analytics?
Basic SQL knowledge helps a lot, but Dune has a library of thousands of community dashboards you can fork and modify without writing a query from scratch. If you know how to change a wallet address in a WHERE clause, you can get started immediately. Most useful trading queries are just a few lines long.
Is Dune Analytics free to use?
Yes, Dune has a free tier that gives you access to query execution and community dashboards. The paid plans unlock faster query execution, private dashboards, and higher API limits. For most individual traders, the free tier is more than enough to start.
How do I find the contract address for a token to use in my query?
Look up the token on Etherscan, CoinGecko, or CoinMarketCap — they all display the official contract address. Always double-check the address before using it, because there are many fake tokens with similar names. The contract address is unique and never changes.
How real-time is the data on Dune Analytics?
Dune data typically lags 1-5 minutes behind the actual blockchain. For most trading analysis — especially anything beyond scalping — this is more than adequate. If you need millisecond-level data, you'd need a direct node connection, but that's overkill for the use cases most traders have.
Can I track wallets on chains other than Ethereum with Dune?
Yes. Dune supports multiple chains including Polygon, Arbitrum, Optimism, Base, Solana, BNB Chain, and others. The table names follow the same pattern — for example, `bnb.transactions` instead of `ethereum.transactions`. Most DEX and token transfer tables are cross-chain and use a `blockchain` column to filter.
What's the difference between Dune SQL and regular SQL?
DuneSQL is built on Trino (formerly PrestoSQL), so the syntax is close to standard SQL with a few differences. The main one is that DuneSQL uses `INTERVAL '30' DAY` syntax and handles hex addresses natively. If you know MySQL or PostgreSQL, you'll adapt quickly — maybe 30 minutes to get comfortable.

Where to Go From Here

Dune SQL is one of those tools that compounds in value the more you use it. Start with the examples in this article — swap in the token or wallet you care about, run the query, and see what you find. Over time you'll build a library of queries that gives you a real information edge over traders who only look at candlestick charts.

The best traders combine multiple data layers: on-chain analytics from Dune, real-time price signals from platforms like VoiceOfChain, and order book depth from exchanges like Binance and Bybit. No single layer tells the full story. On-chain data shows the smart money's hand. Price signals show when the market is finally catching up. That combination — data-driven patience followed by decisive execution — is what separates consistent traders from the crowd.

Key Takeaway: Fork existing Dune dashboards before building your own. The community has already solved most common on-chain analysis problems — start there and customize to your needs.
◈   more on this topic
⌘ api Kraken API Documentation for Crypto Traders: Essentials and Examples ◉ basics Mastering the ccxt library documentation for crypto traders