On-Chain Analysis Skill
Analyze any verified EVM smart contract by pasting its address. The skill runs a full analysis pipeline:
- ABI Fetching — Retrieves the verified ABI from Etherscan (or accepts a manual ABI)
- Usage Discovery — Queries Dune to find which methods are most called, by whom, and with what value
- Decoded Data Tables — AI generates DuneSQL queries using
decode_evm_function_call() to build raw decoded data tables on Dune
- Analytics Generation — A second AI pass generates 6-10 visualization queries (stats, time series, bar charts, pie charts) from the decoded tables
- Execution — All queries are executed on Dune and results returned as structured JSON
When to Use
- User asks "analyze this contract" or "what does this contract do"
- User wants on-chain analytics, usage stats, or dashboards for a smart contract
- User provides a contract address and wants to understand its activity
- User asks about transaction patterns, caller behavior, or function usage
- User wants to compare function usage or identify top callers
- User asks "who uses this contract" or "how popular is this contract"
How to Call
POST https://esraarlhpxraucslsdle.supabase.co/functions/v1/onchain-analysis
Request Body
{
"contractAddress": "0x00000000009726632680FB29d3F7A9734E3010E2",
"chain": "base",
"abi": "(optional — raw ABI JSON string if contract is unverified)"
}
Parameters
| Field |
Type |
Required |
Description |
contractAddress |
string |
Yes |
The EVM contract address (0x-prefixed, 42 chars including 0x) |
chain |
string |
Yes |
One of: ethereum, polygon, bsc, arbitrum, optimism, base, avalanche |
abi |
string/array |
No |
Manual ABI if contract is not verified on Etherscan |
Supported Chains
| Chain |
Example Explorer |
ethereum |
etherscan.io |
polygon |
polygonscan.com |
bsc |
bscscan.com |
arbitrum |
arbiscan.io |
optimism |
optimistic.etherscan.io |
base |
basescan.org |
avalanche |
snowtrace.io |
Response
{
"contractAddress": "0x...",
"chain": "base",
"tldr": "## TLDR\n\n- **Key insight 1** ...\n- **Key insight 2** ...",
"abiSummary": "Events (5):\n - Transfer(...)\nWrite Functions (8):\n - swap(...)",
"dashboardUrl": "https://onchainwizard.ai/shared/abc123-uuid",
"topMethods": [
{
"function_name": "swap",
"call_count": 142000,
"unique_callers": 5200,
"total_eth": 1234.5678
}
],
"rawTables": [
{
"function_name": "swap",
"query_id": 12345,
"dune_url": "https://dune.com/queries/12345",
"execution_state": "QUERY_STATE_COMPLETED"
}
],
"queryResults": [
{
"id": "total_swaps",
"title": "Total Swaps",
"type": "stat",
"sql": "SELECT COUNT(*) AS value FROM query_12345",
"rows": [{ "value": 142000 }]
},
{
"id": "daily_swaps",
"title": "Daily Swap Volume",
"type": "timeseries",
"sql": "SELECT DATE_TRUNC('day', block_time) AS date, COUNT(*) AS value FROM query_12345 GROUP BY 1 ORDER BY 1",
"rows": [
{ "date": "2026-01-01", "value": 500 },
{ "date": "2026-01-02", "value": 620 }
]
}
]
}
Query Result Types
| Type |
Description |
Key Fields |
stat |
Single metric |
rows[0].value — the headline number |
timeseries |
Data over time |
rows[].date, rows[].value |
bar |
Category comparison |
rows[].label, rows[].value |
pie |
Distribution |
rows[].label, rows[].value |
scatter |
Correlation |
rows[].x, rows[].y |
How to Present Results
- Start with the TLDR — display it as markdown to give the user a quick overview
- Dashboard link — always include the
dashboardUrl so the user can view the full interactive dashboard: "📊 View full dashboard"
- Stat queries (
type: "stat") — show as headline metrics (e.g., "Total Swaps: 142,000")
- Time series (
type: "timeseries") — describe trends ("Daily swaps peaked at X on date Y")
- Bar/Pie charts (
type: "bar" / type: "pie") — summarize distributions ("Top 5 callers account for 60% of swaps")
- Link to Dune — provide
dune_url links for raw tables so users can explore further
- Failed queries — if a query has
error instead of rows, mention it briefly but don't block the rest
Example Conversations
Basic: "Analyze this contract"
User: Analyze 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D on ethereum
Action: Call the skill with { "contractAddress": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", "chain": "ethereum" }
Present: TLDR → Stats → Trends → Distributions → Dune links
Missing chain
User: What does 0xABC...DEF do?
Action: Ask which chain before calling. "Which chain is this contract on? I support Ethereum, Polygon, BSC, Arbitrum, Optimism, Base, and Avalanche."
Unverified contract
User: Analyze 0xABC...DEF on base
API returns: "Could not fetch ABI"
Action: Ask user for the ABI JSON, then retry with { "contractAddress": "...", "chain": "base", "abi": "<user-provided ABI>" }
Follow-ups after analysis
- "Tell me more about the top callers" → Expand on bar/pie data from
queryResults
- "What does the swap function do?" → Use
abiSummary to explain
- "Can I see the raw data?" → Link to
rawTables[].dune_url
Important Notes
- The analysis takes 2-5 minutes due to Dune query execution and materialization — set user expectations
- Only works for contracts with verified ABIs (unless a manual ABI is provided)
- The AI selects the most interesting functions automatically based on usage data
- Raw decoded tables are saved as named queries on Dune for future reference
- Query results may be empty if the contract has very little on-chain activity
Error Handling
| Error |
Meaning |
Recommended Action |
"Could not fetch ABI" |
Contract is not verified |
Ask user for the ABI |
"No write functions found" |
No state-changing functions |
Inform user; contract may be read-only or a proxy |
"Unsupported chain" |
Chain not in supported list |
List supported chains and ask again |
"Missing required API keys" |
Server-side config issue |
Report as a service error |
| Timeout / no response |
Analysis exceeded time limit |
Suggest retrying; Dune may be under load |
1---
2name: onchain-analysis
3description: Analyze any EVM smart contract — auto-fetches ABI, discovers usage patterns, decodes function calls via Dune, generates AI-driven analytics (charts, stats, time series), and returns structured results. Supports Ethereum, Polygon, BSC, Arbitrum, Optimism, Base, Avalanche.
4metadata:
5 source: https://skillmd.com/skills/modbender/onchain-analysis
6---
7
8# On-Chain Analysis Skill
9
10Analyze any verified EVM smart contract by pasting its address. The skill runs a full analysis pipeline:
11
121. **ABI Fetching** — Retrieves the verified ABI from Etherscan (or accepts a manual ABI)
132. **Usage Discovery** — Queries Dune to find which methods are most called, by whom, and with what value
143. **Decoded Data Tables** — AI generates DuneSQL queries using `decode_evm_function_call()` to build raw decoded data tables on Dune
154. **Analytics Generation** — A second AI pass generates 6-10 visualization queries (stats, time series, bar charts, pie charts) from the decoded tables
165. **Execution** — All queries are executed on Dune and results returned as structured JSON
17
18## When to Use
19
20- User asks "analyze this contract" or "what does this contract do"
21- User wants on-chain analytics, usage stats, or dashboards for a smart contract
22- User provides a contract address and wants to understand its activity
23- User asks about transaction patterns, caller behavior, or function usage
24- User wants to compare function usage or identify top callers
25- User asks "who uses this contract" or "how popular is this contract"
26
27## How to Call
28
29**POST** `https://esraarlhpxraucslsdle.supabase.co/functions/v1/onchain-analysis`
30
31### Request Body
32
33```json
34{
35 "contractAddress": "0x00000000009726632680FB29d3F7A9734E3010E2",
36 "chain": "base",
37 "abi": "(optional — raw ABI JSON string if contract is unverified)"
38}
39```
40
41### Parameters
42
43| Field | Type | Required | Description |
44|-------|------|----------|-------------|
45| `contractAddress` | string | Yes | The EVM contract address (0x-prefixed, 42 chars including 0x) |
46| `chain` | string | Yes | One of: `ethereum`, `polygon`, `bsc`, `arbitrum`, `optimism`, `base`, `avalanche` |
47| `abi` | string/array | No | Manual ABI if contract is not verified on Etherscan |
48
49### Supported Chains
50
51| Chain | Example Explorer |
52|-------|-----------------|
53| `ethereum` | etherscan.io |
54| `polygon` | polygonscan.com |
55| `bsc` | bscscan.com |
56| `arbitrum` | arbiscan.io |
57| `optimism` | optimistic.etherscan.io |
58| `base` | basescan.org |
59| `avalanche` | snowtrace.io |
60
61### Response
62
63```json
64{
65 "contractAddress": "0x...",
66 "chain": "base",
67 "tldr": "## TLDR\n\n- **Key insight 1** ...\n- **Key insight 2** ...",
68 "abiSummary": "Events (5):\n - Transfer(...)\nWrite Functions (8):\n - swap(...)",
69 "dashboardUrl": "https://onchainwizard.ai/shared/abc123-uuid",
70 "topMethods": [
71 {
72 "function_name": "swap",
73 "call_count": 142000,
74 "unique_callers": 5200,
75 "total_eth": 1234.5678
76 }
77 ],
78 "rawTables": [
79 {
80 "function_name": "swap",
81 "query_id": 12345,
82 "dune_url": "https://dune.com/queries/12345",
83 "execution_state": "QUERY_STATE_COMPLETED"
84 }
85 ],
86 "queryResults": [
87 {
88 "id": "total_swaps",
89 "title": "Total Swaps",
90 "type": "stat",
91 "sql": "SELECT COUNT(*) AS value FROM query_12345",
92 "rows": [{ "value": 142000 }]
93 },
94 {
95 "id": "daily_swaps",
96 "title": "Daily Swap Volume",
97 "type": "timeseries",
98 "sql": "SELECT DATE_TRUNC('day', block_time) AS date, COUNT(*) AS value FROM query_12345 GROUP BY 1 ORDER BY 1",
99 "rows": [
100 { "date": "2026-01-01", "value": 500 },
101 { "date": "2026-01-02", "value": 620 }
102 ]
103 }
104 ]
105}
106```
107
108### Query Result Types
109
110| Type | Description | Key Fields |
111|------|-------------|------------|
112| `stat` | Single metric | `rows[0].value` — the headline number |
113| `timeseries` | Data over time | `rows[].date`, `rows[].value` |
114| `bar` | Category comparison | `rows[].label`, `rows[].value` |
115| `pie` | Distribution | `rows[].label`, `rows[].value` |
116| `scatter` | Correlation | `rows[].x`, `rows[].y` |
117
118## How to Present Results
119
1201. **Start with the TLDR** — display it as markdown to give the user a quick overview
1212. **Dashboard link** — always include the `dashboardUrl` so the user can view the full interactive dashboard: "📊 [View full dashboard](dashboardUrl)"
1223. **Stat queries** (`type: "stat"`) — show as headline metrics (e.g., "Total Swaps: 142,000")
1234. **Time series** (`type: "timeseries"`) — describe trends ("Daily swaps peaked at X on date Y")
1245. **Bar/Pie charts** (`type: "bar"` / `type: "pie"`) — summarize distributions ("Top 5 callers account for 60% of swaps")
1256. **Link to Dune** — provide `dune_url` links for raw tables so users can explore further
1267. **Failed queries** — if a query has `error` instead of `rows`, mention it briefly but don't block the rest
127
128## Example Conversations
129
130### Basic: "Analyze this contract"
131**User:** Analyze 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D on ethereum
132**Action:** Call the skill with `{ "contractAddress": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", "chain": "ethereum" }`
133**Present:** TLDR → Stats → Trends → Distributions → Dune links
134
135### Missing chain
136**User:** What does 0xABC...DEF do?
137**Action:** Ask which chain before calling. "Which chain is this contract on? I support Ethereum, Polygon, BSC, Arbitrum, Optimism, Base, and Avalanche."
138
139### Unverified contract
140**User:** Analyze 0xABC...DEF on base
141**API returns:** `"Could not fetch ABI"`
142**Action:** Ask user for the ABI JSON, then retry with `{ "contractAddress": "...", "chain": "base", "abi": "<user-provided ABI>" }`
143
144### Follow-ups after analysis
145- "Tell me more about the top callers" → Expand on bar/pie data from `queryResults`
146- "What does the swap function do?" → Use `abiSummary` to explain
147- "Can I see the raw data?" → Link to `rawTables[].dune_url`
148
149## Important Notes
150
151- The analysis takes **2-5 minutes** due to Dune query execution and materialization — set user expectations
152- Only works for contracts with verified ABIs (unless a manual ABI is provided)
153- The AI selects the most interesting functions automatically based on usage data
154- Raw decoded tables are saved as named queries on Dune for future reference
155- Query results may be empty if the contract has very little on-chain activity
156
157## Error Handling
158
159| Error | Meaning | Recommended Action |
160|-------|---------|-------------------|
161| `"Could not fetch ABI"` | Contract is not verified | Ask user for the ABI |
162| `"No write functions found"` | No state-changing functions | Inform user; contract may be read-only or a proxy |
163| `"Unsupported chain"` | Chain not in supported list | List supported chains and ask again |
164| `"Missing required API keys"` | Server-side config issue | Report as a service error |
165| Timeout / no response | Analysis exceeded time limit | Suggest retrying; Dune may be under load |