-
Notifications
You must be signed in to change notification settings - Fork 92
feat: add Tron smart contracts and deployment infrastructure #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fix/ci
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds comprehensive Tron support: CI workflow, TronBox config, TRC20/ERC20 test contracts and Truffle tests, TronWeb deployment/verification/util scripts, migrations and deployment records for Nile/mainnet, artifact & package updates, type/chain registry additions, and deployment documentation. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Script as Deploy Script
participant TronWeb
participant Chain as Tron Network
participant FS as File System
User->>Script: run deploy command (e.g. yarn tron:deploy:nile)
Script->>Script: validate env (TRON_PRIVATE_KEY, CONFIRM flags)
Script->>TronWeb: initialize with network fullHost
Script->>TronWeb: derive deployer address, check balance
TronWeb->>Chain: query account/balance
Chain-->>TronWeb: balance result
TronWeb-->>Script: deployer info
Script->>FS: load contract artifacts (ABI/bytecode)
loop per contract
Script->>TronWeb: deploy contract (ABI + bytecode + args)
TronWeb->>Chain: broadcast deployment tx
Chain-->>TronWeb: tx receipt + contract address
TronWeb-->>Script: deployment receipt
Script->>Script: record address
end
Script->>FS: write deployments/tron/{network}.json
FS-->>Script: persisted
Script->>User: print summary & verification instructions
sequenceDiagram
participant User
participant Script as Verify Script
participant FS as File System
participant TronWeb
participant Chain as Tron Network
User->>Script: run verify command (e.g. yarn tron:verify:nile)
Script->>Script: validate env (TRON_PRIVATE_KEY)
Script->>FS: read deployments/tron/nile.json
FS-->>Script: deployment addresses
loop per deployed contract
Script->>FS: load ABI from tron/build
FS-->>Script: ABI
Script->>TronWeb: instantiate contract at address
TronWeb->>Chain: query contract/account info
Chain-->>TronWeb: contract presence/metadata
TronWeb-->>Script: verification result
end
alt ERC20FeeProxy + TestTRC20 present
Script->>TronWeb: run test payment flow (approve + transferFromWithReferenceAndFee)
TronWeb->>Chain: broadcast test tx
Chain-->>TronWeb: receipt
TronWeb-->>Script: test outcome
end
Script->>User: print verification summary
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
Greptile OverviewGreptile SummaryAdds comprehensive Tron blockchain support to Request Network smart contracts, deploying the Key Changes:
Issues Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Payer
participant Proxy as ERC20FeeProxy
participant Token as TRC20 Token
participant Recipient
participant FeeAddr
Payer->>Token: 1. approve(Proxy, totalAmount)
Token-->>Payer: approved
Payer->>Proxy: 2. transferFromWithReferenceAndFee()
Proxy->>Token: 3. transferFrom(Payer, Recipient, paymentAmt)
Token-->>Proxy: transferred
alt feeAmount exists
Proxy->>Token: 4. transferFrom(Payer, FeeAddr, feeAmt)
Token-->>Proxy: transferred
end
Proxy-->>Proxy: 5. emit event
Proxy-->>Payer: complete
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 3 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@packages/smart-contracts/scripts/tron/deploy-test-token.js`:
- Around line 107-108: The deployment output path uses path.join to write to
'../deployments' which resolves relative to the scripts folder; update the
outputPath construction (the path.join call that sets outputPath) to point to
the correct tron deployments directory (e.g., '../../tron/deployments' or
path.join(__dirname, '..', '..', 'tron', 'deployments')) so the file is written
to the expected packages/smart-contracts/tron/deployments location; ensure the
variable outputPath and the fs.writeFileSync call remain unchanged except for
the corrected path join segments and create the deployments directory if it
doesn't exist before writing.
In `@packages/smart-contracts/scripts/tron/verify-deployment.js`:
- Around line 35-41: The loadDeployment function builds deploymentPath
incorrectly; change the path to point into the tron subfolder where files
actually live. Update the deploymentPath construction in loadDeployment (the
variable named deploymentPath inside the loadDeployment function) to reference
../deployments/tron/${network}.json (or equivalent path.join call including
'tron') so it loads deployments/tron/nile.json and deployments/tron/mainnet.json
instead of deployments/${network}.json.
In `@packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts`:
- Around line 185-198: The TypeScript error is caused because the deployment
keys 'tron' and 'nile' are not part of the VMChainName union used by the
artifact's deployment typing; update the type system so these declarative chains
are allowed by either (a) adding 'tron' and 'nile' to the VMChainName (or to
EvmChainName/NearChainName if appropriate) or (b) relaxing the artifact
deployment type to accept declarative chains (e.g., extend the union or
introduce a DeclarativeChainName and include it in the deployment typing);
update the types referenced by the artifact (VMChainName, EvmChainName,
NearChainName and the deployment property used in ERC20FeeProxy index.ts) so the
tron/nile entries compile.
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/smart-contracts/scripts/tron/deploy-mainnet.js`:
- Around line 167-168: The outputPath currently uses path.join(__dirname,
'../deployments/tron/mainnet.json') which resolves to scripts/deployments/...
because __dirname is scripts/tron; update the path calculation in
deploy-mainnet.js (the outputPath constant) to point to the package root
deployments folder (e.g. join or resolve using
'../../deployments/tron/mainnet.json' or use process.cwd() to build
'deployments/tron/mainnet.json') so the JSON is written to the correct
deployments/tron/mainnet.json location.
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
1 similar comment
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
1 similar comment
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
MantisClone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second review — LGTM, approving
Reviewed the full stack of Tron SDK PRs (#1687-#1691). This is the second review pass.
Resolved threads: All 12 review threads (6 critical path bugs, missing mkdirSync, missing artifact entry, etc.) were genuinely fixed. No threads need to be reopened.
Folder structure: Matches the distributed Tron folders approach we agreed on in the Jan 26 Tech Daily — Tron-specific code lives under each existing package (smart-contracts/tron/, payment-detection/src/tron/, etc.) rather than in a single consolidated folder. Consistent with how Near is structured.
Convention compliance: Naming follows existing patterns — TronChains (like NearChains), TronERC20FeeProxyPaymentDetector, TronInfoRetriever, tron key in erc20FeeProxyArtifact. Type system properly extended with TronChainName in VMChainName.
Test coverage: Sufficient for release given the system has been verified end-to-end on mainnet. Unit tests cover contract deployment, payment detection (happy path + errors), payment processing (allowance/balance/network validation), Hasura queries, and factory routing.
Minor non-blocking items (see inline comment below + comments on PRs #1690 and #1691):
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
988cd5c to
2374a54
Compare
21c3cc0 to
1ead8ab
Compare
- Add ERC20FeeProxy contract for Tron (TronBox compatible copy) - Add deployment scripts for Nile testnet and mainnet - Add TronBox configuration and build artifacts - Add CI workflow for Tron smart contracts - Add test contracts (TestTRC20, BadTRC20)
- Fix deploy-nile.js, deploy-mainnet.js, deploy-test-token.js - Output paths now correctly write to tron/deployments/ instead of scripts/deployments/
- Remove duplicate tron/ folder - Keep files in standard locations: - deployments/tron/ - migrations/tron/ - scripts/tron/ - src/contracts/tron/ - test/tron/ - Move TRON_DEPLOYMENT.md to package root - Update deploy scripts output paths accordingly
- Move TronBox build artifacts from tron-build/ to build/tron/ - Update tronbox-config.js contracts_build_directory accordingly - Aligns with Hardhat build structure under build/
- Remove build/tron/ from git tracking (like Hardhat builds) - Build artifacts should be generated, not committed - Run 'tronbox compile' to regenerate when needed
…ructure - Update CI workflow path triggers for new locations - Update CI workflow to check build/tron/ instead of tron-build/ - Update CI workflow to check deployments/tron/ instead of tron/deployments/ - Update package.json script paths from tron/scripts/ to scripts/tron/ - Update artifact paths in deploy scripts from tron-build to build/tron - Update TRON_DEPLOYMENT.md with correct paths
Replace the copy of ERC20FeeProxy.sol with a symlink to the main contract. This ensures consistency between Hardhat and TronBox builds.
- Add TronChainName type ('tron' | 'nile') to types package
- Include TronChainName in VMChainName for contract artifact support
- Remove tron/nile from DeclarativeChainName (now in TronChainName)
- Add Tron chain definitions to currency package
- Export TronChains from currency package
This fixes the CI build error where nile was not recognized as a VMChainName.
- Move tron contracts from src/contracts/tron/ to tron/contracts/ - This prevents Hardhat from finding duplicate ERC20FeeProxy contracts - Update tronbox-config.js to use new path - Update CI workflow paths accordingly
The test was still timing out at 60s due to Etherscan rate limiting.
- Fix ARTIFACTS_DIR to point to ../../tron/build instead of ../build/tron - Fix output paths to point to ../../deployments/tron instead of ../deployments/tron - Fix verify-deployment.js to use correct deployment and artifact paths
Add fs.mkdirSync with recursive: true to create the deployments/tron directory if it doesn't exist before writing the deployment file.
…ures Adjusted timeouts for several tests in request-client.js to accommodate slower operations in CI environments, ensuring stability and reducing flaky test results.
- Added TronChainName to the NativeEthCurrency type for better network representation. - Included Tron and Nile Tron definitions in the native currencies list. - Updated deployment scripts to correct artifact paths for Tron contracts.
1ead8ab to
fb04b23
Compare

Add Tron blockchain support with smart contract deployment and testing
This PR adds comprehensive support for the Tron blockchain to the Request Network protocol, including:
The implementation moves Tron from a declarative chain to a fully supported VM chain with smart contract capabilities, enabling payment requests with TRC20 tokens like USDT and USDC.
Summary by CodeRabbit
New Features
Documentation
Chores
Tests
Closes RequestNetwork/private-issues#222
Closes RequestNetwork/private-issues#230
Closes RequestNetwork/private-issues#231
Closes RequestNetwork/private-issues#232