Trust Machines Logo
Contact
Table of Contents
Share This Article

What is a Hashed Time Locked Contract (HTLC)?

Hashed Timelock Contracts (HTLCs) are a crucial component in the world of blockchain and cryptocurrencies, providing a mechanism for secure and trustless cross-chain or cross-protocol transactions. HTLCs are particularly prevalent in the context of payment channels and atomic swaps, enabling parties to engage in transactions across different blockchains without the need for a trusted intermediary.

At its core, an HTLC is a smart contract that employs both a hash function and a time lock to ensure the secure and conditional execution of a transaction. The key components of an HTLC include a hash lock, a time lock, and the capability to reveal a preimage.

Here's how it works: When parties initiate an HTLC, the sender generates a hash value (hash lock) and creates a transaction that locks the funds with this hash. The receiver, to claim the funds, must produce the preimage (input that hashes to the specified hash) within a specified time frame (time lock). If the preimage is revealed within the allotted time, the funds are released to the receiver; otherwise, they are refunded to the sender.

HTLCs are foundational to the Lightning Network, a layer-2 scaling solution for blockchain networks like Bitcoin. In payment channels within the Lightning Network, participants can create HTLCs to route payments securely and instantaneously across the network. Each hop in the payment route is an HTLC that represents a commitment to transfer funds if the corresponding preimage is revealed before the time lock expires.

Moreover, HTLCs play a pivotal role in atomic swaps, a mechanism that allows users to exchange assets across different blockchains atomically. In an atomic swap, HTLCs on both chains ensure that either both parties successfully complete the swap or the transaction is canceled, preventing the risk of one party failing to fulfill their end of the bargain.

Builder Tracking Pixel

Related Terms