Словник

Hashed Timelock Contract (HTLC)

A hashed timelock contract (HTLC) is an agreement between two parties that requires no trust between two users by offering special features to reduce risk.

What Is Hashed Timelock Contract (HTLC)?

A hashed timelock contract (HTLC) is a distinct feature in the form of a time-locked escrow that is mainly used while creating smart contracts which enable the creators to modify the payment channels.

In basic terms, it is an agreement in which the receipt must be confirmed by the receiver or the beneficiary before a preset date or deadline, and failing to do so will result in the receiver losing the ability to claim the payment. The receiver must acknowledge the payment before the deadline.

There are two main terms that you should know in a hashed timelock contract:

  1. Timelock - It is a function that limits any transacting from the funds of the contract until the receiver affirms the payment before a pre-decided time. This is enabled using Bitcoin commands. If this is not done, the paying party can claim a refund.
  2. Hashlocks - This is a passphrase to claim the funds. The recipient must input the correct phase to gain access to the funds.

The hashed timelock contract feature is used for safe transfers through bidirectional and routed channels, the contract functions without any trust from either party.

How Does the Hashed Timelock Contract Work?

The hashlocks and timelocks are the most pivotal and important components that come into play while settling the contract.

Firstly, the paying party generates a code or password phase and hashes the code. This is known as the hashlock phase which is the restricting mechanism. The hash is protected until the final transaction takes place.

Next, the timelock mechanism is used by setting a set of timelocks to restrict future transactions. One of the timelocks is called a Check Lock Time verify. This sets a base time to release and limit the funds. The next timelock is known as Check Sequence Verify, this timelock keeps a count of the number of locks created to aid with finalizing the transaction.

Application of Hashed Timelock Contract

HTLC is mainly used in the Bitcoin Lightning network to allow users to transact through interconnected channels. The main issue that users face in p2p transactions is trust. This is solved by using the Hashed Timelock Contract as it requires no level of trust from either party. This allows two users to transact without being directly connected with one another through a payment channel - a process known as network routing. HTLC enables other users to aid the transaction and the hashlock and timelock prevent other users from impeding the transaction.

Advantages

Reduced Risk 

The main problem that HTLC solves is the risk of transacting. The contract greatly reduces the counterparty risk through hashlock and timelock mechanisms. 

Atomic Swaps 

Going by the name, these swaps are smart contracts that remove the need for any intermediaries or exchanges with the help of hashed timelock contracts.

Reduced Delays 

With the help of the timelock mechanism, the contracts are settled on a pre-determined deadline which eliminates the chances of a delay in the settlement of the contracts.