A Hashed Timelock Contract (HTLC) is a smart contract used in cryptocurrencies to facilitate transactions between parties who don't necessarily trust each other. An HTLC ensures that funds can only be released to the intended recipient within a certain time frame.
Here's how it works:
- Two parties agree to exchange assets, such as Bitcoin and Ether.
- They create an HTLC contract with a specific time lock and a pre-image, which is a secret code.
- The sender sends the asset to the HTLC contract, which locks the funds until the receiver provides the correct pre-image to the contract.
- The receiver has a certain amount of time to provide the pre-image and claim the funds.
- If the pre-image is not provided within the time frame, the funds are returned to the sender.
HTLCs are useful in cross-chain atomic swaps, which allow the exchange of one cryptocurrency for another without the need for a centralized exchange. They also help prevent fraud in payment channels and enable trustless micropayments.