402.bot
Recipe
live $0.0100 premium General Research

Dune Onchain Brief

Turn an onchain question into dataset discovery, schema inspection, DuneSQL execution, and a compact brief.

$0.0100price
7steps
6sources
368ktokens saved
25tool calls compressed
median latency
DuneDune Dataset SearchGoogle Gemini Flash StructuredDune Table SchemaDune Run SqlTransform

Endpoint: /v1/recipes/dune-onchain-brief/run
Capabilities: dune, onchain, sql, analytics, research

Why pay for this?

This recipe turns roughly 25 separate tool operations into one paid endpoint call and saves about ~368k tokens saved.

Dataset search -> schema -> SQL -> summary

Creator

Name: 402.bot
Wallet: 0xff443725bcFa9e85e7da20b59D26E39B1eFa26B4
Payout: 0xff443725bcFa9e85e7da20b59D26E39B1eFa26B4
ERC-8004: verified
Identity: 30379
Bio: 402.bot managed workflow marketplace recipes.
ERC-8004 reputation: 0.0
Creator score: 21

Usage and trust

Success 30d: 0%
Refund 30d: 0%
Paid runs: 0
Creator recipes: 1
Last run: No recent runs

Dune on 402.bot

Use Dune directly for your own MCP and terminal setup, and use 402.bot when you want a paid, recipe-backed onchain analytics workflow.

Canonical guide: https://402.bot/recipes/dune-onchain-brief

Public sources: dune_dataset_search, dune_table_schema, dune_run_sql

402bot init dune bootstraps the official Dune MCP, CLI, and skill flow with your own DUNE_API_KEY.402.bot server-side Dune sources and the dune-onchain-brief recipe run with the deployment's configured DUNE_API_KEY.402.bot does not expose sponsored raw Dune MCP execution in v1.

Notes: Use Dune's native MCP, CLI, and skill when you want exploratory terminal workflows or docs search. Use 402.bot when you want one paid workflow that handles table discovery, schema inspection, SQL execution, and a compact analyst brief.

Pipeline

Stage 1

Search Dune datasets

fetch_transform

Source: Dune Dataset Search
Step id: datasets

Stage 2

Choose candidate tables

fetch_transform

Source: Google Gemini Flash Structured
Step id: schema_plan

Stage 3

Load chosen schemas

fetch_transform

Source: Dune Table Schema
Step id: schemas

Stage 4

Generate bounded DuneSQL

fetch_transform

Source: Google Gemini Flash Structured
Step id: sql_plan

Stage 5

Execute DuneSQL

fetch_transform

Source: Dune Run Sql
Step id: query

Stage 6

Summarize the result

fetch_transform

Source: Google Gemini Flash Structured
Step id: summary

Stage 7

Attach audit fields

transform

Source: Transform
Step id: finalize

Recent runs

RunStatusTriggerQueued
No recent runs recorded yet. Runs appear here after the first paid execution.
View raw step spec

Search Dune datasets

{
  "id": "datasets",
  "kind": "fetch_transform",
  "title": "Search Dune datasets",
  "request": {
    "params": {
      "limit": 10,
      "query": "{{ $.input.question }} {{ $.input.target }} {{ $.input.chains }}",
      "chains": "{{ $.input.chains }}"
    },
    "sourceId": "dune_dataset_search",
    "deliveryFormat": "json"
  }
}

Choose candidate tables

{
  "id": "schema_plan",
  "kind": "fetch_transform",
  "title": "Choose candidate tables",
  "request": {
    "params": {
      "input": {
        "chains": "{{ $.input.chains }}",
        "target": "{{ $.input.target }}",
        "question": "{{ $.input.question }}",
        "datasetSearch": "{{ $.stepsById.datasets.output }}"
      },
      "prompt": "Choose up to three Dune tables from the supplied dataset search results that best answer the user's question. Prefer tables that clearly match the requested chains and analysis target.",
      "responseSchema": {
        "type": "object",
        "required": [
          "tables"
        ],
        "properties": {
          "tables": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "fullName",
                "rationale"
              ],
              "properties": {
                "fullName": {
                  "type": "string"
                },
                "rationale": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      },
      "systemInstruction": "Return only table references from the supplied dataset search output. Do not invent tables. Prefer the fewest tables that can answer the question."
    },
    "sourceId": "google_gemini_flash_structured",
    "deliveryFormat": "json"
  }
}

Load chosen schemas

{
  "id": "schemas",
  "kind": "fetch_transform",
  "title": "Load chosen schemas",
  "request": {
    "params": {
      "tables": "{{ $.stepsById.schema_plan.output.output.tables }}"
    },
    "sourceId": "dune_table_schema",
    "deliveryFormat": "json"
  }
}

Generate bounded DuneSQL

{
  "id": "sql_plan",
  "kind": "fetch_transform",
  "title": "Generate bounded DuneSQL",
  "request": {
    "params": {
      "input": {
        "days": "{{ $.input.days }}",
        "chains": "{{ $.input.chains }}",
        "target": "{{ $.input.target }}",
        "maxRows": "{{ $.input.maxRows }}",
        "schemas": "{{ $.stepsById.schemas.output }}",
        "question": "{{ $.input.question }}"
      },
      "prompt": "Generate one executable DuneSQL query that answers the user's question using only the supplied Dune schemas. The query must be read-only, must include a literal LIMIT, and should use the supplied days and maxRows when relevant.",
      "responseSchema": {
        "type": "object",
        "required": [
          "generatedSql",
          "datasetsUsed",
          "assumptions"
        ],
        "properties": {
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Assumptions or caveats used when generating the SQL."
          },
          "datasetsUsed": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Datasets referenced by the generated SQL."
          },
          "generatedSql": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "systemInstruction": "You are a DuneSQL analyst. Only reference tables and columns that appear in the supplied schema bundle. Return exactly one query and a short list of assumptions."
    },
    "sourceId": "google_gemini_flash_structured",
    "deliveryFormat": "json"
  }
}

Execute DuneSQL

{
  "id": "query",
  "kind": "fetch_transform",
  "title": "Execute DuneSQL",
  "request": {
    "params": {
      "sql": "{{ $.stepsById.sql_plan.output.output.generatedSql }}",
      "maxRows": "{{ $.input.maxRows }}"
    },
    "sourceId": "dune_run_sql",
    "deliveryFormat": "json"
  }
}

Summarize the result

{
  "id": "summary",
  "kind": "fetch_transform",
  "title": "Summarize the result",
  "request": {
    "params": {
      "input": {
        "chains": "{{ $.input.chains }}",
        "target": "{{ $.input.target }}",
        "sqlPlan": "{{ $.stepsById.sql_plan.output.output }}",
        "question": "{{ $.input.question }}",
        "queryResult": "{{ $.stepsById.query.output }}"
      },
      "prompt": "Write a compact analyst-style answer that summarizes the Dune query result for the user's original question. Keep it factual and grounded in the supplied result rows only.",
      "responseSchema": {
        "type": "object",
        "required": [
          "summary"
        ],
        "properties": {
          "summary": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "systemInstruction": "Do not invent metrics or causal claims. Summarize only what the supplied Dune result shows."
    },
    "sourceId": "google_gemini_flash_structured",
    "deliveryFormat": "json"
  }
}

Attach audit fields

{
  "id": "finalize",
  "kind": "transform",
  "title": "Attach audit fields",
  "request": {
    "mode": "clean_json",
    "source": {
      "kind": "json",
      "value": {
        "chains": "{{ $.input.chains }}",
        "target": "{{ $.input.target }}",
        "summary": "{{ $.stepsById.summary.output.output.summary }}",
        "question": "{{ $.input.question }}",
        "assumptions": "{{ $.stepsById.sql_plan.output.output.assumptions }}",
        "generatedAt": "{{ $.run.startedAt }}",
        "datasetsUsed": "{{ $.stepsById.sql_plan.output.output.datasetsUsed }}",
        "generatedSql": "{{ $.stepsById.sql_plan.output.output.generatedSql }}",
        "artifactLinks": "{{ $.stepsById.query.output.artifactLinks }}",
        "resultExcerpt": "{{ $.stepsById.query.output.rows }}",
        "executionMetadata": "{{ $.stepsById.query.output.execution }}"
      }
    }
  }
}