top of page

Technology

Hashed Timelock Contract

A type of smart contract that enables secure off-chain transactions.

01

■ definition

About

Hashed Timelock Contract

A hashed timelock contract (HTLC) is a type of smart contract that enables secure off-chain and cross-chain transactions, most notably atomic swaps between different cryptocurrencies. It combines two conditions: a hashlock, requiring the receiver to reveal a secret whose hash was set in advance, and a timelock, which returns funds to the sender if the deadline passes without the secret being revealed.

HTLCs are a building block of payment channel networks such as the Lightning Network for Bitcoin, where they allow payments to be routed through intermediaries without trusting them. Because either the conditions are met and payment completes, or the timelock expires and funds return, neither party should be left with funds locked indefinitely when the contract is correctly implemented. The design's elegance is that no trusted third party is needed for the exchange to be safe.

02

■ real-world examples

How It Plays Out in Practice

A hashed timelock contract (HTLC) is a type of smart contract that enables secure off-chain and cross-chain transactions, most notably atomic swaps between different cryptocurrencies. It combines two conditions: a hashlock, requiring the receiver to reveal a secret whose hash was set in advance, and a timelock, which returns funds to the sender if the deadline passes without the secret being revealed.

HTLCs are a building block of payment channel networks such as the Lightning Network for Bitcoin, where they allow payments to be routed through intermediaries without trusting them. Because either the conditions are met and payment completes, or the timelock expires and funds return, neither party should be left with funds locked indefinitely when the contract is correctly implemented. The design's elegance is that no trusted third party is needed for the exchange to be safe.

03

■ key takeaways

What to Remember

◆

A hashed timelock contract (HTLC) is a smart contract condition that makes payments complete only when a secret is revealed before a deadline.

◆

It combines a hashlock, requiring the receiver to reveal a secret whose hash was set in advance, with a timelock that refunds the sender after the deadline.

◆

HTLCs enable atomic swaps between different cryptocurrencies, so either the whole exchange completes or neither side loses funds.

◆

They are a building block of payment channel networks such as Bitcoin's Lightning Network, routing payments through intermediaries without trusting them.

04

■ breaking it down

Understanding Hashed Timelock Contract

01

The Hashlock Condition

The sender locks funds to a hash of a secret only the receiver knows. To claim the payment, the receiver must reveal the secret itself, which the contract checks against the hash — proof of receipt built into the payment.

02

The Timelock Safeguard

If the secret is not revealed before the deadline, the timelock lets the sender reclaim the funds automatically. This guarantees that money cannot sit locked forever if the other party disappears or refuses to complete.

03

How Atomic Swaps Work

Two HTLCs on different blockchains share the same secret: when the receiver claims on one chain, the revealed secret lets the other party claim on the second chain. Both legs complete, or both refund — hence 'atomic'.

04

Routing Without Trust

In the Lightning Network, a payment passes through intermediaries using linked HTLCs, each hop secured by the same secret. Intermediaries cannot divert the funds, because claiming requires the secret only the final receiver holds.

05

■ why it matters

The Importance of

Hashed Timelock Contract

Hashed timelock contracts matter because they remove the trusted middleman from a specific, common problem: exchanging value between parties who do not trust each other, on systems with no referee. Before HTLCs, swapping one cryptocurrency for another usually meant trusting an exchange or the other trader to complete their side. The hashlock-plus-timelock design makes completion automatic and non-completion safe, which is why it sits inside the Lightning Network's routed payments as well as cross-chain swaps. For businesses evaluating digital payment tools, HTLCs are a useful test of substance: they show what a smart contract can genuinely guarantee, and what it cannot.

did you know

Hashed timelock contracts combine exactly two safeguards in their name: a hashlock based on revealing a secret, and a timelock that refunds funds after a deadline. Together they make atomic swaps possible without a trusted intermediary.

06

■ strategies

Applying Hashed Timelock Contracts Carefully

Applying hashed timelock contracts carefully means verifying the implementation, the deadline margins, and the chain conditions before relying on the guarantee.

01

Verify the Implementation

Use established, audited HTLC implementations rather than newly written contract code; the guarantee holds only when the contract is correctly implemented.

02

Allow Generous Time Margins

Set deadlines with ample room for network congestion and confirmation times; a timelock that expires during a busy period can refund a payment that was honestly made.

03

Protect the Secret

The preimage secret controls the funds: generate it securely, store it safely, and reveal it only as part of claiming, since anyone holding it can claim the payment.

04

Check Both Chains' Rules

In a cross-chain swap, confirm the hash function and timelock settings are compatible on both blockchains before locking funds on either side of the exchange.

05

Test With Small Amounts

Prove the full swap or payment route with a small sum first, including the refund path after a deliberate timeout, before committing amounts that matter.

06

Monitor Until Settlement

Watch the contract until it completes or refunds; if a counterparty stalls near the deadline, be ready to claim or reclaim within the timelock window.

07

■ summary

The Bottom Line

A hashed timelock contract (HTLC) is a smart contract mechanism combining a hashlock — reveal a secret to claim — with a timelock that refunds the sender after a deadline. It enables atomic swaps between cryptocurrencies and the routed payments of networks such as Lightning, because either the exchange completes in full or funds return. Its guarantee depends on correct implementation and workable deadlines.

■ related service

Could smart contract conditions reduce counterparty risk in your digital transactions?

Smart contract tools are often presented as automatically safe, while their guarantees depend on implementation details and deadline settings that few users check. Intenovate helps business owners review digital transaction tools and the risks built into them before adopting them in the business.

■ keep learning

Related Articles

bottom of page