π Trustless atomic swaps between Base Sepolia and Etherlink testnets
Fusion+ is a cutting-edge proof-of-concept blockchain application that enables atomic, trustless token swaps between different blockchain networks without relying on centralized bridges or intermediaries. Currently supporting Base Sepolia and Etherlink testnets, this project demonstrates how cryptographic primitives can solve one of DeFi's biggest challenges: secure cross-chain asset transfers.
Traditional cross-chain swaps suffer from:
- π Trust Requirements: Relying on centralized bridges
- β‘ Security Risks: Vulnerability to bridge hacks and exploits
- π Timing Issues: Risk of funds being permanently locked
- πΈ High Fees: Expensive intermediary costs
- Hashlock Mechanism: Uses SHA-256 hashes for secure secret-based unlocking
- Timelock Safety: Built-in expiration prevents permanent fund loss
- Atomic Guarantees: Either both sides complete or neither does
- Base Sepolia: Ethereum Layer 2 testnet integration
- Etherlink: Tezos-based blockchain support
- Extensible Design: Architecture supports additional chains
- Scalable Deployment: Factory contracts create individual escrows
- Gas Optimization: Efficient contract instantiation
- Modular Architecture: Clean separation of concerns
- No Bridge Dependencies: Eliminates bridge-related vulnerabilities
- Trustless Design: No need for trusted third parties
- Timeout Protection: Automatic fund recovery mechanisms
π€ Maker creates swap order:
βββ Source Chain: Base Sepolia
βββ Offer: 100 USDC
βββ Target Chain: Etherlink
βββ Want: 95 DAI
π€ Taker accepts order:
βββ Generates shared secret
βββ Creates cryptographic hashlock
βββ Initiates escrow deployment
π Factory Contracts Deploy:
βββ Base Sepolia Escrow
β βββ Locks 100 USDC
β βββ Hashlock: 0xabc123...
β βββ Timelock: 24 hours
βββ Etherlink Escrow
βββ Locks 95 DAI
βββ Same Hashlock: 0xabc123...
βββ Timelock: 12 hours
π Settlement Process:
βββ Taker reveals secret on Etherlink β Claims 95 DAI
βββ Secret becomes public on blockchain
βββ Maker uses revealed secret on Base β Claims 100 USDC
βββ β
Swap Complete!
β° Fallback: If timeout expires β Both parties reclaim funds
- Language: Solidity ^0.8.0
- Framework: Foundry
- Pattern: Factory + Implementation contracts
- Security: Hashlock + Timelock mechanisms
- Cross-Chain SDK: 1inch Cross-Chain SDK
- Blockchain Interaction: Ethers.js
- Language: TypeScript
- Package Manager: PNPM
| Network | Type | RPC | Factory Contract |
|---|---|---|---|
| Base Sepolia | L2 Testnet | Custom RPC | 0x... |
| Etherlink | Tezos-based | Custom RPC | 0x... |
# Required tools
- Node.js v18+
- PNPM
- Foundry
- Git# Clone the repository
git clone https://github.com/Shashwat-Nautiyal/-Fusion.git
cd Fusion
# Install dependencies
pnpm install
# Install Foundry dependencies
forge installCreate a .env file:
# Network RPCs
BASE_SEPOLIA_RPC=your_base_sepolia_rpc_url
ETHERLINK_RPC=your_etherlink_rpc_url
# Private Keys (for testing only!)
PRIVATE_KEY_1=your_test_private_key_1
PRIVATE_KEY_2=your_test_private_key_2
# Factory Contract Addresses
BASE_FACTORY_ADDRESS=0x...
ETHERLINK_FACTORY_ADDRESS=0x...# Compile contracts
forge build
# Run comprehensive test suite
pnpm test
# Run specific test
forge test -vvvcontract EscrowFactory {
function createEscrow(
bytes32 hashlock,
uint256 timelock,
address recipient,
uint256 amount
) external returns (address escrow);
}contract Escrow {
// Hashlock: Cryptographic security
bytes32 public hashlock;
// Timelock: Time-based safety
uint256 public timelock;
// Claim with secret
function claim(string calldata secret) external;
// Reclaim after timeout
function reclaim() external;
}- One-way Function: SHA-256 ensures secret cannot be reverse-engineered
- Atomic Revelation: Secret revealed on one chain enables claim on other
- Cryptographic Proof: Mathematical guarantee of authenticity
- Asymmetric Timeouts: Different expiration times prevent deadlocks
- Automatic Recovery: Funds automatically recoverable after timeout
- Fail-Safe Design: System defaults to returning funds to owners
- Completion Reward: Both parties benefit from successful completion
- Time Pressure: Earlier timeout encourages prompt execution
- Risk Mitigation: No permanent fund loss possible
tests/
βββ unit/
β βββ EscrowFactory.t.sol # Factory functionality
β βββ Escrow.t.sol # Individual escrow logic
β βββ Hashlock.t.sol # Cryptographic primitives
βββ integration/
β βββ CrossChainSwap.t.sol # End-to-end swap flows
β βββ TimeoutScenarios.t.sol # Edge case handling
βββ e2e/
βββ FullSwapCycle.t.sol # Complete user journey- β Happy Path: Successful swap completion
- β Timeout Scenarios: Fund recovery mechanisms
- β Invalid Secrets: Security boundary testing
- β Cross-Chain Coordination: Network interaction verification
- DEX Integration: Enable cross-chain trading pairs
- Liquidity Bridging: Move assets between ecosystems
- Yield Farming: Access opportunities across chains
- Portfolio Rebalancing: Move assets without centralized risk
- Arbitrage Opportunities: Exploit price differences across chains
- Ecosystem Migration: Transfer holdings between preferred networks
- dApp Integration: Build cross-chain functionality
- Research Platform: Study atomic swap mechanisms
- Infrastructure Building: Create trustless bridge alternatives
- Current Status: Proof-of-concept on testnets
- Not Production Ready: Requires security audits
- Educational Purpose: Designed for learning and testing
- Smart Contract Risk: Potential bugs in contract logic
- Network Risk: Testnet instability
- Key Management: Secure private key handling required
We welcome contributions! Please see our Contributing Guidelines for details.
- π΄ Fork the repository
- πΏ Create feature branch (
git checkout -b feature/amazing-feature) - πΎ Commit changes (
git commit -m 'Add amazing feature') - π€ Push to branch (
git push origin feature/amazing-feature) - π Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- 1inch Network: Cross-chain SDK integration
- Foundry Team: Development framework
- Base: Testnet infrastructure
- Tezos: Etherlink blockchain support
- GitHub Issues: Report bugs or request features
- Discussions: Join community discussions
β Star this repository if you find it useful! β