A Hashed Timelock Contract (HTLC) is a type of smart contract, self-executing code that lives on a blockchain, that lets two people exchange assets directly with each other, without needing a middleman. It works through two prebuilt conditions. In essence, a secret code must be revealed to be able to claim the funds.  If the swap isn’t completed in time, an automatic refund occurs. Both parties end up getting what they agreed to, or otherwise, neither loses anything at all.

Think of it like a secure drop-box swap. You place your package in one box and lock it with a combination. Your trading partner places their package in another box and locks it with the same combination. Neither of you can open your box until the combination is shared, and if either of you fails to show up before the clock runs out, both boxes pop open and return whatever was placed inside. The trade completes fully or cancels entirely. There is no halfway.

The two mechanisms that make this work each have a name. It works through two prebuilt conditions.  In essence, a secret code must be revealed to be able to claim the funds.  If the swap isn’t completed in time, an automatic refund occurs. Both parties end up getting what they agreed to, or otherwise, neither loses anything at all. Together, they make the contract self-enforcing, no judge, no bank, no arbitrator required.

You have probably benefited from HTLCs without realizing it. They are the backbone of the Bitcoin Lightning Network, a payment system built on top of Bitcoin that enables fast, low-fee transactions. HTLCs in Lightning payments work to ensure that the payment will return to the sender if one of the payment’s hops fails whether they are either routed through a payment channel that isn’t valid or has exceeded its expiry. A type of escrow called HTLCs makes it possible for two parties to agree to a marriage.  Using an HTLC on each chain, for example, a Bitcoin holder and a Litecoin holder can swap directly. The Lightning Network’s Rusty Russell and others are believed to have come up with it in 2015.

Join our newsletter

For anyone trying to understand how crypto payments scale without sacrificing security, HTLCs are a foundational piece. They prove that two strangers can transact across different blockchains, without trusting each other, and without trusting anyone else.

Disclaimer: Coin Medium is not responsible for any losses or damages resulting from reliance on any content, products, or services mentioned in our articles or content belonging to the Coin Medium brand, including but not limited to its social media, newsletters, or posts related to Coin Medium team members.

Related Terms

Multi-Party Computation

Multi-Party Computation, which people commonly call MPC, functions as a cryptographic method that enables several parties to compute a result while safeguarding their individual secret information from each other. The system enables people to work together on protected information without requiring them to trust each other completely or share their private data. The academic field of cryptography developed this concept through research activities that existed before blockchain technology appeared.  Researchers sought to solve a core problem that involved different parties

Keccak-256

Keccak-256 serves as a widely utilized cryptographic hash function for blockchain systems which includes its primary application in the Ethereum network. The algorithm belongs to the Keccak hashing algorithm family which served as the foundation for the US National Institute of Standards and Technology to select SHA-3 as its official standard. Ethereum uses the original Keccak-256 variant because SHA-3 and Keccak share a strong relationship between their two systems. Keccak-256 processes any input size to produce a constant output size

Index Fund

If you’ve ever looked at the thousands of coins on an exchange and felt completely lost, you’re not alone. This is where a Crypto Index Fund comes in. An index fund is a “basket” of different cryptocurrencies that are put together into one investment. Instead of you having to research, buy, and manage twenty different coins, you buy one single “share” of the fund. It’s the crypto version of those classic stock index funds that track the S&P 500. You