تخطَّ إلى المحتوى الرئيسي

Hashed Timelock Contract (HTLC)

Advanced

العقد المقفل زمنيًا بالهاش

Also known as: HTLC, Hash Time Locked Contract, Hash Timelock Contract

Cryptocurrencies
Last updated

Definition reviewed before publishing

Our content team writes and reviews every definition before it is published, and revisits it when the way a term is used in the markets changes. The date shows the latest change to this term.

Last updated on 25 November 2026

A hashed timelock contract is a type of smart contract that combines two conditions for releasing funds: the recipient must present a secret that matches a hash agreed in advance, and must do so before a deadline. If the deadline passes without the secret being revealed, the funds go back to the sender.

Quick summary

• A smart contract that requires revealing a secret matching a hash before a deadline. • Funds return to the sender if the deadline passes. • The basis of the Lightning Network and atomic swaps.

How it works

The recipient starts by generating a random secret, computes its hash with a cryptographic function such as SHA-256, and sends only the hash to the sender. The sender locks funds in a contract on the network that requires the original secret producing that hash, and sets a deadline measured in blocks or in time. If the recipient reveals the secret within the deadline, the funds are released and the secret becomes visible on the network. If not, the sender can reclaim the funds once the deadline passes. The idea becomes powerful when several contracts are chained on the same hash, as in Bitcoin's Lightning Network: a payment passes through intermediaries nobody needs to trust, and each intermediary can collect only by revealing the secret that also unlocks the payment owed by the party before it. Deadlines shrink along the route so that each intermediary has time to claim its funds after the next party reveals the secret.

Example

Ahmed wants to pay Sara 0.01 bitcoin through Khalid. Ahmed locks 0.0101 bitcoin for Khalid with a 48-hour deadline, and Khalid locks 0.01 for Sara with a 24-hour deadline on the same hash. Sara reveals the secret and collects, Khalid uses it to collect from Ahmed, and Khalid earns a routing fee of 0.0001 bitcoin (0.0101 - 0.01).

Where you will see it

In Bitcoin Lightning Network payment channels, in atomic swaps between different blockchains, and in technical papers for bridge and off-chain payment protocols.

Why it matters

This mechanism explains how funds can move between parties who do not trust each other without a custodian holding the money. Users of the Lightning Network or atomic swaps can see why deadlines exist and why funds may be held temporarily if one party goes offline.

How it is calculated

There is no financial formula, but the release condition is: hash(secret) = the value set in the contract, with claim time < deadline. On a multi-hop route, deadlines decrease: first party's deadline > next party's deadline.

How it differs from similar terms

• Smart contract: a general term for any program that executes automatically on a blockchain, and an HTLC is one specific kind. • Layer 2: solutions built on top of the base chain, and the Lightning Network relies on HTLCs. • Cross-chain: the idea of linking different blockchains, and HTLCs are one tool for swapping between them without an intermediary.

Common mistakes

Believing the contract guarantees the payment will arrive no matter what. It guarantees only that the funds either arrive in full when the secret is revealed or return to the sender after the deadline, and they may stay locked until then.

Related terms