What is a hash time-locked contract and how does it protect a cross-chain swap
A hash time-locked contract (HTLC) is a smart contract that requires the receiver of a payment to acknowledge it within a set time by revealing a secret, or else the funds return to the sender. It protects a cross-chain swap by making the transaction atomic: either both sides of the swap happen, or neither does, eliminating the risk that one party takes the other's coins and disappears.
Swap crypto
Live rates · no accountSend exactly to:
This asset needs a memo / tag. Send it with or the exchanger cannot credit your deposit.
You receive about at . Exchange reference .
Status: waiting for your deposit
You send from your own wallet straight to the exchanger — nothing to connect, no account, and you stay on this page throughout. Rates are indicative until a swap is opened.
The swap is carried out by an independent exchanger and the deposit address above is theirs. rosiesol.xyz never holds, receives or controls your funds, has no key to that address, and earns a referral commission. Opening a swap sends your receiving address, IP, browser and timezone to the exchanger for their compliance checks; we store none of it. Check their terms, fees and country restrictions before sending anything.
Think of an HTLC as a conditional payment with a deadline. The contract locks funds on one blockchain, and the recipient can only claim them by providing a cryptographic hash preimage - a piece of data that, when hashed, matches a value the sender chose. The same hash is used across both chains. If the recipient never reveals the preimage, the sender gets the funds back after the timer expires. This design is the backbone of "getting an asset from one chain to another without a bridge or a centralised account," the subject of the hub page you are reading now.
Here is how it works in a swap between two people, Alice and Bob. Alice wants to send Bitcoin to Bob in exchange for Ethereum. They agree on amounts. Alice creates an HTLC on the Bitcoin blockchain that locks her Bitcoin. The contract says: Bob can claim this Bitcoin if he provides the preimage for a specific hash before a deadline. If he does not, Alice can reclaim her Bitcoin after the deadline.
Alice sends the hash to Bob. Bob, seeing the locked Bitcoin, creates his own HTLC on the Ethereum blockchain. His contract locks his Ethereum and says: Alice can claim this Ethereum if she provides the same preimage before a different deadline. Crucially, Bob's deadline is earlier than Alice's. This asymmetry is deliberate. It prevents a situation where Alice reveals the preimage, claims Bob's Ethereum, and then Bob still has time to not claim the Bitcoin, leaving Alice empty-handed.
Alice now has the Ethereum locked. She can claim it by revealing the preimage to the Ethereum contract. When she does, the Ethereum contract releases the funds to her, and the preimage becomes visible on the Ethereum blockchain. Bob, watching the Ethereum chain, sees the preimage. He now has the information needed to claim the Bitcoin from Alice's HTLC on the Bitcoin chain. He does so, and the swap completes.
The protection is straightforward. Neither party can cheat. If Bob never creates his HTLC, Alice's Bitcoin remains locked only until her timer expires, then she reclaims it. If Bob creates the HTLC but Alice never reveals the preimage, both contracts expire and both parties get their coins back. If Alice reveals the preimage to claim the Ethereum, Bob is forced to see it and can claim the Bitcoin. The swap is atomic - it either fully settles or fully unwinds.
The time-locked part is what makes it safe for peer-to-peer swaps. The receiver has a window to act. The sender has a window to recover. The contracts do not need to trust each other or any third party. They rely only on the properties of the underlying blockchains and the cryptographic hash.
HTLCs are not a complete solution for cross-chain swapping. They require both parties to be online and responsive within the time windows. They also assume the blockchains involved can support the necessary scripting, which most major ones do. For a fuller picture of the process, including how the order book finds your counterparty and what happens when timers expire, read the sibling pages linked from the hub.
Not financial advice. rosiesol.xyz publishes market data and general information about Rosie. Crypto assets are volatile and you can lose everything you put in. Nothing here is a recommendation to buy, sell or hold, and we make no price predictions.
Prices are sourced from third parties and may be delayed or wrong. Verify anything you intend to act on against a primary source.