← Back to home

hermes

Hermes is a Fusion+ implementation enabling swaps between Stellar and Ethereum.

Problem Statement

Hermes is a Fusion+-style cross-chain bridge enabling atomic swaps between Ethereum-compatible chains and Stellar using HTLCs on Stellar, deterministic contract addresses, and a custom EVM deployment. It features bespoke relayer and resolver services that coordinate off-chain verification, guarantee atomicity, and optimize finality. By integrating Stellar’s native capabilities with EVM programmability, Hermes ensures secure, trust-minimized, and deterministic asset movement across both ecosystems without centralized custody.

Solution

Hermes - Cross-Chain Atomic Swap ProtocolOverviewHermes implements a cross-chain atomic swap protocol using Hash Time Locked Contracts (HTLCs) with time-locked escrow contracts on both Ethereum and Stellar chains. The system ensures trustless, atomic exchanges without requiring centralized custody.Core TechnologiesSmart ContractsEthereum (EVM): Solidity contracts built with Foundry frameworkEscrowFactorydeploys source and destination escrow contractsEscrowSrcandEscrowDsthandle the actual token locking and unlockingUses OpenZeppelin's Create2 for deterministic contract addressesStellar: Rust-based Soroban smart contractsMirror functionality of EVM contracts but adapted for Stellar's account modelBuilt using the Stellar SDK and Soroban CLIFrontend StackReact with TypeScript for the user interfaceRainbowKit/Wagmi for Ethereum wallet integrationFreighter for Stellar wallet connectivityVite for build tooling and development serverCross-Chain CoordinationThe resolver service (resolver/nevm.ts) orchestrates the four-step atomic swap process:Create Source Escrow: Deploys and funds escrow on the source chainCreate Destination Escrow: Deploys corresponding escrow on destination chainWithdraw Destination: Recipient claims tokens using the secretWithdraw Source: Original sender completes the swap using the revealed secretKey Technical InnovationsDeterministic AddressesThe system uses deterministic contract deployment to ensure both parties can independently verify escrow addresses before funding, eliminating trust requirements.Time-Lock MechanismsSophisticated timelock encoding ensures proper sequencing:Withdrawal windows for legitimate swapsCancellation periods for failed swapsPublic withdrawal/cancellation for resolver interventionCross-Chain State ManagementThe resolver maintains state consistency across chains by:Generating shared secrets for each swapCoordinating timing to prevent race conditionsHandling edge cases like network delays or failed transactionsDevelopment & DeploymentMonorepo StructureModular TypeScript packages for shared utilitiesSeparate build processes for contracts, frontend, and resolverDocker containerization for easy deploymentTesting & VerificationFoundry for EVM contract testingRust toolchain for Stellar contract validationContract verification on Etherscan for transparencyNotable Implementation DetailsSecret Managementconst secret = random32Bytes(); const hashlock = keccak256(secret);Each swap uses a unique 32-byte secret, with its keccak256 hash serving as the commitment.Cross-Chain Token BridgingThe system doesn't actually "bridge" tokens but rather enables atomic exchanges of native tokens on each chain, avoiding the complexities and risks of wrapped token approaches.Environment ConfigurationExtensive environment variable configuration supports multiple networks and deployment scenarios, with separate variables for frontend and backend services.Architecture BenefitsThis architecture creates a trustless bridge that leverages the strengths of both Ethereum's programmability and Stellar's efficiency while maintaining security through cryptographic commitments and time-based constraints.

Hackathon

ETHGlobal Unite

2025

Contributors