Contracts in the 21st Century
Hashed TimeLock Contracts
Since we are covering the subject of Hashed TimeLock Contracts (HTLCs) and Atomic Swaps, it’s probably best to define them. First, an HTLC is a type of smart contract – a conditional transfer where the ledger enforces the condition. The Lightning Network also uses this concept from the Bitcoin community. You may not be familiar with the term yet. However, today’s crypto payment processors utilize a very similar process. As a fact, anyone who’s made a purchase with Bitcoin or another cryptocurrency recently has probably experienced a comparable process.
Say your shopping at an online merchant that accepts Bitcoin, your shopping cart is full and you are ready to pay. You scan or paste the receiving address to your wallet. Then you enter the amount specified by the merchant. You then send the transaction to their designated wallet. It’s at that moment you’ve probably seen the countdown clock ticking away while your transaction is pending over the blockchain. If the payment receives at least one blockchain confirmation before the clock counts down to zero, there is confirmation of the payment. The clock disappears, and a pop-up message that reads “Thank you for your payment” usually takes its place.
An HTLC essentially works the same. Two parties agree to the rules of a transaction. If the party that is to receive the token generates a proof of payment by a certain time, there is confirmation of the transaction. If not, it becomes invalid and the token is refunded back to the sender.
An Atomic Swap is the exchange of one cryptocurrency to another cryptocurrency, without the need to trust a third-party. This is achieved through the use of a type of smart contract known as known as a hashed timelock contract (HTLC). As exciting as this technology is, there are some fundamental requirements before just any cryptocurrency can support an atomic swap. One such requirement is the implementation of the Lightning network. The other is the utilization of HTLCs.
As with HTLCs that link two blockchains together, the lightning network links together payment channels. For example, A wants to transact with B. For this, there must be a link for the two through payment channels. That’s the lightning network! In addition, for a transaction to occur between two different blockchains, it is necessary for both blockchains to share the same cryptographic hash function, such as SHA-256. This is to allow for the hash-time locked contract to function properly when it comes to the user providing the number that was generated via the hash function.
Between constant growth and higher levels of understanding the Lightning Network continues to look as though it is an answer to many of the major problems currently plaguing many networks. Through the ingenious use of the different attributes of the protocol, multiple networks and coins can and should work together to ensure adoption.