What Is A Hashed Timelock Contracts (HTLC)?
HTLC refer to a special feature that is used to create smart contracts that are able to modify payment channels.
Go Back
๐ 12:10 PM
๐
May 13, 2025
โ๏ธ By Ecojames
What Is a Hashed Timelock Contract
A Hashed Timelock Contract (HTLC) is a transactional agreement used in the cryptocurrency industry to produce conditional payments. It is basically a payment wherein the receiver or the beneficiary is required to acknowledge the receipt of payment before a predetermined time or a preset deadline.
Key elements which distinguish HTLC from standard cryptocurrency transactions
1. Hashlock
A function that restricts the spending of funds until a certain piece of data is publicly disclosed.
2. Timelock
This is a function that restricts the spending of funds until a specific time (or block height) in the future. It can be achieved in Bitcoin, for example, using functions like CheckLockTimeVerify or CheckSequenceVerify.
How Hashed Timelock works
Payment channels already use timelocks, and it can be relatively simple conceptually to extend them with hashlocks.
- This provides the useful benefit of making payments routable across two or more payment channels.
Example
- Judy opens a payment channel to Augustus , and Augustus opens a payment channel to Kahenya .
Judy wants to buy something from Kahenya for 1,000 satoshis.
- Kahenya generates a random number and generates its SHA256 hash. Kahenya gives that hash to Judy.
Judy uses her payment channel to Augustus to pay him 1,000 satoshis, but she adds the hash Kahenya gave her to the payment along with an extra condition: in order for Augustus to claim the payment, he has to provide the data which was used to produce that hash.
- Augustus uses his payment channel to Kahenya to pay Kahenya 1,000 satoshis, and Augustus adds a copy of the same condition that Judy put on the payment she gave Augustus .
- Kahenya has the original data that was used to produce the hash (called a pre-image), so Kahenya can use it to finalize his payment and fully receive the payment from Augustus . By doing so, Kahenya necessarily makes the pre-image available to Augustus .
- Augustus uses the pre-image to finalize his payment from Judy.
Benefits of Hashed Timelock Contracts
1. Time-bound transactions
Using a hashed timelock contract system ensures time-bound transactions. It guarantees the timely execution of transactions and hence, the timely execution and receipt of payments.
2. Atomic swaps
Using the HTLC system to settle transactions brings the ability to engage in atomic swaps to the table.
- An atomic swap is a form of smart contract technology that enables the settlement of cryptocurrency transactions without the use of central bodies, exchanges, or intermediaries. It ensures faster settlement of transactions without any middlemen.
3. Minimize counterparty risk
It minimizes counterparty risk. Its basic function is to minimize counterparty risk by eliminating the โwhat ifsโ of a transaction. It is done by hashlocks and timelocks, thereby ensuring that the settlement of a transaction is 100% ensured.