-
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: master
Are you sure you want to change the base?
Conversation
- 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)
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 | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
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.
- Fix deploy-nile.js, deploy-mainnet.js, deploy-test-token.js - Output paths now correctly write to tron/deployments/ instead of scripts/deployments/
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
- 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
✅ 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. |
- 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/
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:
|
- Remove build/tron/ from git tracking (like Hardhat builds) - Build artifacts should be generated, not committed - Run 'tronbox compile' to regenerate when needed
✅ 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:
|
✅ 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:
|
- 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
✅ 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:
|
The test was still timing out at 60s due to Etherscan rate limiting.
✅ 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:
|
- 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
✅ 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-test-token.js`:
- Around line 107-109: The script computes outputPath and calls fs.writeFileSync
to save deploymentInfo but doesn’t ensure the target directory exists, causing
ENOENT if deployments/tron/ is missing; update the deployment save logic around
outputPath (the block that writes deploymentInfo using fs.writeFileSync) to
create the directory first (e.g., use fs.mkdirSync or fs.promises.mkdir with {
recursive: true } on path.dirname(outputPath)) before writing, then proceed to
JSON.stringify(deploymentInfo, null, 2) and write the file.
✅ 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:
|
Add fs.mkdirSync with recursive: true to create the deployments/tron directory if it doesn't exist before writing the deployment file.
✅ 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:
|
The test 'can disable and enable the get the balance of a request' was timing out at 60s in slow CI environments. Increased to 120s to match other similar tests in the file.
✅ 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.
Looks good to me so far.
Reviewed with Claude Code Opus 4.5

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
✏️ Tip: You can customize this high-level summary in your review settings.
Closes RequestNetwork/private-issues#222
Closes RequestNetwork/private-issues#230
Closes RequestNetwork/private-issues#231
Closes RequestNetwork/private-issues#232