Secure hash time lock contracts and liquidity management for cross-chain atomic swaps
Core contracts for Ethereum-side atomic swap functionality
The main contract implementing hash time lock functionality for secure cross-chain swaps. Manages the creation, claiming, and refunding of atomic swaps using cryptographic hashes.
Manages liquidity pools and provides funding for atomic swaps. Handles token deposits, withdrawals, and ensures sufficient liquidity for cross-chain operations.
The core contract that implements atomic swap functionality using hash time locks.
Creates a new hash time lock contract
Claims funds using preimage
Refunds after timelock expiration
Retrieves contract details
struct TimeLockContract {
address sender;
address receiver;
uint256 amount;
bytes32 hashlock;
uint256 timelock;
bool withdrawn;
bool refunded;
bytes32 preimage;
}
Deploy contracts to Ethereum networks
cd ethereum-contracts
npm install
cp .env.example .env
# Configure your .env file
npx hardhat compile
# Contracts compiled to artifacts/
npx hardhat test
# Run all tests
npx hardhat test --grep "HashedTimelock"
# Run specific test suite
npx hardhat run scripts/deploy.js --network localhost
# Deploy to local network
npx hardhat run scripts/deploy.js --network sepolia
# Deploy to testnet
Comprehensive test suite covering all contract functionality and edge cases.