An overview of the fundamental knowledge and tools required to successfully build, customize, and analyze data using a personal Dune Analytics dashboard.
Building a Custom Portfolio Dashboard with Dune Analytics
Core Concepts and Prerequisites
Understanding Blockchain Data
On-chain data refers to all information permanently recorded on a blockchain, like Ethereum. This includes transactions, smart contract interactions, token transfers, and wallet balances.
- Data is public, transparent, and immutable once confirmed.
- Examples include tracking NFT sales on OpenSea or analyzing DeFi protocol liquidity pools.
- Mastering this is crucial for querying the correct datasets and building meaningful dashboard metrics.
SQL Query Fundamentals
Structured Query Language (SQL) is the primary tool for extracting and transforming data in Dune. You write queries to filter, join, and aggregate raw blockchain data into human-readable insights.
- Key commands: SELECT, FROM, WHERE, JOIN, and GROUP BY.
- A real use case is calculating the daily trading volume for a specific DEX like Uniswap.
- Strong SQL skills are the foundation for creating any custom dashboard widget or chart.
Dune Spellbook & Abstraction
Abstractions are pre-built, community-maintained SQL tables that decode raw blockchain data into familiar labels. The Spellbook is Dune's repository of these abstractions, saving you from writing complex decoding logic.
- Examples include
dex.tradesfor DEX swaps ornft.tradesfor NFT market sales. - Using abstractions like
erc20.tokenssimplifies querying token names and decimals. - This prerequisite dramatically speeds up development and ensures data accuracy.
Dashboard Design & Visualization
A Dune Dashboard is a collection of queries and visualizations that tell a data story. Effective design involves selecting the right chart types and organizing information for clarity and impact.
- Use counters for key metrics, line charts for trends over time, and tables for detailed data.
- A practical example is a dashboard tracking whale wallet activity for a specific token.
- Good design makes complex on-chain data accessible and actionable for end-users.
Wallet Addresses & Token Standards
Wallet addresses (public keys) and token standards like ERC-20 and ERC-721 are the fundamental entities and assets you will analyze. Understanding their structure and how they interact is key.
- Addresses can be Externally Owned Accounts (EOAs) or smart contracts.
- An ERC-20 token represents fungible assets (e.g., USDC), while ERC-721 represents unique NFTs.
- Queries often filter or group transactions by these addresses and token types.
Connecting to Data Sources
Dune ingests data from blockchain RPC nodes and organizes it into SQL-queryable datasets. Knowing what data is available and its structure is a key prerequisite for building queries.
- Core tables include
transactions,logs, andtracesfor Ethereum. - For example,
logscontain event data emitted by smart contracts, essential for tracking specific actions. - Familiarity with these sources allows you to locate the precise data needed for your analysis.
Methodology: From Query to Dashboard
A step-by-step guide to creating a custom portfolio tracking dashboard using Dune Analytics.
Step 1: Define Your Data Scope & Craft the Query
Identify the blockchain data you need and write the foundational SQL query.
Detailed Instructions
Start by defining the exact on-chain data you wish to track, such as token balances, transaction history, or DeFi positions for a specific wallet address. The core of this step is writing a SQL query in Dune's query editor. Use the platform's decoded tables (like erc20_ethereum.evt_Transfer) to access readable data.
- Sub-step 1: Identify Target Contracts: Determine the smart contract addresses for the assets in your portfolio, e.g.,
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48for USDC. - Sub-step 2: Write the Base Query: Construct a query to filter transfers for your wallet address. Use
WHEREclauses to specify"from"and"to"addresses. - Sub-step 3: Aggregate Data: Use
SUM()andGROUP BYfunctions to calculate net balances or transaction counts.
sqlSELECT contract_address, SUM(CASE WHEN "from" = '0xYourWalletAddress' THEN -value ELSE value END) / 1e18 as net_amount FROM erc20_ethereum.evt_Transfer WHERE "from" = '0xYourWalletAddress' OR "to" = '0xYourWalletAddress' GROUP BY 1
Tip: Use Dune's spellbook documentation to find the correct table names for different blockchains and protocols.
Step 2: Refine and Visualize Query Results
Transform raw query results into clear charts and tables.
Detailed Instructions
After running your initial query, use Dune's visualization wizard to create charts. This transforms raw numbers into actionable insights. Focus on creating clear time series charts for historical balance tracking and counter widgets for current totals.
- Sub-step 1: Add Visualizations: Click "New Visualization" and select a chart type, such as
Bar chartfor token distribution orLine chartfor value over time. - Sub-step 2: Configure Chart Settings: Map your query columns to the chart's axes. For a portfolio value chart, set the
timecolumn on the X-axis and thevalue_usdcolumn on the Y-axis. - Sub-step 3: Add a Counter: Create a counter widget to display the total current portfolio value by summing the latest data point from your time series.
Tip: Use the
$__intervalmacro in your query'sGROUP BYclause (e.g.,GROUP BY date_trunc('day', evt_block_time), contract_address) to automatically adjust granularity based on the selected dashboard time range.
Step 3: Assemble and Configure the Dashboard
Create a new dashboard and add your visualizations.
Detailed Instructions
Navigate to the Dashboards section and create a new dashboard with a descriptive title like "My DeFi Portfolio." This is where you bring all your visualizations together into a single, coherent view.
- Sub-step 1: Create Dashboard: Click "New Dashboard," provide a name and description, and save it.
- Sub-step 2: Add Queries: Click "Add Widget" and select the queries you created in Step 2. You can add multiple visualizations from the same or different queries.
- Sub-step 3: Arrange Layout: Drag and drop widgets to organize the dashboard. Resize them to create a logical flow, such as placing a total value counter at the top, followed by asset allocation charts and a transaction history table below.
- Sub-step 4: Set Parameters: Add a dashboard parameter (e.g., a wallet address input) to make the dashboard dynamic. Reference it in your queries using the syntax
{{address}}.
Tip: Use text widgets to add sections, explanations, or links between related charts for better narrative flow.
Step 4: Publish, Share, and Automate Updates
Finalize the dashboard, share it publicly or privately, and ensure data stays current.
Detailed Instructions
The final step is to make your dashboard operational. Dune dashboards can be public or private. Ensure your queries are set to refresh automatically to reflect the latest on-chain data without manual intervention.
- Sub-step 1: Set Refresh Rate: In the dashboard settings, configure the auto-refresh interval (e.g., every 15 minutes or 1 hour) under "Cache Settings."
- Sub-step 2: Review & Publish: Double-check all visualizations and parameters. Click "Save" and then "Publish" to finalize the dashboard.
- Sub-step 3: Share Your Work: Use the "Share" button to get a public link (e.g.,
https://dune.com/your_username/dashboard_title). You can also embed the dashboard on other websites using the provided iframe code. - Sub-step 4: Monitor and Iterate: Regularly check the dashboard for any query errors due to contract upgrades or schema changes. Use Dune's query version history to track and revert changes if needed.
Tip: For complex dashboards, consider using Dune's API to pull data directly into other applications or alerting systems.
Key On-Chain Data Sources for Portfolio Tracking
Comparison overview of data sources for building a custom portfolio dashboard with Dune Analytics.
| Data Source | Primary Use Case | Granularity | Access Method in Dune |
|---|---|---|---|
Ethereum Traces (call, delegatecall) | Track token transfers & internal contract calls | Transaction-level |
|
Decoded Event Logs (via ABIs) | Monitor specific smart contract events (e.g., swaps, staking) | Event-level | Project-specific decoded tables (e.g., |
Ethereum Transactions | Analyze gas fees, transaction success/failure | Transaction-level |
|
Token Transfers (ERC-20/ERC-721) | Track token holdings and movements across wallets | Transfer-level |
|
DeFi Llama Yield Pool Data | Monitor APYs and TVL in DeFi protocols | Pool-level, daily | Spellbook tables (e.g., |
Dune Wizard Labels | Categorize wallets (e.g., CEX, whale) and contracts | Address-level |
|
Price Feed Data (prices.usd) | Value portfolio in USD across chains | Minute-level for major tokens |
|
Practical SQL Query Examples
Understanding On-Chain Data
On-chain data refers to all information permanently recorded on a blockchain, like Ethereum. For a portfolio dashboard, this means tracking your wallet's transactions, token holdings, and DeFi interactions. Dune Analytics makes this data accessible by translating blockchain activity into readable SQL tables.
Key Concepts
- Smart Contract Events: Actions like token transfers on Uniswap or deposits on Aave emit logs. Dune decodes these into tables like
ethereum.logsor protocol-specific tables likeuniswap_v3_ethereum.Pair_evt_Swap. - Token Standards: Recognize ERC-20 for tokens (like USDC) and ERC-721 for NFTs. Tables like
tokens.erc20andprices.usdhelp track values. - Wallet Addresses: Your portfolio is tied to a public address. Queries filter data WHERE
fromortoequals your address.
Starter Query
To see your recent USDC transfers on Ethereum:
sqlSELECT block_time, from, to, value/1e6 AS amount_usdc FROM erc20_ethereum.evt_Transfer WHERE contract_address = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' -- USDC contract AND (from = 'your_wallet_address' OR to = 'your_wallet_address') ORDER BY block_time DESC LIMIT 10;
Advanced Techniques and Optimization
Further Reading and Resources
Ready to Start Building?
Let's bring your Web3 vision to life.
From concept to deployment, ChainScore helps you architect, build, and scale secure blockchain solutions.