Dune Spellbook: Open-Source Community Decoded Tables for Blockchains
Spellbook is Dune Analytics' open-source repository of 'spells' — community-maintained SQL transformations that turn raw blockchain data into clean, human-readable tables for specific protocols. It is the substrate that makes Dune's SQL-on-blockchains abstraction usable.
Spellbook is the open-source repository underlying Dune Analytics's decoded data layer, hosted publicly at github.com/duneanalytics/spellbook. It contains the SQL transformations — called 'spells' — that convert raw blockchain data (transactions, traces, event logs) into clean, protocol-specific tables that humans can query directly. A spell is essentially a dbt-style model. Raw chain data lands in low-level tables (for example ethereum.logs and ethereum.transactions). A spell joins, decodes, and filters those tables to produce something useful, like uniswap_v3.swaps or aave_v3.borrows. Each spell is checked into the repository as version-controlled SQL plus metadata declaring its inputs, outputs, and tests. Spellbook is community-maintained. Anyone can open a pull request adding a spell for a new protocol or extending an existing one. Maintainers review and merge, after which the spell is built into Dune's data warehouse and the resulting table becomes queryable by all users. This crowdsourcing is the operational reason new DeFi protocols typically have query-ready tables on Dune within days of launch — the protocol team or a community Wizard contributes the spell upstream. The architectural significance is that Spellbook decouples Dune's value from any single team's roadmap. Coverage of long-tail protocols, edge-case event signatures, and chain-specific quirks is sustained by the contributor community rather than gated by Dune employees' priorities. It also means decoded data is auditable: any user can inspect the SQL that produced a table and check whether the transformation is correct. Spellbook runs on top of DuneSQL (a Trino fork) and uses dbt for build orchestration. Test fixtures within the repo validate spell outputs against known values, giving the system some defense against decoding bugs introduced by PRs.