Research

Hashed Time Lock Contracts (HTLC)

Messari

Jul 9, 2019 ⋅  2 min read

Written by Regan Grishaber

Introduction

A Hashed Timelock Contract (HTLC) is a construct that permits secure peer-to-peer transactions used in the Lightning Network to route payments outside of one’s direct channel.

HTLCs are used in various forms of atomic swaps, or peer-to-peer transfers that do not rely on an intermediary. An on-chain swap takes place between two different currencies in a cross-chain transaction and records the transfer directly on each chain, while an off-chain swap requires an off-chain platform such as Lightning to facilitate transfers of the native currency. Use of an HTLC ensures that both parties in an atomic swap fulfill their side of the trade by requiring proof of payment within a specified deadline.

In Lightning, an HTLC achieves a global state across nodes by encumbering payments with a hash that requires knowledge of the 20-byte random input data used to generate the hash, called a pre-image. The SHA256 hash is generated by the ultimate receiver, who provides it to the original sender. The sender uses their payment channel to make the first payment to their channel counterparty. Recipients are responsible for producing this pre-image within a set number of block confirmations, else the funds are returned to the sender. To route payments across a network of nodes, each transaction is encumbered with the same HTLC. Only the final recipient can unlock the funds by producing knowledge of the pre-image. Transactions are made revocable off-chain by embedding RSMCs in the output.

Suggested Reading

What Are Hashed Timelock Contracts (HTLCs)? Application In Lightning Network & Payment Channels by Arnav Vohra

What is a Hashed Timelock Contract? by JP Buntinx

If there is anything you'd like to add or change, you can tweet your feedback at @messari_crypto or email [email protected]

Let us know what you loved about the report, what may be missing, or share any other feedback by filling out this short form. All responses are subject to our Privacy Policy and Terms of Service.

Upgrade to Messari Pro

Gain an edge over the market with professional grade tools, data and research.

Already a member? Sign in

Upgrade to Messari Pro

Gain an edge over the market with professional grade tools, data and research.

Already a member? Sign in

Read more

Research Reports

Read more

Based on your watchlists

Create a new watchlist
Read more

Research Reports

Read more

Based on your watchlists

Create a new watchlist