Blockchain & Cryptocurrency Glossary

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

  • search-icon Clear Definitions
  • search-icon Practical
  • search-icon Technical
  • search-icon Related Terms

Hash Time‑Locked Contract (HTLC)

1 min read
Pronunciation
[hash tym-lokd kon-trakt]
Analogy
Like a sealed envelope that only opens when you provide the correct secret code or returns to the sender after a deadline.
Definition
A smart contract that locks funds until a cryptographic preimage is revealed or a timeout elapses, enabling trustless atomic swaps and payment channels.
Key Points Intro
HTLCs underpin cross‑chain atomic swaps and off‑chain payment networks by enforcing conditional transfers.
Key Points

Hashlock: Requires preimage of a known hash to unlock funds.

Timelock: Refund path after expiry if preimage not provided.

Atomicity: Ensures either both sides of an exchange occur or none.

Use cases: Lightning Network, atomic token swaps.

Example
Alice and Bob perform an atomic swap: Alice locks BTC in an HTLC on Bitcoin, Bob locks ETH in an HTLC on Ethereum; exchange secrets to claim each other’s funds.
Technical Deep Dive
HTLC script on Bitcoin uses `OP_SHA256 OP_EQUALVERIFY OP_CHECKSIGVERIFY OP_CHECKLOCKTIMEVERIFY OP_DROP OP_CHECKSIG`. On Ethereum, a Solidity contract checks `keccak256(preimage) == hash` and `block.timestamp expiry`.
Security Warning
Clock skew or block timestamp manipulation can affect timelock behavior; use conservative time windows.
Caveat
HTLCs require both parties to be online to claim funds before timeout.

Hash Time‑Locked Contract (HTLC) - Related Articles

No related articles for this term.