Market Cap: 24h Vol: BTC: BTC Dom:
Gold: S&P 500: EUR/USD: Oil (BRENT):

Hashed Timelock Contract (HTLC)

An HTLC combines two conditions into a single spending script: a hashlock, which only releases funds to whoever can produce a secret value (a preimage) that hashes to a pre-agreed number, and a timelock, which lets the original sender reclaim the funds if that secret is never revealed in time. Together they turn a payment into an all-or-nothing event with a built-in expiry, so neither party ever has to trust the other.

The mechanism was first described by Bitcoin developer Tier Nolan in 2013 and now underpins two major use cases. On the Lightning Network, HTLCs let a payment hop across several connected channels: the recipient generates a hash and shares it with the sender, each intermediary node forwards funds under a copy of that same hashlock with a progressively shorter timelock, and the moment the recipient reveals the secret to claim the final hop, every earlier node can use it to claim its own payment in turn. If the payment stalls anywhere along the route, the timelocks simply expire and the funds return to their senders.

The second use case is the atomic swap: two parties on separate blockchains, such as Bitcoin and an altcoin, each lock funds in an HTLC using the same hash. Whoever reveals the secret to claim one side automatically exposes it on-chain, letting the counterparty claim the other side, so the trade either completes fully or not at all.

  • No custodian or escrow is needed, since funds are locked in code rather than held by a third party.
  • Chains must support compatible hashing and timelock scripting to participate.
  • A newer design, point timelock contracts (PTLCs), aims to replace HTLCs on Lightning for better privacy, though HTLCs remain the production standard.