ChainScore Labs
All Guides

Building a Custom Portfolio Dashboard with Dune Analytics

LABS

Building a Custom Portfolio Dashboard with Dune Analytics

A technical guide for developers to query, visualize, and track on-chain portfolio data.
Chainscore © 2025

Core Concepts and Prerequisites

An overview of the fundamental knowledge and tools required to successfully build, customize, and analyze data using a personal Dune Analytics dashboard.

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.trades for DEX swaps or nft.trades for NFT market sales.
  • Using abstractions like erc20.tokens simplifies 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, and traces for Ethereum.
  • For example, logs contain 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.

1

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., 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 for USDC.
  • Sub-step 2: Write the Base Query: Construct a query to filter transfers for your wallet address. Use WHERE clauses to specify "from" and "to" addresses.
  • Sub-step 3: Aggregate Data: Use SUM() and GROUP BY functions to calculate net balances or transaction counts.
sql
SELECT 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.

2

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 chart for token distribution or Line chart for 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 time column on the X-axis and the value_usd column 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 $__interval macro in your query's GROUP BY clause (e.g., GROUP BY date_trunc('day', evt_block_time), contract_address) to automatically adjust granularity based on the selected dashboard time range.

3

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.

4

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 SourcePrimary Use CaseGranularityAccess Method in Dune

Ethereum Traces (call, delegatecall)

Track token transfers & internal contract calls

Transaction-level

ethereum.traces table

Decoded Event Logs (via ABIs)

Monitor specific smart contract events (e.g., swaps, staking)

Event-level

Project-specific decoded tables (e.g., uniswap_v3_ethereum.Pair_evt_Swap)

Ethereum Transactions

Analyze gas fees, transaction success/failure

Transaction-level

ethereum.transactions table

Token Transfers (ERC-20/ERC-721)

Track token holdings and movements across wallets

Transfer-level

erc20_ethereum.evt_Transfer or nft_ethereum.transfers

DeFi Llama Yield Pool Data

Monitor APYs and TVL in DeFi protocols

Pool-level, daily

Spellbook tables (e.g., dex.trades, yield.aggregator)

Dune Wizard Labels

Categorize wallets (e.g., CEX, whale) and contracts

Address-level

labels.contracts and labels.all tables

Price Feed Data (prices.usd)

Value portfolio in USD across chains

Minute-level for major tokens

prices.usd (chain-agnostic) or prices.usd_latest

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.logs or protocol-specific tables like uniswap_v3_ethereum.Pair_evt_Swap.
  • Token Standards: Recognize ERC-20 for tokens (like USDC) and ERC-721 for NFTs. Tables like tokens.erc20 and prices.usd help track values.
  • Wallet Addresses: Your portfolio is tied to a public address. Queries filter data WHERE from or to equals your address.

Starter Query

To see your recent USDC transfers on Ethereum:

sql
SELECT 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;
SECTION-ADVANCED-TECHNIQUES

Advanced Techniques and Optimization

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.