What Is Hashed Timelock Contract (HTLC)?
Hashed Timelock Contract (HTLC) is a framework used for payment transfers via platforms like the Lightning Network, allowing receivers to confirm the receipt of funds before time-out. The primary goal of HTLCs is to provide an extra level of security while transferring funds through a decentralized system.
HTLC works on two concepts – Hashlock and Timelock. The term Hashed Timelock Contract has been derived by combining these two words. These features make the release and transfer of funds easier. However, if a receiver fails to claim payment receipt before the stipulated period, they lose the right to receive the funds, and the amount gets refunded to the payee.
Table of contents
- Hashed Timelock Contract, or HTLC, is a key feature of smart contracts that allows parties to transfer funds and execute conditional, time-bound contracts easily.
- Here, the sender will create a cryptographic hash that acts as the Key to the transaction. As the receiver cracks it, they receive the payment.
- There are two important components of HTLC. They are called the hashlock and timelock. While the former involves the initiation of a transaction with certain restrictions, the latter ensures the receiver validates the transaction within a certain time.
- The Bitcoin community initiated the use of this feature in lightning networks.
Hashed Timelock Contract Explained
Hashed Timelock Contract, in blockchain technology, allows crypto users to modify payment details by sending confirmation to the receiver. Cryptographic Proof is the feature that confirms the authenticity of information and defines how a receiver becomes eligible for receiving payments in HTLCs. However, if the receiver fails to acknowledge the payment receipt through cryptographic proof, they cannot claim the sum. The sender holds the power to reject it too, turning the transaction void. This way, an HTLC adds extra security to the transactions executed on the blockchain.
This feature was released by the Bitcoin community and is used in the Lightning Network. They use CheckLockTimeVerify (CLTV) and CheckSequenceVerify (CSV) to secure transactions.
CheckLockTimeVerify (CLTV) contains information about transaction execution (release of funds) in Bitcoin blocks (blocks hold transaction-related data points or parameters). Only after the designated period elapses or a specific parameter (ceiling, date, time, etc.) is met will the funds be released. In simple words, CLTV helps lock funds until the assigned time for their use arrives. CheckSequenceVerify enables users to apply time locks on transactions, i.e., it saves information about when a block related to a specific transaction will be closed. Once this period is over, the Bitcoin transaction is ready to be executed.
Two key elements within the structure of HTLC make the technology viable. Let us study them.
#1 – Hashlock
It refers to the restriction imposed on the transaction until the receiver provides the right key. In simple terms, the transaction is hashed or encrypted cryptographically to secure it. It acts as a Two-factor Authentication or a Secret Recovery Phrase for the parties. So, if the receiver wants to access the funds, they must provide the security key or pin to the sender. This key is like the private key but differs slightly in its function.
#2 – Timelock
As the name suggests, the timelock feature limits receivers from confirming the payment details before a preset date and time. It typically sets aside certain Bitcoin or cryptocurrencies that get released upon confirmation.
The way hashed timelock contract works is usually visible to the sender and receiver. The person intending to send the money will set up a cryptographic hash to lock the amount. Similarly, to receive the money, the receiver needs to set up a Proof of Payment (POP) before the preset time. However, this duration can vary depending on the contract details.
So, if the receiver cracks the hash and confirms the details within the given time, they will receive the full amount. On the other hand, failure to do so results in them not receiving the amount.
Let us look at some examples of hashed timelock contracts to understand the concept better.
James and Alice have a Bitcoin transaction of 10 Bitcoin (BTC) to execute. Here, the former is a sender, and the latter is a receiver. So, James creates a crypto hash and sends it to Alice. Now, the receiver must crack the hash per the hashed block. Similarly, James can create a time lock that allows Alice to confirm the transaction before a block (50 blocks). As she completes the verification, she receives 10 BTC as her payment.
But, if Alice fails to do so, she will not be able to receive any crypto money. Instead, one mistake on her side can cause her to lose the entire amount.
According to a report published on May 19, 2023, researchers found that Hashed Timelock Contracts (HTLCs) can connect ledgers under different DLTs (Distributed Ledger Technologies – a database/records storage for transactions), offering access to various databases. This facilitates communication between multiple networks. Simply put, HTLC enables international transfers using various cryptocurrency networks active around the world. The report believes that closing transactions in real-time might also be possible.
Let us look at the uses and applications of hashed timelock contracts.
#1 – Lightning Networks
The highest use of the HTLC is seen in the Bitcoin Lightning Network. The procedure is called “Network Routing,” where users can cheaply and effectively transfer funds. It creates a payment channel that enables faster processing in less time.
#2 – Atomic Swaps
Here, atomic swaps are contracts to exchange two cryptocurrencies belonging to different blockchains. So, using HTLC in this method can bring a change in the transaction speed as there are no intermediaries.
#3 – Initial Coin Offerings
Initial Coin Offerings (ICOs) are announced to crowdfund crypto coins and crypto tokens. ICOs pose significant financial risks. Hence, SEC advises investors to stay vigilant while entering such transactions. Investors can use HTLCs to withdraw funds up to a set time.
#4 – Integration with ChainLink Automation
The integration of hashed timelock contracts with chainlink automation serves multiple purposes. One of the main problems it addresses is the disconnect between smart contracts and relevant events that impact cryptocurrency outcomes. For the last will and testament documents, HTLCs can be executed after verifying whether the owner of the will is alive or deceased. If the death certificate has been filed, family members or heirs can access the funds.
Let us go through the advantages of hashed timelock contracts.
#1 – Validation and Privacy Protection
These contracts allow crypto users to validate transactions through cryptographic proof of payment systems. Parties can also execute cross-currency transactions.
#2 – Timely Execution
With HTLC, the parties (sender and receiver) can transact and transfer money within a stipulated time. It allows them to confirm and verify the details until a certain number of blocks get filled.
#3 – Time Sensitivity
HTLC uses the time sensitivity feature that does not require users to track payments. If the receiver does not confirm, the amount will be returned to the sender. So, there is no chance of loss on either side.
#4 – Counterparty Risk Reduction
HTLCs reduce counterparty risks since the payment is conditional and depends on the presentation of the right key or secret recovery phrase. The timelock feature freezes the possibility of a transaction being executed outside the defined timeframe.
Frequently Asked Questions (FAQs)
The Bitcoin community originally developed hashed timelock contracts. CheckLockTimeVerify (CLTV) and CheckSequenceVerify (CSV) are time constraints that can secure transactions during processing.
Despite the many advantages that hashed timelock contracts offer, certain limitations cannot be ignored. Although popular, many individuals are unaware of this feature. As a result, the real-world application is limited. In addition, failure to confirm the transaction can cause a receiver to lose the entire payment. Moreover, if the cryptic hash is leaked, it can lead to major cyberattacks.
The only difference between PTLC and HTLC is that the former is an improved version with reduced fees and safety features. However, it only supports Bitcoin transitions.
This has been a guide to What is Hashed Timelock Contract (HTLC). Here, we explain it with its examples, uses, and advantages. You may also find some useful articles here –