Skip to main content

Overview

x402x-detector automatically identifies an ERC-20 token’s “gasless payment capability” — covering EIP-2612 Permit, EIP-3009, and Permit2 — and handles common proxy patterns (EIP-1967 / UUPS). Results are cached for millisecond-level access.

Key features

  • Full detection: Permit / EIP-3009 / Permit2
  • Proxy handling: EIP-1967 / UUPS / custom implementation
  • High performance: 2–5s on first run, <1ms with cache hits
  • Simple API: detect / getRecommendedMethod / initialize

Install

Quick start

Examples

Create detect.ts, core logic:

Detection details

  • Permit: permit() / DOMAIN_SEPARATOR() / nonces(owner)
  • EIP-3009: transferWithAuthorization() / authorizationState()
  • Permit2: allowance(user, token, spender)
Proxy contracts: automatically read the implementation address (EIP-1967 storage slot / UUPS proxiableUUID(), etc.)
  • Warm up on startup: detector.initialize([USDC, DAI, ...])
  • Choose a recommended type: detector.getRecommendedMethod(token)
  • For non-standard proxies, manually verify implementation address

API reference (condensed)

For more types and return structures, see:
  • Parameters: /en/parameters-responses/detector/parameters
  • Responses: /en/parameters-responses/detector/responses

Performance and optimization

  • Warm up hot tokens: initialize([tokens]) on service startup
  • Parallel detection: prefer initialize for batch parallel detection
  • Detect on demand: slow the first time, fast afterwards (cache hits)
  • Periodic refresh: re-detect popular tokens on a schedule

Resources

  • Source: https://github.com/WTFLabs-WTF/x402x/tree/main/typescript/packages/x402x-detector
  • Issues: https://github.com/WTFLabs-WTF/x402x/issues