Duneanalytics SQL queries
Dune, formerly Dune Analytics, provides DuneSQL for analyzing indexed blockchain data. Choose raw tables for chain records, decoded tables for named contract events and calls or curated tables for standardized activity across supported protocols. The useful comparison is what each row represents and whether the table covers the network, contract and period your question requires.
Running custom queries requires a paid plan or an active trial. Public dashboard viewing remains free.
Raw, Decoded and Curated Tables
| Decision Criterion | Raw Tables | Decoded Tables | Curated Tables |
|---|---|---|---|
| Record Meaning | A transaction, log or execution trace, depending on the table. | A contract event or function call with parsed fields. | A modeled activity record, such as a DEX pool trade segment. |
| Analysis Work | Use chain-level fields and interpret encoded contract data when needed. | Filter named contract fields without manually parsing the underlying bytes. | Aggregate consistent fields across the protocols and chains the dataset includes. |
| Material Limit | The selected table’s network, history and record type. | The decoded contracts, their applicable interfaces and the history available. | The model’s supported chains, protocol versions and activity definitions. |
Raw records preserve details useful for transaction-level analysis or custom interpretation. Decoded data makes contract-specific questions easier to express. Curated datasets reduce repeated modeling work when their definitions match the metric you need. These layers can complement one another within the same analysis.
Contract Events and Function Calls
Ethereum’s
ethereum.transactions
contains one row per transaction. Logs and traces describe different parts of execution, so counting their rows doesn’t produce the same metric as counting transactions.
Decoded event tables
expose readable contract fields. Dune’s Event Logs documentation identifies
uniswap_v3_ethereum.Factory_evt_PoolCreated
as the Ethereum table for Uniswap V3 pool-creation events. The related
uniswap_v3_ethereum.Factory_call_createPool
table describes calls to the function. Use the event table for emitted events and the call table for recorded invocations; their counts aren’t interchangeable.
Decoded tables can collect multiple instances of a contract type. The
contract_address
field distinguishes the instance emitting an event or receiving a call. A protocol namespace alone doesn’t necessarily restrict the result to one pool or contract.
Call tables describe onchain execution. A local read-only function call that isn’t broadcast doesn’t appear as an onchain call record. The same function can be recorded when another contract invokes it within a transaction.
Curated Metrics and Units
Dune’s curated datasets normalize activity into consistent schemas. For DEX analysis,
dex.trades
covers supported EVM activity, while
dex_solana.trades
provides Solana DEX data. A table’s cross-chain scope doesn’t imply identical protocol coverage on every network.
The
dex.trades
fields
blockchain
,
project
and
version
describe the network and DEX implementation. Each recorded pool segment is a separate row, so a transaction routed through several pools can contribute several rows.
Amount columns also carry different meanings. In
dex.trades
,
token_bought_amount_raw
is the quantity before decimal adjustment,
token_bought_amount
is in token display units and
amount_usd
is the trade’s USD value at execution. Those columns aren’t interchangeable measures of volume.
Pool Trade Rows Versus Transactions
A reader wants the number of Ethereum transactions containing a recorded DEX trade. Assume a hypothetical 13-day sample with 83 pool trade rows and 53 distinct, non-null transaction hashes. The period and counts are illustrative inputs, not measured activity.
SELECT
COUNT(*) AS pool_trade_rows,
COUNT(DISTINCT tx_hash) AS transactions_with_trades,
COUNT(*) - COUNT(DISTINCT tx_hash) AS additional_rows
FROM dex.trades
WHERE blockchain = 'ethereum'
AND block_time >= NOW() - INTERVAL '13' DAY
AND block_time < NOW();
For that hypothetical sample, the results are 83 pool trade rows, 53 transactions with recorded trades and 30 additional rows:
83 - 53 = 30
. Reporting the row count as the transaction count would overstate transactions by 30. Another recorded pool segment within an existing transaction increases the row count without increasing the distinct transaction count. Both counts remain limited to the selected table, network and period.
Coverage and Query Boundaries
Dune’s data explorer provides table schemas and sample data. Confirm the available columns, contract coverage and historical range before relying on an aggregation. A missing decoded event or unsupported protocol version can’t establish that no onchain activity occurred.
Time filters and a
blockchain
filter on applicable cross-chain tables help reduce the data scanned. Use the table’s actual partition fields and select the columns the analysis needs. When joining event or trade rows to transaction records, account for multiple matching rows before summing transaction-level values; otherwise the join can repeat those values in the total.