Skip to content

SDK - Implement native TRC20 currency type for TRON #1713

Description

@MantisClone

Problem

TRON TRC20 tokens (e.g., USDT, USDC on TRON) are classified under CURRENCY.ERC20 and differentiated only by their network field being tron or nile. This causes:

  • Broken request creation: After request-token-list#27 correctly set Tron currency type to TRC20, the SDK's CurrencyManager rejects it because it doesn't handle that type. A bandaid override was applied in the Request API to unblock usage.
  • Semantic inaccuracy: TRC20 is a TRON-native standard, not ERC20.
  • Scattered special-case handling: Multiple files check network === 'tron' || network === 'nile' within ERC20 code paths.
  • Confusion for integrators: "ERC20 on TRON" really means TRC20.
  • TronChains.ts incorrectly registers TRON chains under CURRENCY.ETH.

Impact

Tron request creation is currently broken without the API-level bandaid. The SDK stores incorrect currency types (ERC20 instead of TRC20) in the API database and Protocol (IPFS), which will cause issues when Tron is re-enabled on the frontend.

Proposed Solution

Introduce CURRENCY.TRC20 as a first-class currency type across the SDK packages:

  1. Core Types (packages/types) — Add TRC20 to CURRENCY enum, add TRC20Currency/TRC20CurrencyInput types, add TRC20_FEE_PROXY_CONTRACT payment network ID, remove TronChainName from ERC20Currency.network
  2. Currency Management (packages/currency) — Create TRC20 token list module, fix TronChains.ts to use CURRENCY.TRC20, update CurrencyManager to handle TRC20 in fromAddress, fromStorageCurrency, toStorageCurrency, validateAddress, getDefaultList
  3. Advanced Logic (packages/advanced-logic) — Create Trc20FeeProxyPaymentNetwork extension, remove TRON-specific logic from ERC20 extension, register TRC20 extension in AdvancedLogic
  4. Payment Detection (packages/payment-detection) — Add TRC20 section in PaymentNetworkFactory, remove TRON entries from ERC20 section, update TronFeeProxyPaymentDetector to use new TRC20 payment network ID
  5. Payment Processing (packages/payment-processor) — Add TRC20 guards, update trc20-fee-proxy.ts validation
  6. Request Client (packages/request-client.js) — Verify end-to-end with new CURRENCY.TRC20 type
  7. Testing — Unit tests for each package + integration test for create/pay/detect flow

Full implementation plan: https://www.notion.so/requestnetwork/Implementation-Steps-Native-TRC20-Currency-Type-for-TRON-3279821d9d8f80ebb7eaec66fa0dd92e

Considerations

  • Backward compatibility: Existing requests stored with ERC20 type for Tron tokens will need to still be readable. fromStorageCurrency should handle both old ERC20 and new TRC20 records for Tron networks.
  • API bandaid: The Request API currently overrides the token list to use ERC20 for Tron. This bandaid should be removed once this SDK fix is merged.
  • Frontend: Tron is disabled on the Dashboard frontend. It should not be re-enabled until this fix lands, otherwise new requests will have incorrect currency types in storage.
  • The changes are well-scoped and understood. Testing is the most time-consuming part — the SDK has decent test coverage that should help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions