Cross-chain atomic swaps: trustlessly swap BTC ⇄ ETH using Bitcoin HTLCs
This project enables trustless atomic swaps between Bitcoin and Ethereum by combining Bitcoin HTLCs with Ethereum smart contracts, coordinated through 1inch Fusion+. On the Bitcoin side, funds are locked using native P2WSH scripts that enforce hash and time constraints. On Ethereum, minimal escrow contracts (MinimalEscrowSrc/Dst) hold funds securely with matching logic. A SwapCoordinator orchestrates the end-to-end swap, sequencing actions across chains, handling edge cases (like refunds or delays), and supporting rescue operations.
The 1inch Fusion+ system is integrated to manage order resolution and relay execution. The Fusion+ resolver (acting as the swap taker) is responsible for submitting the secret once revealed on-chain, making swaps compatible with the existing 1inch offchain RFQ and execution architecture. The project supports bidirectional swaps (BTC→ETH and ETH→BTC), includes example scripts and real testnet integrations, and emphasizes transparency and non-custodial control.
Bitcoin components are built in Node.js using bitcoinjs-lib, tiny-secp256k1, and custom script logic to generate P2WSH contracts. Ethereum logic is implemented in Solidity and deployed using Hardhat. Escrow contracts on Ethereum enforce hashlocks, timelocks, and safe withdrawal patterns. The project is wired into 1inch Fusion+ by emitting and resolving orders via Fusion resolvers, allowing external parties (including relayers) to finalize swaps by submitting secrets or claiming refunds.
Demo commands (npm run example:btc-to-eth) simulate the full flow, from funding a BTC HTLC, to escrow deployment, to Fusion+ resolution and claim. The system is fully testable on public testnets like Bitcoin testnet and Sepolia.