Blockchain Short Story 011: Hashed Time-Lock Contracts (HTLCs)

Ivica Aračić
Blockchain Short Stories
2 min readAug 5, 2023

--

A Hashed Timelock Contract (HTLC) stands as a prominent solution for achieving interoperability and reducing counterparty risks during cross-ledger transactions involving the delivery-versus-payment of assets. This mechanism facilitates the secure exchange of assets between two distinct ledgers, be they centralized or decentralized, without the necessity for a direct technical linkage between the two systems.

Example

Assuming Alice wants to trade with B an asset on Ledger A versus an asset on Ledger B, the steps are as follows:

  1. Alice creates a secret key and a hash of that secret key.
  2. Alice locks assets on Ledger A in a HTLC using the hash in the way that as soon as the secret corresponding to the hash is presented, the assets are transferred to Bob.
  3. Alice shares the hash with Bob
  4. Bob symmetrically locks assets on Ledger B using the same hash in the way that as soon as the secret corresponding to the hash is presented, the assets are transferred to Alice.
  5. Now Alice can use the secret key to claim the assets on Ledger B. In the same moment the secret is revealed.
  6. Bob uses the revealed secret to claim the assets on Ledger A.

Additionally there is a time-lock involved, which will ensure that assets are locked for a pre-defined time period and that the HTLC can be cancelled after the time-lock expires.

Limitations

In scenarios where the network is congested or the parties are slow to act, operational delays can lead to the timeout being reached before Bob can claim assets on Ledger A. In this case, Alice could cancel the HTLC on Ledger A even though the payment on Ledger B has already been settled. This would necessitate conflict resolution outside of the blockchain. The risk of timeouts can be reduced by automating the unlocking process so it can be as soon as the secret has been revealed.

--

--

Ivica Aračić
Blockchain Short Stories

writing short stories on blockchain / DLT in the finance industry