Skip to content
Agentmart
Submit a tool

contract-decode

EVM contract error and calldata decoder.

Skill by sd0xdev

IndexedMIT★ 194
Write a review

Install

Works with Claude Code. Read the repository before you give any tool access to your data.

npx agentmarket install skill/sd0xdev-contract-decode

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

EVM contract error and calldata decoder. Use when: user pastes hex revert data, calldata, function selector, or mentions custom error, execution reverted, 4byte, decode. Input contains 0x + 8+ hex chars.

Use cases: documents, data

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/contract-decode

Tools it pre-approves 5

From allowed-tools in SKILL.md: the agent may use these without asking you each time.

  • Read,
  • Grep,
  • Glob,
  • Bash,
  • WebFetch

What's inside

Skill name
contract-decode
Description
EVM contract error and calldata decoder. Use when: user pastes hex revert data, calldata, function selector, or mentions custom error, execution reverted, 4byte, decode. Input contains 0x + 8+ hex chars.
License
MIT
Allowed tools
Read,, Grep,, Glob,, Bash,, WebFetch
Instructions
182 lines in SKILL.md · view on GitHub

Before installing

  • Pre-approves some shell commands

Files (2)

  • SKILL.md
  • apis.md · references/

SKILL.md (first lines)

# Contract Decode — EVM Error & Calldata Decoder

Decode EVM contract function selectors, custom errors, calldata, and revert data.

## Trigger

- Keywords: revert, selector, 4byte, calldata, decode, custom error, execution reverted, abi decode
- Message contains `0x` + 8+ hex chars (selector or revert data)

## When NOT to Use

- Standard `Error(string)` revert already handled by your codebase
- Non-EVM chain errors
- Only need error code definitions (not hex decoding)

## Input Parsing

Extract from user input:

| Field | Source | Example |
|-------|--------|---------|
| `revertData` | Error data or user-pasted hex | `0xaca553e4` |
| `calldata` | Transaction data | `0x5e15c749000...1c05` |
| `contractAddr` | Contract address | `0x5874...f064` |
| `chainId` | Chain identifier | `1` (Ethereum mainnet) |

## Workflow

```
Step 1: Classify input → Step 2: Local fast decode → Step 3: ABI query → Step 4: Precise decode → Report
```

### Step 1: Classify Input

| Length | Classification | Next Step |
|--------|---------------|-----------|
| 4 bytes (`0x` + 8 hex) | Pure selector | Step 2 |
| > 4 bytes, with selector prefix | Calldata or revert data | Step 2 + Step 3 |
| Contract address | Need ABI first | Step 3 |

### Step 2: Local Fast Decode (no external dependencies)

Try in order:

**2a. Standard error decode**

| Selector | Type | Decode Method |
|----------|------|---------------|
| `0x08c379a0` | `Error(string)` | `cast abi-decode "Error(string)" <data>` |
| `0x4e487b71` | `Panic(uint256)` | `cast abi-decode "Panic(uint256)" <data>` → lookup panic code |

Panic code reference:

| Code | Meaning |
|------|---------|
| 0x00 | generic compiler panic |
| 0x01 | assert failure |
| 0x11 | arithmetic overflow |
| 0x12 | division by zero |
| 0x21 | enum conversion |
| 0x22 | storage encoding |
| 0x31 | pop empty array |
| 0x32 | array out of bounds |
| 0x41 | too much memory |
| 0x51 | zero function pointer |

**2b. Selector lookup (`cast`)** — optional, skip if `cast` not installed

```bash
timeout 5 cast 4byte <selector>
```

If `cast` is unavailable or crashes, fall back to Step 3 API query.

### Step 3: External API Query

See `references/apis.md` for full endpoints and parameters.

**Query strategy**:

```
Has contract address? → 3a. ABI path (precise) → get ABI → Step 4
No contract address?  → 3b. Selector DB path (candidates) → get signature candidates
```

**3a. ABI path** (has contract address + chainId)

1. **Sourcify** (free, no key) → get full ABI JSON
2. **Etherscan v2** (needs key, free tier 3 req/s) → get ABI JSON
3. If proxy → get implementation address → re-query ABI

**3b. Selector DB path** (no contract address or ABI query failed)

1. **4byte.directory** API → may return multiple candidates
2. Multiple candidates → mark `confidence: low`, list all possibilities

### Step 4: Precise Decode

With ABI, use `cast` (if available):

```bash
# Decode revert data (needs ABI file)
cast decode-error <revert_data> --abi <abi_file>

# Decode calldata
cast decode-calldata <calldata> --abi <abi_file>

# Or decode with signature directly
cast calldata-decode "functionName(type1,type2)" <calldata>
```

Without ABI but with signature candidates:

```bash
cast abi-decode "functionName(type1,type2)" <data_without_selector>
```

## Output Format

From sd0xdev/sd0x-harness, MIT.

Signals

Stars
194
Forks
26
Open issues
5
Last commit (this folder)
Mar 9, 2026 (7 months ago)
Last release
Oct 6, 2026 (22 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from sd0xdev

Cite this page

contract-decode skill. Agent Mart. https://agentmart.dev/skills/sd0xdev-contract-decode (last updated 2026-10-24)