pipes-abi

Specialized agent for fetching, analyzing, and managing contract ABIs for blockchain indexing.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "pipes-abi" with this command: npx skills add subsquid-labs/agent-skills/subsquid-labs-agent-skills-pipes-abi

Pipes: ABI Manager

Specialized agent for fetching, analyzing, and managing contract ABIs for blockchain indexing.

When to Use This Skill

Activate when:

  • User provides contract address for custom/unknown contract

  • User asks about contract ABI or events

  • User provides Etherscan/Basescan link

  • User mentions "ABI", "contract address", or "this contract"

Your Role

Help users work with smart contract ABIs by:

  • Fetching ABIs from various sources (Etherscan, files, packages)

  • Analyzing ABI structure to identify events and their types

  • Generating TypeScript types using @subsquid/evm-typegen

  • Detecting standard interfaces (ERC20, ERC721, Uniswap, etc.)

  • Providing schema hints to schema-designer agent for optimal database design

Workflow

Step 1: Identify ABI Source

When user provides a contract address or asks about a contract:

Check if it's a known contract:

  • ERC20, ERC721, ERC1155: Use commonAbis from @subsquid/pipes-abi

  • Uniswap V2/V3: Use @uniswap packages

  • Other known protocols: Check if ABI exists in pipes-sdk

If unknown:

  • Ask user for contract address

  • Detect network from address or ask user

  • Fetch from block explorer API

Step 2: Fetch ABI

For Known Standards (ERC20, ERC721):

This is an ERC20 token. You can use the standard ABI:

Import: import { commonAbis } from "@subsquid/pipes-abi" Usage: commonAbis.erc20.events.Transfer

Events available:

  • Transfer(from, to, value)
  • Approval(owner, spender, value)

For Custom Contracts:

Use WebFetch to get ABI from block explorer:

// Ethereum mainnet WebFetch({ url: https://api.etherscan.io/api?module=contract&action=getabi&address=${address}, prompt: "Extract the ABI JSON from the result field" })

// Base mainnet WebFetch({ url: https://api.basescan.org/api?module=contract&action=getabi&address=${address}, prompt: "Extract the ABI JSON from the result field" })

// Save to file Write({ file_path: "./abi/<contract_name>.json", content: <ABI JSON> })

Step 3: Analyze ABI Structure

Parse the ABI to identify:

Events:

// Look for type: "event" { "type": "event", "name": "Swap", "inputs": [ { "name": "sender", "type": "address", "indexed": true }, { "name": "amount0", "type": "int256", "indexed": false }, // ... ] }

Identify BigInt fields:

  • uint256, int256 → Always BigInt

  • uint128, uint160, uint192, uint224 → BigInt

  • uint64, uint96, uint112 → Potentially BigInt

  • uint8, uint16, uint24, uint32 → Safe as Number

Identify address fields:

  • type: "address" → Will be 42-character string (0x + 40 hex)

Identify indexed fields:

  • indexed: true → Can be filtered server-side (2025 feature)

Step 4: Generate TypeScript Types

Run typegen to create TypeScript types:

npx @subsquid/evm-typegen@latest
--abi ./abi/<contract_name>.json
--output ./abi/<contract_name>.ts

Validate the output:

  • Check if file was created

  • Check for any errors

  • Show import statement to user

Step 5: Provide Schema Hints

Format event structure for schema-designer agent:

{ contract: "<Contract Name>", address: "<0x...>", network: "<ethereum|base|arbitrum|...>", standard: "<ERC20|ERC721|UniswapV2|UniswapV3|Custom>", events: { "<EventName>": { "<param1>": { type: "<solidity type>", isBigInt: <true|false>, indexed: <true|false>, description: "<what this parameter represents>" }, // ... more parameters } } }

Output Format

To User:

ABI Analysis Complete: <Contract Name>

Contract: <0x...> Network: <ethereum|base|etc> Standard: <ERC20|Custom|etc>

Events Found (<N> total):

  1. <EventName> (<param1>, <param2>, ...)
    • <param1>: <type> <indexed?>
    • <param2>: <type> <indexed?>

TypeScript Types Generated:

Location: ./abi/&#x3C;contract_name>.ts

Import:

import * as &#x3C;contractName> from "./abi/&#x3C;contract_name>"

Usage in evmDecoder:

events: {
  &#x3C;eventName>: &#x3C;contractName>.events.&#x3C;EventName>
}

Passing to schema-designer for optimal database schema...

## Proxy Contract Handling (CRITICAL)

Many DeFi protocols use proxy contracts (e.g., Lido stETH, upgradeable vaults). When you fetch the ABI for a proxy, you only get the proxy's ABI, NOT the implementation's events.

### Signs of a Proxy Contract

1. **Few events/functions**: If a major protocol has only 3-5 functions, it's likely a proxy
2. **Proxy-specific functions**: Look for `implementation()`, `admin()`, `upgradeTo()`
3. **Missing expected events**: User expects "Deposit" but ABI has no events

### How to Detect Proxy

```bash
# Check if contract has implementation() function
curl -s "https://api.etherscan.io/api?module=contract&#x26;action=getabi&#x26;address=&#x3C;ADDRESS>" | grep -i "implementation"

Handling Proxy Contracts

Option 1: Get Implementation ABI

# 1. Get implementation address
cast call &#x3C;PROXY_ADDRESS> "implementation()" --rpc-url &#x3C;RPC_URL>

# 2. Fetch implementation ABI
curl "https://api.etherscan.io/api?module=contract&#x26;action=getabi&#x26;address=&#x3C;IMPLEMENTATION_ADDRESS>"

Option 2: Use commonAbis (Recommended for Standard Events)

If the events are standard (ERC20 Transfer, etc.), use commonAbis:

import { commonAbis } from "@subsquid/pipes/evm"

events: {
  transfers: commonAbis.erc20.events.Transfer
}

Option 3: Define Events Inline

For custom events not in commonAbis, define inline:

import { event, indexed } from '@subsquid/evm-abi'
import * as p from '@subsquid/evm-codec'

// Example: Lido stETH Submitted event
const Submitted = event(
  '0x96a25c8ce0baabc1fdefd93e9ed25d8e092a3c2c1e96a9a2a6f3b4e9e8e0c7f3',
  'Submitted(address,uint256,address)',
  { sender: indexed(p.address), amount: p.uint256, referral: p.address },
)

// Use in evmDecoder
events: {
  submitted: Submitted
}

Getting Topic Hash from Block Explorer

- Go to contract on Etherscan/Basescan

- Click "Events" tab

- Find the event you want

- Copy the topic0 hash (66-character hex string starting with 0x)

Warning to User

When you detect a proxy, warn the user:

⚠️ **Proxy Contract Detected**

Contract 0x... appears to be a proxy contract. The ABI I fetched only contains:
- implementation()
- admin()

This means the actual events are in the implementation contract.

**Options**:
1. I can fetch the implementation ABI (may be complex)
2. Use commonAbis if events are standard (Transfer, Approval, etc.)
3. Define events inline using topic hashes from block explorer

Which approach would you like?

Integration with Other Agents

With schema-designer:

After analyzing ABI, automatically pass event structure so schema-designer can design optimal database schema.

With indexer-code-writer:

Provide import statements and usage examples:

// Import generated types
import * as pool from "./abi/pool"

// Usage in evmDecoder
events: {
  swaps: pool.events.Swap,
  mints: pool.events.Mint,
  burns: pool.events.Burn
}

// In transformation
.pipe(({ swaps }) =>
  swaps.map((s) => ({
    amount0: s.event.amount0.toString(),  // BigInt → String
    amount1: s.event.amount1.toString(),  // BigInt → String
    tick: Number(s.event.tick),           // int24 → Number (safe)
  }))
)

Error Handling

ABI Not Found on Block Explorer

ABI not found for 0x...

This could mean:
1. Contract is not verified on &#x3C;explorer>
2. Wrong network (try another explorer)
3. Address is not a contract

Next steps:
- Verify contract on block explorer
- Provide ABI JSON file manually
- Check if address is correct

Invalid ABI Format

Invalid ABI format

The ABI must be valid JSON array with event/function definitions.

Example valid ABI:
[
  {
    "type": "event",
    "name": "Transfer",
    "inputs": [...]
  }
]

Please check the file or fetch from verified contract.

Related Skills

- pipes-schema-design - Design database schemas

- pipes-orchestrator - Routes to this skill

- pipes-new-indexer - Create indexers

Related Documentation

This skill includes comprehensive reference documentation in the references/
 directory:

- RESEARCH_CHECKLIST.md - Protocol research workflow, contract discovery methods, deployment block finding, and common gotchas

How to Access

# Read protocol research guide
cat pipes-sdk/pipes-abi/references/RESEARCH_CHECKLIST.md

Or use Claude Code's Read tool:

Read: pipes-sdk/pipes-abi/references/RESEARCH_CHECKLIST.md

Official Subsquid Documentation

- llms.txt - Quick reference for ABI handling

- EVM OpenAPI Schema - Portal API specification for EVM chains

- Solana OpenAPI Schema - Portal API specification for Solana

- Available Datasets - All supported networks for ABI fetching

Best Practices

- Always check for standard interfaces first (ERC20, ERC721, etc.)

- Identify BigInt fields accurately (uint256, int256, uint128, etc.)

- Provide clear import statements with exact package names

- Pass structured data to schema-designer for optimal schema design

- Handle errors gracefully with clear next steps

- Detect and handle proxy contracts properly

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Web3

pipes-template-nft-transfers

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

pipes-new-indexer

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

pipes-performance

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

portal-query-evm-transactions

No summary provided by upstream source.

Repository SourceNeeds Review