Htlc

HTLC Trade

johnalbertini14-glitch Updated 1 repo stars

File contents

HTLC Trade

Atomic swap trading using Hash Time Locked Contracts.

Quick Start

# Install dependencies
npm install ethers viem

# Set environment
export PRIVATE_KEY=0x...
export BASE_ETH_RPC=https://mainnet.base.org

Commands

Generate Preimage

node scripts/htlc.js preimage

Lock Funds (Buyer)

node scripts/htlc.js lock <seller> <preimageHash> <timeout> <amountETH>

Reveal (Seller)

node scripts/htlc.js reveal <lockHash> <preimage>

Full Trade

node scripts/htlc.js trade <seller> <inscriptionTx> <amountETH>

Contract

BaseTimelock: 0xa7f9f88e753147d69baf8f2fef89a551680dbac1

Flow

  1. Seller generates preimage, shares hash + inscription
  2. Buyer verifies inscription, calls lock() with ETH
  3. Seller calls reveal() with preimage → ETH released
  4. Buyer confirms receipt → trade complete

johnalbertini14-glitch/openclaw-skills/tree/main/skills/web4agent/htlc commit dbd862e2df

Frequently asked questions

npx skillmds@latest add johnalbertini14-glitch/htlc