DotFusion

Trustless, secure, and fast token exchanges between Ethereum and Polkadot ecosystems. No intermediaries, no wrapped tokens, just pure atomic swaps.

github
  • 0 Raised
  • 472 Views
  • 0 Judges

Categories

  • 1inch
  • Polkadot
  • ENS
  • BuidlGuidl
  • 💸 Finance [MAIN TRACK]

Gallery

Description

DotFusion - Trustless Cross-Chain Atomic Swaps


DESCRIPTION OF THE PROJECT

DotFusion is a decentralized cross-chain atomic swap platform enabling trustless ETH ↔ DOT exchanges between Ethereum (Sepolia) and Polkadot (Paseo Asset Hub) using Hash Time-Locked Contracts (HTLC). Built on Scaffold-ETH 2 with native Polkadot XCM Precompile integration for automatic cross-chain secret propagation, featuring instant swap UI with resolver service for seamless user experience.


REPOSITORY WITH THE PROJECT'S CODE

GitHub Repository: https://github.com/VincenzoImp/dot-fusion

License: MIT (Open Source)

Setup Instructions: Complete documentation in README.md including:
- Quick start guide (install → start → use)
- Detailed setup instructions for local development
- Resolver service configuration
- Environment setup guides


Contract Explorers (Live on Testnets) 

Ethereum Sepolia Testnet:
- DotFusionEthereumEscrow: https://sepolia.etherscan.io/address/0x4cFC4fb3FF50D344E749a256992CB019De9f2229
Polkadot Paseo Asset Hub Testnet:
- DotFusionPolkadotEscrow: https://assethub-paseo.subscan.io/address/0xc84E1a9A1772251CA228F34d0af5040B94C7083c
- DotFusionXCMBridge: https://assethub-paseo.subscan.io/address/0x418eE7f4c98c37a408db9426302beACa862D7731

Note: Frontend runs locally via `yarn start` (port 3000) and connects to deployed testnet contracts. Resolver service runs via `yarn resolver-api` (port 3001).


TECHNOLOGY INTEGRATION & SPONSOR USAGE

🟣 POLKADOT (Main Sponsor - Primary Integration)

How We Used Polkadot:

1. Native Polkadot Asset Hub Deployment
- Deployed production-ready smart contracts on Paseo Asset Hub testnet (Polkadot parachain)
- Leveraged Polkadot's EVM-compatible environment while accessing native Polkadot features
- Contracts deployed: PolkadotEscrow and XCMBridge

2. XCM Precompile Integration ⭐ (Unique Polkadot Feature)  
- Integrated Polkadot's XCM Precompile (at address 0x0000000000000000000000000000000000000804) for cross-chain messaging
- Used XCM for automatic secret propagation between Paseo and Ethereum chains
- Demonstrates native cross-chain capabilities that are unique to Polkadot VM
- See implementation in XCMBridge.sol lines 34, 211-218, 266-273  
- XCM Bridge contract uses the precompile to call `send()` function for cross-parachain message delivery

3. Cross-Chain Atomic Swaps   
- Built HTLC-based atomic swaps leveraging Polkadot's fast finality (~6 seconds vs Ethereum's ~12 seconds)
2x faster transaction finality on Polkadot provides superior user experience
40-50% lower gas costs compared to Ethereum equivalents   
- Asymmetric timelock design (12h on Ethereum, 6h on Polkadot) prevents timing attacks

4. Why This Showcases Polkadot:   
Interoperability: Real-world demonstration of Polkadot's cross-chain vision   
XCM Innovation: Practical use case of XCM in smart contracts (not just parachain-to-parachain)   
Developer Experience: Proves Solidity developers can easily build on Polkadot with added superpowers   
Cost Efficiency: Demonstrates economic advantages of Polkadot ecosystem   
- Performance: Faster block times and finality improve UX significantly

Technical Implementation Details:
- XCM Bridge contract calls XCM Precompile at `0x0804` with `send(uint32 paraId, bytes xcmMessage, uint64 weight)`
- Encodes Transact instruction to call `completeSwap()` on destination chain
- Automatic secret propagation reduces user coordination overhead
- Seamless integration with existing Ethereum tooling (Hardhat, Scaffold-ETH 2)
- Production-ready deployment scripts for multi-chain environments

🏗️ BUIDLGUIDL / SCAFFOLD-ETH 2

How We Used Scaffold-ETH 2:

1. Complete dApp Framework   
- Built entire frontend using Scaffold-ETH 2 boilerplate and components   - Leveraged SE-2's contract interaction hooks (`useScaffoldReadContract`, `useScaffoldWriteContract`, `useScaffoldEventHistory`)   
- Used SE-2's deployment system (`hardhat-deploy`) for efficient contract deployment on both chains

2. Rapid Development & Deployment   
Smooth deployment: Used SE-2's Hardhat integration to deploy contracts to Sepolia and Paseo in minutes   
Fast iteration: Hot-reload and TypeScript ABI generation accelerated development   
Production-ready UI: RainbowKit wallet integration, responsive design, professional components out of the box   
- Multi-chain support: Adapted SE-2 configuration for dual-chain deployment (Ethereum + Polkadot)

3. Custom Components Built on SE-2:
- `Address`, `AddressInput`, `Balance`, `EtherInput` components for Web3 interactions
- Custom swap UI components built on top of SE-2 foundation   
- Dashboard with real-time event monitoring using SE-2 hooks   
- Instant Swap UI leveraging SE-2's contract write patterns

4. Deployment Infrastructure:
- SE-2's deployment scripts adapted for dual-chain deployment (Ethereum + Polkadot)   
- Automatic ABI generation and contract address management via `deployedContracts.ts`   
- Development workflow: `yarn chain` → `yarn deploy` → `yarn start`   
- TypeScript type generation for contract ABIs ensures type safety

Why Scaffold-ETH 2 Was Essential:
Speed: Built production dApp in hackathon timeframe
Quality: Professional UI/UX without building from scratch
Best Practices: Security patterns and code structure built-in
Multi-chain: Easily adapted for Polkadot network integration
- Developer Experience: Hot reload, error handling, and debugging tools accelerated development

🔷 ENS (Embedded in Address Input)

How We Used ENS:

1. Address Resolution:
- Integrated ENS resolution in all address input fields throughout the application
- Users can enter ENS names (e.g., `vitalik.eth`) instead of hex addresses when: Creating swaps (taker address), Specifying destination addresses, Participating in swaps

2. Implementation:
- Used Scaffold-ETH 2's `AddressInput` component which has built-in ENS support   
- Automatic resolution of `.eth` domains to Ethereum addresses   
- Real-time ENS lookup and validation   
- See implementation in swap creation flow: packages/nextjs/app/swaps/page.tsx

3. User Experience Enhancement:
Readability: Users can use human-readable names instead of hex addresses   
Trust: ENS names provide identity verification for counterparties   
Convenience: No need to copy/paste long addresses   
- Error Prevention: Reduces mistakes from incorrect addresses

Where ENS Appears:
- Swap creation form (taker address field)
- Destination address inputs
- All address input sections across the dApp
- Resolver address configuration


Key Features & Achievements

✅ Production-Ready Contracts deployed on Sepolia and Paseo Asset Hub
✅ XCM Precompile Integration for cross-chain messaging (unique to Polkadot)
Instant Swap UI with automatic resolver fulfillment
✅ Complete HTLC Implementation with atomic guarantees
✅ Comprehensive Security (ReentrancyGuard, CEI pattern, OpenZeppelin)
✅ Full-Stack dApp with Next.js 14, TypeScript, TailwindCSS
✅ Multi-Wallet Support via RainbowKit
✅ Real-Time Dashboard with swap statistics
✅ Resolver Service for liquidity provision (Express API)
✅ Open Source with MIT license and extensive documentation
Developer-Friendly setup with clear instructions


Innovation & Technical Achievements

1. First HTLC Implementation with XCM Precompile - Novel integration of atomic swaps with Polkadot's native cross-chain messaging
2. Multi-Chain Resolver Architecture - Automatic liquidity provision across Ethereum and Polkadot
3. Production-Ready Security - ReentrancyGuard, CEI pattern, comprehensive input validation, asymmetric timelock design
4. Seamless Developer Experience - Proved Ethereum tooling (Hardhat, Scaffold-ETH 2) works perfectly with Polkadot
5. Complete End-to-End Solution - Not just contracts, but full UX including instant swaps, dashboard, and API


Attachments