Hashed Timelock Contracts (HTLCs) and How They Work

By Ether Crunch | Ether Crunch | 12 Jun 2024


 

0*jpAGAa533S_ORPPt

A Hashed Timelock Contract or HTLC, is a type of smart contract that is used in many blockchain applications. The value of an HTLC comes from the fact that it expires after a certain timeframe. An HTLC has many components that work similarly to other transactions/contracts, except for two major aspects:

  • Hashlock: A hashlock is generated by the party that initiates the transaction, and it is a “hashed version of a public key.” This hash is then stored and in the final stage of the transaction, it is revealed along with the associated private key, allowing the transaction to be completed. The Hashlock initiates the transaction with some basic restrictions.
  • Timelock: There are two different timelocks in an HTLC: CheckLockTimeVerify (CLTV) and CheckSequenceVerify (CSV). CLTVs track the time, by hardcoding the time, and releasing the coins only when it reaches a specific time/date. CSVs, on the other hand, don’t track time; instead, they track the number of blocks generated, which it uses to track the time. Once a certain number of blocks have been generated, the transaction expires or is completed. The Timelock ensures that the transaction is validated in a certain timeframe.

hashlock time contract digital art space

Many applications use HTLCs, like Atomic Swaps, Bitcoin’s Lightning Network, or ICOs (Initial Coin Offerings). HTLCs offer many advantages: reduced counterparty risk, execution within a certain timeframe, and proper validation and privacy. Counterparty risk is when one party does not meet the obligation in a certain transaction; they fail to meet the terms of the contract. HTLCs reduce this risk by incorporating a strict timeframe and using a hashlock.

If you want to learn more, check out the links below:

Hashed Timelock Contract (HTLC): Overview and Examples in Crypto

⭐Hashed Timelock Contract (HTLC)

Hashed Timelock Contract

Thank You for Reading

If you like this article, consider reading my other articles

Ether Crunch - Medium

How do you rate this article?

52



Ether Crunch
Ether Crunch

Basics to blockchain, crypto, and ethereum.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.