Web3 core operations

From XSpoonAi/spoon-awesome-skill · View interactive version

Web3 core operations is an AI agent skill from the GitHub repository XSpoonAi/spoon-awesome-skill. Comprehensive ERC20 token allowance management system with real blockchain queries via RPC, supporting multiple approval strategies, security risk assessment, and batch operations.

How to use this skill

Skill file

ERC20 Allowance Manager - Skill Specification

Skill ID

erc20-allowance-manager

Category

Web3 Core Operations

Overview

Comprehensive ERC20 token allowance management system with real blockchain queries via RPC, supporting multiple approval strategies, security risk assessment, and batch operations.

Capabilities

Core Functions

  1. check - Query current allowance for token/spender pair
  2. approve - Set token allowance with multiple strategies
  3. revoke - Revoke token allowance (set to 0)
  4. batch_check - Check allowances for multiple spenders simultaneously

Approval Strategies

Input Format

Parameters

{
  "owner": "0x...",           // Token owner wallet address (required)
  "token": "0x...",           // ERC20 token contract address (required)
  "action": "check|approve|revoke|batch_check",  // Operation (default: check)
  "spender": "0x...",         // Spender contract address (required for check/approve/revoke)
  "amount": "1000.00",        // Amount to approve (optional, for exact/increase)
  "strategy": "exact",        // Approval strategy (default: exact)
  "spenders": ["0x...", "0x..."]  // Array of spenders (required for batch_check)
}

Output Format

Success Response (check action)

{
  "success": true,
  "action": "check",
  "owner": "0x...",
  "token": {
    "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "symbol": "USDC",
    "decimals": 6,
    "name": "USD Coin"
  },
  "spender": {
    "address": "0x68b3465833fb72B5A828cCEEB955439B22B36987",
    "name": "Uniswap V3 Router",
    "category": "dex",
    "risk_level": "low"
  },
  "allowance": {
    "amount": "1000000000",     // Raw wei/units
    "amount_decimal": 1000000.0, // Decimal-adjusted
    "is_unlimited": false,
    "expires_at": null
  },
  "risk_assessment": {
    "is_unlimited": false,
    "is_suspicious_spender": false,
    "balance_ratio": 0.5,
    "risk_level": "low",
    "recommendations": []
  },
  "block_number": 24398547,
  "rpc_used": "https://eth-mainnet.public.blastapi.io",
  "timestamp": "2026-02-06T20:36:00Z"
}

Success Response (approve action)

{
  "success": true,
  "action": "approve",
  "owner": "0x...",
  "token": {...},
  "spender": {...},
  "approval": {
    "amount": "1000000000",
    "amount_decimal": 1000.0,
    "strategy": "exact",
    "transaction": {
      "to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "data": "0x095ea7b3...",
      "gas_limit": 60000,
      "gas_price_gwei": 35.0,
      "estimated_cost_usd": 2.50
    }
  },
  "block_number": 24398547,
  "timestamp": "2026-02-06T20:36:00Z"
}

Success Response (batch_check action)

{
  "success": true,
  "action": "batch_check",
  "owner": "0x...",
  "token": {...},
  "results": [
    {
      "spender": {...},
      "allowance": {...},
      "risk_assessment": {...}
    }
  ],
  "summary": {
    "total_checked": 3,
    "unlimited_approvals": 1,
    "suspicious_spenders": 0
  },
  "timestamp": "2026-02-06T20:36:00Z"
}

Error Response

{
  "success": false,
  "error": "validation_error|connection_error|dependency_error|system_error",
  "message": "Human-readable error description"
}

Error Handling

| Error Type | Cause | Solution |

|-----------|-------|----------|

| dependency_error | web3.py not installed | Run pip install web3 |

| connection_error | RPC endpoint unreachable | Check ETHEREUM_RPC environment variable or RPC endpoint availability |

| validation_error | Invalid address/token format | Verify Ethereum address format (0x...{40 hex chars}) |

| system_error | Unexpected error | Check logs and retry |

Configuration

Environment Variables

ETHEREUM_RPC=https://eth-mainnet.public.blastapi.io  # Custom RPC endpoint (optional)

Known Spenders Registry

Token Registry

Dependencies

Required

Optional

Blockchain Integration

RPC Method

Smart Contracts

Validation Rules

  1. Address Validation: Must be 42-character hex string starting with 0x
  2. Amount Validation: Must be positive number or "unlimited"
  3. Strategy Validation: Must be one of: unlimited, exact, increase, safe
  4. Action Validation: Must be one of: check, approve, revoke, batch_check
  5. Batch Size: Maximum 50 spenders per batch_check

Security Considerations

  1. Risk Levels:
  1. Risk Flags:
  1. Best Practices:

Performance

Supported Networks

Currently supports Ethereum mainnet. Future versions may add:

Testing

Test Cases Included

Example Test

echo '{
  "owner": "0x1234567890123456789012345678901234567890",
  "spender": "0x68b3465833fb72B5A828cCEEB955439B22B36987",
  "token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  "action": "check"
}' | python3 scripts/main.py

Version History

Author

web3devzz

License

MIT

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.