Term
HTLC (Hash Time-Locked Contract)
An HTLC (Hash Time-Locked Contract) is a smart-contract primitive that locks funds until either a cryptographic secret is revealed to claim them or a timeout elapses to refund them, enabling atomic cross-chain swaps and Lightning Network channels.
An HTLC is a construction with two conditions on releasing locked funds. The first is a hash-lock: the funds can be claimed by anyone who reveals a pre-image that hashes to a specified hash. The second is a time-lock: if the pre-image is not revealed within a set time, the funds return to the sender automatically. Together, these give the trustless "either both sides complete or nobody loses" property that makes atomic swaps and off-chain payment channels possible.
In an atomic swap across two chains, party A locks funds on chain 1 with a hash-lock using hash H. Party B locks funds on chain 2 with the same hash H but a shorter timeout. When A claims from B's contract by revealing the pre-image, that pre-image becomes visible on chain 2, and B uses it to claim from A's contract on chain 1. If either party abandons before revealing, the timeouts refund everyone.
The Lightning Network extends HTLC into multi-hop routing. A payment from A to C through intermediary B uses two chained HTLCs; the same hash-lock enforces that either the entire route completes or every leg refunds. This is what makes trustless Lightning payments possible between parties who do not have a direct channel.
Want to put this to work?