Workflow for running Dune Analytics SQL queries against Solana blockchain data. Use this skill whenever the user asks to query Dune, extract on-chain data from Solana, run SQL against solana.transactions, or needs per-program fee/CU data. Also trigger when the user mentions "Dune", "on-chain query", "program fees", "priority fees per program", "compute units by program", or any Solana data extraction task. CRITICAL: This skill encodes a hard constraint — Cowork's VM CANNOT call the Dune API (HTTPS proxy blocks it). All Dune operations must go through Claude Code in VS Code via MCP.
You CANNOT execute Dune queries from Cowork's Linux VM.
The VM's HTTPS proxy blocks outbound calls to api.dune.com. This has been tested and confirmed multiple times. Do NOT attempt urllib, requests, curl, or any HTTP call to Dune — it will fail with 403 Forbidden.
Instead, your job is to prepare everything and hand it to the user as a ready-to-paste prompt for Claude Code in VS Code, which has Dune MCP access.
Write the SQL query following the patterns that work on Dune's free tier (see below). Save it to a .sql file in the project.
Create a markdown file containing:
Tell Sylvain: "Copy-paste this prompt into Claude Code in VS Code. It will create the query on Dune, execute it, and save the results."
Once the user has the CSV, then you can:
WITH tx_with_program AS (
SELECT
fee,
compute_units_consumed,
instructions[1].executing_account AS program_id,
success
FROM solana.transactions
WHERE block_date >= DATE '2026-02-04'
AND block_date < DATE '2026-03-06'
AND compute_units_consumed > 0
AND fee > 0
-- Optional: filter to specific programs
AND instructions[1].executing_account IN ('addr1', 'addr2', ...)
)
SELECT
program_id,
COUNT(*) AS tx_count,
SUM(CASE WHEN success THEN 1 ELSE 0 END) AS success_count,
ROUND(SUM(5000.0) / 1e9, 4) AS base_fees_sol,
ROUND(SUM(GREATEST(CAST(fee AS double) - 5000, 0)) / 1e9, 4) AS priority_fees_sol,
ROUND(SUM(CAST(fee AS double)) / 1e9, 4) AS total_fees_sol,
SUM(compute_units_consumed) AS total_cu,
ROUND(AVG(CAST(compute_units_consumed AS double)), 0) AS avg_cu_per_tx
FROM tx_with_program
GROUP BY program_id
ORDER BY total_fees_sol DESC
Key points:
block_date partition pruning — without it, full table scan = timeoutDATE '2026-02-04') not CURRENT_DATE - INTERVAL for reproducibilityinstructions[1].executing_account = first instruction's program (program attribution)cardinality(signatures))required_signatures (integer) is available natively — no need for cardinality(signatures)compute_units_consumed is the correct column name (not compute_units)solana.transactions with solana.instruction_calls (too many rows)system_program_solana.system_program_call_transfer on > 48h windowssolana.transactions without program filteringPer @ilemi query 4314734, JOINing system_program_solana.system_program_call_transfer with solana.transactions works on 48h windows. The decoded table column is lamports (not amount), and account_to for recipient. Table name is lowercase (system_program_call_transfer). See data/sql_query2_jito_tips_qc_48h.sql for the tested pattern. If timeout on 48h, reduce to 24h.
Community plan: 2500 credits/month. Billing period resets ~6th of each month. One 30d single-table scan with 531-program IN clause costs ~200-500 credits. The Jito JOIN query (48h) costs ~300-800 credits. Budget both queries before executing.
Claude Code in VS Code has these Dune MCP tools:
createDuneQuery(name, query_sql, is_private) — Creates a saved queryexecuteQueryById(query_id, parameters) — Runs a query (async)getExecutionResults(execution_id) — Polls for resultssearchTables(search_term) — Explore table schemasAll output CSVs must use:
;)data/raw/ in the raiku-revenue-model projectThis skill is part of the RAIKU revenue model project. Key files:
config.py — API keys, paths, CSV settingsdata/raw/dune_program_fees_v2.csv — Canonical 30-day per-program data (500 programs)data/raw/dune_daily_program_fees.csv — Daily per-program data (20 days, 82 programs)data/mapping/program_categories.csv — 314 programs classified (aot/jit/both/potential/neither)02_transform/build_program_database.py — Merges Dune + mapping → program_database.csvWhen writing a prompt for Claude Code, use this structure:
# [Query Name]
## SQL Query
[SQL in code block]
## Instructions
1. Create this query on Dune: `createDuneQuery("query-name", sql, true)`
2. Execute it: `executeQueryById(query_id)`
3. Poll for results: `getExecutionResults(execution_id)` — retry every 30s until complete
4. Save results to `data/raw/[filename].csv` with semicolon delimiter (`;`), UTF-8
5. Validate: [specific checks]
## Expected Output
- Columns: [list]
- Rows: ~[estimate]
- Period: [dates]