This project implements a production-ready cross-chain atomic swap system that connects Tron blockchain to the 1inch Fusion+ ecosystem. The integration enables secure, trustless token swaps between Tron and 9+ other blockchains including Ethereum, Bitcoin, Stellar, Aptos, Sui, Polygon, Arbitrum, Optimism, and BSC.
Key Features:
- Atomic Security: Hash Time-Locked Contracts (HTLCs) ensure either both sides complete or both fail
- Dual-Chain Support: Native TRX and TRC20 token compatibility with cross-chain bridging
- Automated Relayers: TypeScript-based resolver service for seamless cross-chain coordination
- Production Ready: Deployed and tested on live testnets with real token transfers
- Multi-Hash System: SHA256 for Tron compatibility, KECCAK256 for Ethereum compatibility
- Economic Incentives: Safety deposits and protocol fees ensure reliable service
The system allows users to swap tokens across chains without centralized intermediaries. For example, a user can swap TRX for ETH by creating an order on Tron, having a relayer automatically create a matching order on Ethereum, and completing the atomic swap through cryptographic secret revelation.
Live Deployments:
- Tron Shasta Testnet:
TATH2MqmeKRDmDN4E5rjZkbnHLyc5LzWo7
- Resolver Contract:
TT5tSZkG1526s7N6qgpCVkZZY1wGgRrMrn
- Ethereum Sepolia:
0x067423CA883d8D54995735aDc1FA23c17e5b62cc
Smart Contract Architecture:
The core is built on two Solidity contracts deployed on Tron's TVM (Tron Virtual Machine):
-
TronAtomicSwap.sol - The main HTLC contract featuring:
- SHA256 hashlock verification (compatible with Tron's crypto primitives)
- Unix timestamp-based timelocks (1-24 hour windows)
- Support for both native TRX and TRC20 tokens
- Cross-chain bridge order management for 10 different blockchains
- Protocol fee collection (0.5%) and comprehensive admin controls
-
TronResolver.sol - The relayer coordination contract providing:
- Source/destination escrow deployment functions
- Safety deposit mechanisms to incentivize honest behavior
- Secret revelation and fund withdrawal coordination
- Order lifecycle management with timeout handling
Cross-Chain Coordination:
The system uses a dual-hash approach to handle different blockchain hash functions:
- Tron side uses SHA256 for hashlock verification
- Ethereum side uses KECCAK256 for hashlock verification
- Same 32-byte secret works on both chains, maintaining atomic guarantees
TypeScript Relayer Service:
Built with TronWeb and Ethers.js, the TronResolverService
provides:
- Real-time event monitoring on both Tron and Ethereum
- Automatic order processing and escrow deployment
- Secret revelation detection and claim execution
- Error handling and timeout management
Technologies Used:
- Solidity ^0.8.23: Smart contracts with latest security features
- TronWeb 5.3.2: Official Tron JavaScript SDK for blockchain interaction
- Ethers.js 6.15.0: Ethereum interaction and wallet management
- TronBox: Deployment and testing framework for Tron
- Node.js/TypeScript: Backend relayer service development
Notable Technical Innovations:
- Dual-Hash Compatibility: Solved the challenge of different hash functions across chains while maintaining atomicity
- Economic Security Model: Safety deposits ensure relayers fulfill their obligations
- Gas Optimization: Struct packing and efficient storage patterns minimize TRX costs
- Event-Driven Architecture: Real-time monitoring enables sub-minute cross-chain coordination
Testing & Production Readiness:
- Comprehensive test suite with unit and integration tests
- Live testnet deployments with verified transactions
- Real cross-chain swaps demonstrated between Tron Shasta and Ethereum Sepolia
- Production-grade error handling and security measures
The integration successfully bridges Tron's unique TVM environment with the broader DeFi ecosystem, enabling seamless asset transfers while maintaining the security guarantees that make atomic swaps trustless.