Skip to content
Back to skills

Tron Sql Patterns

ASecurity

Use before calling run_sql on the TRON warehouse. Rules for bounded, explained, chunked read-only SQL and when to use export or a job instead; details come from search_docs.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 8, 2026
ai-agentsgosql

Works with

  • cursor

Security analysis

A100/100

Scanned November 8, 2026

npx -y skills add transatron/awesome-tron-agents --skill tron-sql-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tron Sql Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tron Sql Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/transatron-tron-sql-patterns/badge)](https://www.skillsdirectory.com/skills/transatron-tron-sql-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: tron-sql-patterns
description: Use before calling run_sql on the TRON warehouse. Rules for bounded, explained, chunked read-only SQL and when to use export or a job instead; details come from search_docs.
---

# SQL patterns

## Decide first

Use a dedicated tool when one answers the question (`address_transfers`, `address_counterparties`, `first_funder`,
`contract_callers`, `decode_calls`, `trace_flows`). They are index-shaped and cost 1-5 CU. Write `run_sql` only when
no tool fits: a custom join, a window, a selector histogram.

## Rules

1. **`explain_sql` first.** It never runs the statement, costs 0 CU, and returns the verdict, the partitions touched,
   the estimated cost and a chunk list when the statement is too wide.
2. **Literal block bounds.** Put `block_number BETWEEN <a> AND <b>` with literal numbers on every partitioned table.
   A bound hidden inside a CTE or a subquery does not prune partitions. Add a time bound next to it on address
   lookups.
3. **Stay inside the limits**: read-only single statement, 120 s, cost 5,000,000, 3 partitions. Exact current values:
   `search_docs` "limits".
4. **Chunk large scans by week.** About 201,600 blocks is one week. The `explain_sql` chunk list gives ready ranges.
5. **Know the traps** before you filter: sign of amounts on the sending side, two timestamp types, boolean
   transaction result, address encoding, rounding needing a numeric cast. Ask `search_docs` "gotchas".
6. **Decode calldata with a tool**: `decode_calls` takes the signature. Layouts per protocol:
   `search_docs` with the selector (4 bytes, hex) or the protocol name.
7. **Keep the evidence**: quote the `query_id`, the `block_height` and the SQL from `evidence.sql`.

## When the result is big

- Over about 200 rows with hashes: do not paste rows into the conversation. Call `export` with the `query_id` and
  work on the file; report the file path and the row count.
- A statement that needs more time or cost than the interactive limits: `submit_job`, then `job_status`, then
  `job_results`.
- Pages: use the opaque `cursor` the tool returns; do not rebuild paging by hand.

## Recipes

`search_docs` with a topic ("full history of a token", "weekly export", "selector histogram", "parallel payments")
returns a validated recipe with bounded SQL. Prefer a recipe over a fresh statement.

## Errors

`E_TOO_EXPENSIVE`, `E_TIMEOUT`, `E_SQL_FORBIDDEN`, `E_RATE`, `E_QUOTA`: the message names the fix. Narrow the block
range, apply the chunk list, or move to a job. Do not retry the same statement unchanged.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.