Info Gulp

What Is a Hashed Timelock Contract (HTLC)?


Last Updated:
Info Gulp employs strict editorial principles to provide accurate, clear and actionable information. Learn more about our Editorial Policy.

    Highlights

  • Hashed timelock contracts (HTLCs) reduce counterparty risk in blockchain transactions by requiring a cryptographic passphrase and timely claim to unlock funds
  • HTLCs incorporate hashlocks, which are hashed public keys, and timelocks like CheckLockTimeVerify (CLTV) and CheckSequenceVerify (CSV) to enforce time or block-based constraints
  • They enable atomic swaps for cross-chain cryptocurrency exchanges and are fundamental to Bitcoin's Lightning Network for efficient, conditional payments
  • Smart contracts, including HTLCs, execute automatically on blockchains like Bitcoin post-Taproot upgrade, but deploying them on networks like Ethereum incurs gas fees in Gwei
Table of Contents

What Is a Hashed Timelock Contract (HTLC)?

Let me explain what a hashed timelock contract, or HTLC, really is—it's a type of smart contract you'll find in blockchain setups, designed specifically to cut down on counterparty risk. Think of it as a time-sensitive escrow that demands a cryptographic passphrase to release funds.

In practice, if you're the one receiving funds in a transaction, you have to do two things to get them: input the right passphrase and claim the payment before the clock runs out. Get the passphrase wrong or miss the deadline, and you forfeit the funds entirely.

Key Takeaways

As I see it, the core of an HTLC is how it minimizes counterparty risk in decentralized smart contracts by setting up a time-based escrow tied to a cryptographic passphrase. You, as the receiver, must acknowledge and claim the payment within a set period, or it's gone. These contracts make payments conditional, which boosts efficiency in blockchain transactions and positions HTLCs as a key building block for things like the Lightning Network.

Understanding Hashed Timelock Contracts (HTLCs)

When you dive into HTLCs, you'll notice they pull from standard cryptocurrency transaction elements, like using multiple signatures with private and public keys to verify everything. But what sets them apart are the hashlock and the timelock—those are the game-changers.

Hashlock

First off, the hashlock is essentially a cryptographically scrambled version of a public key that the transaction initiator creates. You use the matching private key to unlock it. In an HTLC, the initiator generates this key, hashes it, and stores it in a pre-image that's revealed only at the end. These contracts are built to expire after a set time or a certain number of blocks, giving you a clear end point. Remember, to pull off an HTLC transaction, both parties need to open channels, typically through a wallet or exchange.

Timelock

Then there's the timelock, which comes in two flavors to impose time limits on these contracts. The first is CheckLockTimeVerify (CLTV), which locks and releases crypto based on actual time—hardcoding constraints so coins only move at a specific date, time, or block height. You'll see HTLCs powering atomic swaps for trading across different blockchains, and they're also central to Bitcoin's Lightning Network. The second type is CheckSequenceVerify (CSV), which skips time altogether and tracks by the number of blocks generated to decide when to wrap things up.

The Process in a Hashed Timelock Contract

Let's walk through a real example: say Alice wants to swap her Bitcoin for Bob's Litecoin using an HTLC. She starts by generating a hash from her Litecoin private key and sends it to Bob, along with a pre-image from a small transaction to validate later. Bob mirrors this by creating his own hash and pre-image in Litecoin, sending them to Alice. Once Alice gets Bob's transaction, she signs it with her original key from the pre-image, and Bob does the same on his side. When both input their keys and agree, the smart contract kicks in and executes—neither can back out or alter it, eliminating any chance of foul play.

What Is a Timelock Contract?

A timelock contract is simply a smart contract on a blockchain that triggers a transaction at a predetermined time. You'll encounter them in HTLCs and payment channels where timing is critical for payments.

Does Bitcoin Have Smart Contracts?

Bitcoin's blockchain didn't support smart contracts at first, but the 2021 Taproot upgrade changed that, allowing them in transactions now.

What Is a Smart Contract?

At its core, a smart contract is a program on a blockchain that runs automatically when conditions are met.

How Much Does a Smart Contract Cost?

On Ethereum, deploying a smart contract requires gas paid in Gwei, a fraction of ether. Costs can climb to billions of Gwei for complex ones, but simpler swaps are far cheaper.

Investment Disclaimer

Investing in cryptocurrencies and ICOs carries high risk and speculation, and this isn't advice from me or Investopedia to jump in. Your situation is unique, so consult a qualified professional before any financial moves. We make no guarantees on the accuracy or timeliness of this info.

Other articles for you

What Is the Arab League?
What Is the Arab League?

The Arab League is a regional organization of 22 Arabic-speaking countries aimed at promoting their independence, economic growth, and political stability.

What Is a Special Economic Zone (SEZ)?
What Is a Special Economic Zone (SEZ)?

Special Economic Zones are designated areas with favorable regulations to attract foreign investment and boost economic growth.

What Is a Reorganization?
What Is a Reorganization?

Business reorganization is a major restructuring of a troubled company to restore profitability, often under court supervision in bankruptcy.

What Is a Rate-and-Term Refinance?
What Is a Rate-and-Term Refinance?

A rate-and-term refinance replaces your existing mortgage with a new one featuring a better interest rate or term without providing cash, helping lower payments or shorten the loan duration.

What Is Abenomics?
What Is Abenomics?

Abenomics refers to the economic policies implemented by Japanese Prime Minister Shinzo Abe in 2012 to revive Japan's stagnant economy through monetary expansion, government spending, and structural reforms.

What Is the Hot Waitress Economic Index?
What Is the Hot Waitress Economic Index?

The Hot Waitress Economic Index is a dubious theory suggesting that more attractive servers indicate a weak economy.

What Is Reinvestment?
What Is Reinvestment?

Reinvestment means using income from investments like dividends or interest to buy more shares instead of taking cash.

What Is Price Level?
What Is Price Level?

Price level refers to the average cost of goods and services in an economy or specific price points in investments like support and resistance.

What Is the Law of Supply and Demand?
What Is the Law of Supply and Demand?

The law of supply and demand explains how price changes influence the supply and demand of goods, leading to market equilibrium.

What Is a Business Model?
What Is a Business Model?

A business model is a plan for how a company creates and delivers value to customers while generating profit.

Follow Us

Share



by using this website you agree to our Cookies Policy

Copyright © Info Gulp 2025