Skip to content

feat: add Tron payment processor support - #1690

Merged
rodrigopavezi merged 5 commits into
masterfrom
feat/tron-payment-processor
Feb 12, 2026
Merged

feat: add Tron payment processor support#1690
rodrigopavezi merged 5 commits into
masterfrom
feat/tron-payment-processor

Conversation

@rodrigopavezi

@rodrigopavezirodrigopavezi commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Description of the changes

Added support for Tron blockchain payments in the payment-processor package. This implementation enables TRC20 token payments through the ERC20 Fee Proxy contract on Tron networks.

The changes include:

  • New tron-fee-proxy.ts module with functions for paying requests on Tron:

    • payTronFeeProxyRequest - Process payments with TRC20 tokens
    • approveTronFeeProxyRequest - Approve token spending
    • hasSufficientTronAllowance - Check token allowance
    • hasSufficientTronBalance - Verify token balance
    • getTronPaymentInfo - Get payment details
  • New utils-tron.ts module with Tron-specific utilities:

    • TronWeb type definitions
    • Address validation
    • Contract interaction helpers
    • Token approval and payment processing
  • Comprehensive test coverage for all new functionality

  • Exports for the new modules in the package index


Closes RequestNetwork/private-issues#234

Summary by CodeRabbit

  • New Features
    • Added TRON network support for fee proxy payments, including balance verification, allowance checks, and token approvals
    • Support for TRON mainnet and Nile testnet networks
    • New TRC20 fee proxy payment workflow for TRON transactions

@coderabbitai

coderabbitaiBot commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Adds TRON network support to the SDK's payment processing pipeline. Includes TRON TRC20 utility functions, fee proxy payment workflows, integration with payment detection layer, and comprehensive test coverage. Also updates CI/CD configuration to wait for Graph node readiness before deployment.

Changes

Cohort / File(s)Summary
CI/CD Configuration
.circleci/config.yml
Adds polling loop in Subgraph deployment step to check Graph node readiness on http://localhost:8020 for up to 30 iterations with 2-second intervals before proceeding with cloning and dependency installation.
Payment Detection TRON Integration
packages/payment-detection/src/erc20/fee-proxy-contract.ts
Extends getTheGraphInfoRetriever to support TRON chains by importing TronChains and TronInfoRetriever, updating return type signature, and adding conditional branch for TRON chain detection with appropriate type casting.
Payment Processor TRON Implementation
packages/payment-processor/src/payment/utils-tron.ts, packages/payment-processor/src/payment/tron-fee-proxy.ts, packages/payment-processor/src/index.ts
Introduces comprehensive TRON payment processing: utility module with TronWeb abstraction, address validation, allowance/balance checks, approval and fee proxy payment execution; high-level fee proxy workflow functions (approval, payment, info retrieval); and public API exports for TRON functionality.
Payment Processor TRON Tests
packages/payment-processor/test/payment/tron-fee-proxy.test.ts
Comprehensive test suite covering payment execution paths, approval flows, balance/allowance validation, address validation, proxy address resolution across TRON networks, and edge cases for non-TRON networks.

Sequence Diagram(s)

sequenceDiagram
participant User as User/Client
participant Processor as Payment Processor
participant TronWeb as TronWeb Library
participant TronNet as TRON Network
participant Contract as ERC20 Fee Proxy Contract
User->>Processor: payTronFeeProxyRequest(request, tronWeb)
Processor->>Processor: Validate TRON network support
Processor->>Processor: Validate request & extract payment info
Processor->>TronWeb: getTronAllowance(tokenAddress)
TronWeb->>Contract: Read allowance
Contract-->>TronWeb: Current allowance
TronWeb-->>Processor: Allowance value
alt Insufficient Allowance
Processor->>Processor: Compute total amount (payment + fee)
Processor->>TronWeb: approveTrc20(tokenAddress, amount)
TronWeb->>Contract: approve(proxyAddress, amount)
Contract-->>TronWeb: Approval transaction result
TronWeb-->>Processor: Transaction ID
Processor->>TronNet: Wait for confirmation
TronNet-->>Processor: Confirmed
end
Processor->>TronWeb: isTronAccountSolvent(tokenAddress, totalAmount)
TronWeb->>Contract: balanceOf(senderAddress)
Contract-->>TronWeb: Balance
TronWeb-->>Processor: Solvent status
Processor->>TronWeb: processTronFeeProxyPayment(...)
TronWeb->>Contract: transferFromWithReferenceAndFee(...)
Contract-->>TronWeb: Payment transaction result
TronWeb-->>Processor: Transaction ID
Processor->>TronNet: Wait for confirmation
TronNet-->>Processor: Confirmed
Processor-->>User: Payment completion result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/tron-payment-processor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Added comprehensive Tron blockchain payment support to the payment-processor package, enabling TRC20 token payments through the ERC20 Fee Proxy contract.

Key Changes:

  • Implemented tron-fee-proxy.ts with core payment functions: payTronFeeProxyRequest, approveTronFeeProxyRequest, hasSufficientTronAllowance, hasSufficientTronBalance, and getTronPaymentInfo
  • Created utils-tron.ts with Tron-specific utilities including TronWeb type definitions, address validation (isValidTronAddress), and contract interaction helpers
  • Added comprehensive test coverage in tron-fee-proxy.test.ts with proper mocking and edge case testing
  • Leveraged existing ERC20FeeProxy smart contract artifact structure with Tron-specific deployments (mainnet: TCUDPYnS9dH3WvFEaE7wN7vnDa51J4R4fd, testnet: THK5rNmrvCujhmrXa5DB1dASepwXTr9cJs)
  • Added tronweb@5.3.2 and ethers@6.16.0 dependencies to support Tron integration

Implementation Details:

  • Payment flow follows the same pattern as EVM chains: validate network → check allowance → verify balance → execute payment
  • Uses TronWeb's contract API to interact with TRC20 tokens and the ERC20FeeProxy contract
  • Validates Tron addresses using Base58Check format (34 characters starting with 'T')
  • Properly formats payment references with 0x prefix for contract calls
  • Fee limits set to 100 TRX for approvals and 150 TRX for proxy payments

Confidence Score: 4/5

  • This PR is safe to merge with standard review
  • Implementation follows established patterns from EVM payment processors, includes comprehensive test coverage, and properly validates inputs. Minor points: error handling in utility functions returns default values which could mask network issues, and the test timeout increase suggests potential performance concerns worth monitoring
  • Pay close attention to utils-tron.ts error handling in isTronAccountSolvent and getTronAllowance functions which catch and suppress errors by returning default values

Important Files Changed

FilenameOverview
packages/payment-processor/src/payment/tron-fee-proxy.tsadds Tron payment processor functions with proper validation, allowance/balance checks, and payment execution
packages/payment-processor/src/payment/utils-tron.tsimplements Tron-specific utilities including TronWeb types, address validation, contract interactions, and payment processing
packages/payment-processor/test/payment/tron-fee-proxy.test.tscomprehensive test coverage for Tron payment processor functions with proper mocking and edge case testing
packages/payment-processor/src/index.tsexports new Tron modules for public API
yarn.lockadds tronweb@5.3.2 and related dependencies (ethers@6.16.0, axios@1.13.2, etc.)

Sequence Diagram

sequenceDiagram
participant Client
participant TronFeeProxy as tron-fee-proxy.ts
participant UtilsTron as utils-tron.ts
participant TronWeb
participant TRC20Contract as TRC20 Token
participant ProxyContract as ERC20FeeProxy
Note over Client,ProxyContract: Approval Flow
Client->>TronFeeProxy: approveTronFeeProxyRequest(request, tronWeb)
TronFeeProxy->>TronFeeProxy: Validate network (TronChains)
TronFeeProxy->>TronFeeProxy: Calculate total amount (payment + fee)
TronFeeProxy->>UtilsTron: approveTrc20(tronWeb, tokenAddress, network, amount)
UtilsTron->>UtilsTron: getERC20FeeProxyAddress(network)
UtilsTron->>TronWeb: contract(TRC20_ABI, tokenAddress)
TronWeb-->>UtilsTron: TRC20 contract instance
UtilsTron->>TRC20Contract: approve(proxyAddress, amount).send()
TRC20Contract-->>UtilsTron: Transaction result
UtilsTron->>UtilsTron: callback.onHash(txHash)
UtilsTron-->>TronFeeProxy: txHash
TronFeeProxy-->>Client: txHash
Note over Client,ProxyContract: Payment Flow
Client->>TronFeeProxy: payTronFeeProxyRequest(request, tronWeb)
TronFeeProxy->>TronFeeProxy: Validate network (TronChains)
TronFeeProxy->>TronFeeProxy: validateRequest(ERC20_FEE_PROXY_CONTRACT)
TronFeeProxy->>TronFeeProxy: getRequestPaymentValues()
TronFeeProxy->>TronFeeProxy: validatePaymentReference()
TronFeeProxy->>UtilsTron: isValidTronAddress(paymentAddress)
UtilsTron-->>TronFeeProxy: validation result
TronFeeProxy->>UtilsTron: getTronAllowance(tronWeb, tokenAddress, network)
UtilsTron->>TronWeb: contract(TRC20_ABI, tokenAddress)
TronWeb-->>UtilsTron: contract instance
UtilsTron->>TRC20Contract: allowance(owner, spender).call()
TRC20Contract-->>UtilsTron: allowance amount
UtilsTron-->>TronFeeProxy: BigNumber allowance
alt Insufficient Allowance
TronFeeProxy-->>Client: Error: Insufficient TRC20 allowance
end
TronFeeProxy->>UtilsTron: isTronAccountSolvent(tronWeb, tokenAddress, amount)
UtilsTron->>TronWeb: contract(TRC20_ABI, tokenAddress)
TronWeb-->>UtilsTron: contract instance
UtilsTron->>TRC20Contract: balanceOf(owner).call()
TRC20Contract-->>UtilsTron: balance
UtilsTron-->>TronFeeProxy: true/false
alt Insufficient Balance
TronFeeProxy-->>Client: Error: Insufficient TRC20 token balance
end
TronFeeProxy->>UtilsTron: processTronFeeProxyPayment(params)
UtilsTron->>UtilsTron: Validate all addresses
UtilsTron->>UtilsTron: getERC20FeeProxyAddress(network)
UtilsTron->>TronWeb: contract(ERC20_FEE_PROXY_ABI, proxyAddress)
TronWeb-->>UtilsTron: proxy contract instance
UtilsTron->>UtilsTron: Format payment reference (add 0x prefix)
UtilsTron->>ProxyContract: transferFromWithReferenceAndFee(token, to, amount, ref, feeAmount, feeAddress).send()
ProxyContract->>TRC20Contract: transferFrom(payer, recipient, amount)
TRC20Contract-->>ProxyContract: success
alt Fee > 0
ProxyContract->>TRC20Contract: transferFrom(payer, feeRecipient, feeAmount)
TRC20Contract-->>ProxyContract: success
end
ProxyContract-->>UtilsTron: Transaction result
UtilsTron->>UtilsTron: callback.onHash(txHash)
UtilsTron-->>TronFeeProxy: txHash
TronFeeProxy-->>Client: txHash
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch from 853297e to 5bb6ef7CompareJanuary 27, 2026 01:49
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch 2 times, most recently from 5ac332a to 984a642CompareJanuary 27, 2026 01:53
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch 2 times, most recently from 3c7d77f to 816af51CompareJanuary 27, 2026 01:56
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from 984a642 to 41e33e8CompareJanuary 27, 2026 01:56
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch from 816af51 to fc1128cCompareJanuary 27, 2026 01:58
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from 41e33e8 to d03f1dbCompareJanuary 27, 2026 01:58
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch from fc1128c to cf070e9CompareJanuary 27, 2026 02:02
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from d03f1db to 7d73139CompareJanuary 27, 2026 02:02
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch from cf070e9 to 62f2685CompareJanuary 27, 2026 02:15
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch 2 times, most recently from 6dce563 to dbed330CompareJanuary 27, 2026 02:25
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch 2 times, most recently from 3bf2428 to f06892cCompareJanuary 27, 2026 02:34
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch 2 times, most recently from 1797a69 to d5e25dfCompareJanuary 27, 2026 02:39
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch from f06892c to 8456f0aCompareJanuary 27, 2026 02:39
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch 2 times, most recently from b5ce760 to 60d3c03CompareJanuary 27, 2026 02:50
@MantisClone
MantisClone self-requested a review February 10, 2026 15:10

@MantisCloneMantisClone left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — well-typed TronWeb interface, good validation (address format, balance, allowance). One minor non-blocking comment about fee limits (see inline).

Comment threadpackages/payment-processor/src/payment/utils-tron.ts Outdated
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch from cecfc7e to 6c8cb20CompareFebruary 11, 2026 13:29
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from ceec59f to 10ddce5CompareFebruary 11, 2026 13:29
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch from 6c8cb20 to 938afcaCompareFebruary 11, 2026 13:37
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from 10ddce5 to 362dbbcCompareFebruary 11, 2026 13:37
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch from 938afca to c8c4b67CompareFebruary 11, 2026 14:39
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from 5ec56fe to b8f3840CompareFebruary 11, 2026 14:39
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from b8f3840 to 55c4451CompareFebruary 11, 2026 14:48
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch 2 times, most recently from 1408a38 to 559e872CompareFebruary 11, 2026 14:53
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from 55c4451 to 2d1ffbcCompareFebruary 11, 2026 14:53
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch from 559e872 to 96f878eCompareFebruary 11, 2026 16:40
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch 2 times, most recently from 91553a4 to 8315931CompareFebruary 11, 2026 16:42
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-detection branch from 96f878e to 35cc88dCompareFebruary 11, 2026 16:42
@rodrigopaveziGraphite App

rodrigopavezi commented Feb 12, 2026

Copy link
Copy Markdown
ContributorAuthor

Merge activity

  • Feb 12, 1:06 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 12, 1:15 PM UTC: Graphite rebased this pull request as part of a merge.
  • Feb 12, 1:15 PM UTC: @rodrigopavezi merged this pull request with Graphite.

@rodrigopavezi
rodrigopavezi changed the base branch from feat/tron-payment-detection to graphite-base/1690February 12, 2026 13:12
@rodrigopavezi
rodrigopavezi changed the base branch from graphite-base/1690 to masterFebruary 12, 2026 13:13
- Add tron-fee-proxy payment functions
- Add Tron utility functions for transaction handling
- Add unit tests for Tron payment processing
- Update request-client tests for Tron support
Add a retry loop to wait for the Graph node to be ready on port 8020
before attempting to create and deploy the subgraph.
- Introduce DEFAULT_TRON_APPROVAL_FEE_LIMIT and DEFAULT_TRON_PAYMENT_FEE_LIMIT constants for TRC20 transactions.
- Update approveTrc20 and processTronFeeProxyPayment functions to use dynamic fee limits instead of hardcoded values.
- Update ERC20FeeProxyPaymentDetector to support TronChainName by adding TronInfoRetriever.
- Enhance the getTheGraphInfoRetriever method to handle Tron payment chains.
- Change import statement for TronInfoRetriever to reflect new file structure in the tron directory.
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from 8315931 to 700e046CompareFebruary 12, 2026 13:14
@rodrigopavezi
rodrigopavezi merged commit 23fd8e3 into masterFeb 12, 2026
4 of 7 checks passed
@rodrigopavezi
rodrigopavezi deleted the feat/tron-payment-processor branch February 12, 2026 13:15
@rodrigopavezirodrigopavezi mentioned this pull request Feb 16, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rodrigopavezi@MantisClone@aimen74