project screenshot 1
project screenshot 2
project screenshot 3

Enderswap

Cross-chain atomic swaps between Base Sepolia and Sui testnet using HTLCs.

Enderswap

Created At

Unite Defi

Project Description

EnderSwap is a cross-chain, bi-directional atomic swap system that allows users to securely exchange assets between the Ethereum ecosystem (specifically, the Base Sepolia testnet) and the Sui testnet. There is a Solidity smart contract deployed on Base Sepolia (EVM). There is a Move smart contract deployed on Sui testnet. Both contracts implement the same HTLC logic: lock funds with a hash, release them only if the correct secret is revealed before a deadline, or allow a refund after the deadline. Example: Alice (on EVM) wants to swap ETH for Bob’s SUI (on Sui) Alice locks ETH in the EVM contract, specifying Bob’s EVM address as the recipient and a hash of a secret. Bob sees the lock and locks SUI in the Sui contract, specifying Alice’s Sui address as the recipient and using the same hash. Alice claims SUI on Sui by revealing the secret. Bob sees the revealed secret and uses it to claim ETH on EVM. If either party fails to claim in time, they can refund their own locked assets after the timelock. The reverse flow (SUI → EVM) works the same way, just with roles swapped. The relayer-service is a simple script for now that orchestrates the swap process for demo and testing due to limited time and my skill issues. It can simulate both sides of the swap, monitor events, and handle the timing and secret sharing. Everything a relayer should do but as a script for demo.

How it's Made

The core of the project is two smart contracts: one written in Solidity for the EVM side and deployed on Base Sepolia, and one written in Move for the Sui side and deployed on Sui testnet. Both contracts implement the same HTLC logic, allowing users to lock funds with a hash, release them only if the correct secret is revealed before a deadline, or allow a refund after the deadline. I used Foundry for compiling, deploying, and testing the Solidity contract, and Sui’s Move toolchain for the Sui contract. To orchestrate the swap process and demonstrate the protocol, I wrote a set of TypeScript scripts in the relayer-service directory. This isn’t a backend in the traditional sense, but rather a set of scripts that simulate both sides of the swap, generate secrets and hashes, and manage the timing and event monitoring. I used ethers.js for EVM wallet management and contract calls, and @mysten/sui for Sui wallet management and Move contract calls. The scripts generate a random secret, hash it, and use the hash to lock funds on both chains. They monitor on-chain events to know when to proceed to the next step, such as when a lock is created or a secret is revealed. The same secret hash is used on both chains, ensuring atomicity, and the scripts wait for confirmations before proceeding to the next step in the swap. For the demo, I took a few shortcuts to make development and testing easier. Most notably, I used the same wallet address for both the source and destination on each chain, so the “maker” and “taker” are the same person in the demo and the funds always end up back in the same wallet. In a real-world scenario, you’d want to use four distinct addresses (maker/taker, source/destination on each chain), but for time and sanity, this shortcut made everything much easier to test and debug. I also used a simple synchronous sleep after creating a lock on Sui to avoid race conditions with object finality, which is not production-grade but works for the demo. All interaction is via the command line and logs; there’s no frontend yet, but the architecture is ready for one. I relied on partner technologies like Base Sepolia, everyone's favourite EVM chain for dirt cheap gas prices and speed, and Sui Testnet, I really like the direction Sui is going in especially love the community who's actively working on it. Foundry beacause yes. Overall, EnderSwap is a practical, working demo of cross-chain atomic swaps between EVM and Sui.

background image mobile

Join the mailing list

Get the latest news and updates