articleStartImage

In theory, one of the best features of smart contracts is that two parties don’t have to trust each other when making a transaction. Due to the underlying blockchain technology, double spending and getting scammed become pretty much impossible. To further the efficiency of these transactions in next-generation cryptocurrencies like Bitcoin (BTC) and Stellar Lumens (XLM), a new feature called Hashed TimeLock Contracts is being implemented.

What exactly is a Hashed TimeLock Contract?

A Hashed TimeLock Contract (HTLC) in many ways is like any other cryptocurrency transaction where two parties agree to the rules of a transaction using a cryptocurrency like Bitcoin. However, there are several elements that make it much different.

One difference is that because these contracts are “time-locked”, the party receiving Bitcoin has a limited time to accept the payment by generating “a cryptographic proof of payment”. Otherwise, the transaction becomes invalid and the BTC is refunded back to the sender.

HTLCs also use hashlocks. A hashlock is a scrambled version of a cryptographic key generated by the sender of a transaction, which unlocks the original hash used in a transaction. In HTLC, the originating party generates a key and hashes it. The hash is eventually revealed during the final transaction.

How do HTLCs work?

A typical HTLC transaction between two entities (people, IoT devices, etc.) takes place as follows:

1)  First, the sender making the payment must set up a specific hash from the sender’s private key, which represents the amount of money to be paid. A pre-image is also generated to help validate and finalize the transaction.

2)  The entity receiving the payment also generates a pre-image, as well as a hash and sends it to the sender.

3)  Once payment is received, the recipient signs the transaction using the original key that is already available to him/her in the pre-image. The sender does likewise on their end, using his/her private key to unlock the recipient’s transaction.

4)  Within a specified amount of time, the entity receiving the payment must produce the “cryptographic proof of payment” to show acceptance. Both the sender and the receiver sign the transaction using the pre-images.

Once completed, this can then trigger other actions as programmed within the smart contract. To what extent - this is limited to the imagination of developers and tech startups. For instance, it’s not difficult to see how this technology could be beneficial in real estate and lawsuit cases.

Uses and Benefits of Hashed TimeLock Contracts

There’s an assortment of benefits to these types of smart contracts that make them efficient and needed.

1)  Time Sensitivity. Because they are time sensitive, it prevents the sender from having to wait indefinitely to find out whether his or her payment went through. Nor will the sender have to worry much, since payment will be returned if it wasn’t. For instance, a real-estate development firm may need to interview and hire a contractor for a job within a limited amount of time. It would be in their interest to create hashed timelock contracts that would send contractors a down payment immediately upon approving a contractor’s plan for the job - without all the intermediaries usually needed that slow the process down.

2)  Validity of the blockchain. The cryptographic proof of payment required by the receiver helps to validate the transaction on the blockchain.

3)  Trust not needed. Due to its built-in trustless programming, each party is protected from counterparty risk.

4)  Parties conducting transactions and contracts with other nations have nothing to worry about. Just like the internet, HTLCs and blockchains are boundless and decentralized. Foreign fiat currencies are not needed in the HTLC process.

5)  In regards to cryptocurrencies, a major use for HTLCs is in cross-chain trading using “atomic swaps”. What this essentially means is being able to trade one cryptocurrency for a completely different cryptocurrency on a different blockchain - like trading Ethereum for Bitcoin without an intermediary currency like the US dollar. In addition, hashed timelock contracts could also become the main ingredient of the potent Lightning Network, a coveted scaling solution for Bitcoin’s bloated blockchain.

The Lightning Network

The upcoming Lightning Network (LN) implements HTLCs, in turn allowing payments to be safely routed through many different peer-to-peer payment channels. Any peer on the network can pay another peer, even if they don't have a direct channel open between each other. Essentially, LN will enable “off-chain” transactions. This will be huge for Bitcoin and cryptocurrencies as a whole, enhancing the speed of transactions many times over, as well as lessening their associated costs.

Key features include:

1)  Trustless network. Without an intermediary, two peers in a channel can pay each other effortlessly, just like in any other Bitcoin transaction.

2)  Super fast payments. Payments can virtually travel as fast as any piece of data would over the internet. In fact, if both parties cooperate, a channel can be closed immediately.

3)  The blockchain is less bloated. Most payments within Lightning Network channels can remain uncommitted to the blockchain, allowing reduced load on blockchain nodes that process transactions.

4)  Programmable enforcement. If one party attempts to steal money by closing a channel prematurely, the other party has a specified block of time to stop it.

5)  Optional security measures. For instance, each party can require there be signatures by multiple keys, providing additional security.

6)  Transactions across blockchains. Like atomic swaps, payments can be routed across more than one blockchain as long as they all support timelocks, as well as the same hash function to use for the hash lock.

Developers are hoping to unleash Lightning Network on all of Bitcoin’s nodes by the end of 2018. However, there are potential kinks LN may encounter. For instance, while LN will indeed unclog Bitcoin’s network considerably, it is still questionable how much it will lessen Bitcoin’s exorbitant transaction fees. Afterall, congestion is only one cause for Bitcoin’s high fees. The exponential increase in Bitcoin’s transaction volumes is largely attributed to its equally accelerated rise in trading volumes. Consequently, the overall effect of the Lightning Network on reducing Bitcoin’s transaction fees may be limited.

A Challenge for Hashed TimeLock Contracts

Like many aspects of blockchain and cryptocurrencies, the technology is still in its infant years and there’s still much work that needs to be done. The most difficult challenge for mass adoption is it’s foreign to just about everyone.

Humans are creatures of habit, and they’ve been doing transactions the same way for centuries. Governments and other institutions are used to major transactions being done with the help of lawyers, notaries, and banks, and now blockchain and HTLCs are supposed to do away with all that? Not without a lot of scrutinizing and a big heap of regulation for years to come.

It took at least a decade for businesses and people to fully embrace email and PayPal payments, and it may take at least a decade for them to learn about cryptocurrency payments and HTLCs. Satoshi Nakamoto first introduced us to Bitcoin and its amazing technology almost 10 years ago, yet a sizable majority of this planet doesn’t even know what blockchain is. Still, adoption rates across the world may be faster than even experts can anticipate. Afterall, anyone noticed the price of Bitcoin last year? That’s one way to get people’s attention.

Conclusion

Hashed TimeLock Contracts are doing more than just improving the transfer of “nerd money”. The technology is helping the crypto-industry reshape their understanding of cryptocurrency payments. It won’t be long before the whole world will gain a new understanding of the word “value” and how to transfer value efficiently with blockchains and cryptocurrency payments.

Hashed TimeLock Contracts are a natural evolution of the way we write contracts and perform transactions, born out of the maturing internet. Given all the ways parties can be scammed, the internet needs an efficient method of transacting value and HTLCs is making that happen. As long as we continue to be connected by the internet, HTLCs help to eliminate friction and transactional risks that come with complex engagements between businesses, institutions and even nations.

Furthermore, if new blockchain technologies like atomic swaps and the Lightning Network gain steam, then it is possible that more and more cryptocurrencies will adopt the use of Hashed TimeLock Contracts besides just top cryptocurrencies like Bitcoin, Stellar and Ethereum (ETH). Time-sensitive “conditional payments” can be exceptionally beneficial to the whole blockchain industry. The opportunities are limitless.