SQL views for Dune
GitHub Repo

SQL views for Dune

@the_ospsPost Author

Project Description

View on GitHub

Unpacking Dune's Spellbook: SQL Views for On-Chain Data

If you've ever wrestled with complex blockchain data queries, you know the pain of repeating the same JOINs and WHERE clauses across multiple analyses. The folks at Dune Analytics just dropped something that might change how we approach on-chain data analysis.

Their Spellbook repository introduces SQL views for blockchain data—think of it as a shared library of common transformations and abstractions that make querying Ethereum, Solana, and other chains significantly cleaner.

What It Does

Spellbook is Dune's open source collection of SQL "spells"—essentially reusable views and transformations that standardize how we interact with raw blockchain data. Instead of every analyst starting from scratch with raw decoded tables, Spellbook provides curated abstractions like dex.trades, nft.trades, and tokens.erc20 that handle the underlying complexity.

These aren't just simple views—they're sophisticated SQL transformations that normalize data across different standards and protocols, making cross-protocol analysis actually feasible without losing your mind.

Why It's Cool

The magic here is in the abstraction layer. Instead of needing to understand the exact implementation details of every Uniswap version or NFT marketplace, you can query consistent interfaces. Want to compare trading volume across all DEXs? Spellbook gives you a unified dex.trades table rather than forcing you to manually combine Uniswap, Sushiswap, Curve, and others.

What makes this particularly clever is that it's built using dbt (data build tool), meaning the entire transformation pipeline is version-controlled, tested, and documented. The community can contribute new spells or improvements through standard GitHub workflows, creating a living library that gets smarter over time.

The implementation is production-grade too—incremental models prevent full table refreshes, and there's proper testing built in to ensure data quality.

How to Try It

Head over to the Spellbook repository to browse the available abstractions. You can see all the current spells in the models directory, organized by category like dex, nft, and tokens.

If you're already using Dune, many of these abstractions are available directly in their query interface. For local development or contributing, you can clone the repo and set up dbt to run the transformations against your own data warehouse.

The quickest way to get a feel for it is to check out some example queries in the repository or jump into Dune's platform and start querying the abstracted tables directly.

Final Thoughts

As someone who's written their fair share of repetitive blockchain queries, Spellbook feels like finding a well-stocked toolbox when you're used to building everything from scratch. It's not just about saving time—it's about creating shared mental models and consistent data definitions across the entire analytics community.

For developers building analytics features or doing deep protocol research, this could significantly accelerate your workflow. The open source nature means we can all benefit from and contribute to making on-chain data more accessible. It's one of those projects that makes you wonder how we managed without it.

@githubprojects

Back to Projects
Project ID: 1977227704090173947Last updated: October 12, 2025 at 04:19 AM