This project implements a Hash Time-Locked Contract (HTLC) that allows atomic swaps between the Sepolia Ethereum testnet and the Binance Smart Chain (BNB) testnet. The HTLC smart contract facilitates cross-chain token swaps.
This project demonstrates a cross-chain atomic swap using Hash Time-Locked Contracts (HTLC) between the Sepolia Ethereum testnet and the Binance Smart Chain (BNB) testnet. The implementation is done using Solidity, Hardhat for development, and Chai for testing.
Atomic swaps are a method of exchanging cryptocurrencies between two different blockchains without requiring a trusted third party. This project implements HTLCs to enable these atomic swaps, ensuring that the swap either completes successfully for both parties or fails for both, without either party being able to cheat the other.
Users:
HTLC Contracts:
UNINITIALIZED
, ACTIVE
, WITHDRAWN
, REFUNDED
, and EXPIRED
.Hash Lock & Time Lock:
Development Tools:
This diagram provides a simplified overview of the HTLC setup, focusing on the interactions between users, smart contracts, and the development tools.
This diagram illustrates the detailed process flow of the HTLC-based atomic swap between Sepolia and BNB networks, including the token locking, unlocking, and refund mechanisms.
hashLock
ensures that tokens can only be withdrawn by providing the correct secret.timeLock
ensures that if the swap is not completed within the specified time, the tokens are refunded to the original sender.REFUNDED
state, and the locked tokens are returned to the original senders.Clone the Repository:
git clone https://github.com/sanjay-sol/AtomicSwaps-HTLC
cd AtomicSwaps-HTLC
Install Dependencies:
npm install
Compile Contracts:
npx hardhat compile
Deploy Contracts: Deploy the HTLC contracts on both Sepolia and BNB testnets.
npx hardhat run scripts/deploy.js --network sepolia
npx hardhat run scripts/deploy.js --network binanceTestnet
Run Tests:
npx hardhat test
I am working on the project, it is not completed yet.
This project demonstrates the implementation of atomic swaps using HTLCs, allowing trustless exchanges between two different blockchains. The use of Hardhat and Chai ensures that the contracts are robust and thoroughly tested.