> ## Documentation Index
> Fetch the complete documentation index at: https://docs.garden.finance/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# HTLCs

> Atomic swaps enable secure cross-chain swaps using Hashed Time Lock Contracts (HTLCs)

HTLCs ensure that either both parties complete the swap or both get their funds back — no party can be cheated.

## Universal concepts

Regardless of the blockchain, all atomic swap implementations share these core methods:

> [card] Initiate
>
> Start the cross-chain swap by depositing funds into the HTLC on the source chain.

> [card] Redeem
>
> Complete the cross-chain swap by redeeming funds from the HTLC on the destination chain.

> [card] Refund
>
> Get your funds refunded on the source chain, if swap does not happen within the settlement window.

> [card] Instant refund
>
> Cancel the swap and get an instant refund on the source chain during the settlement window.

## Security features

**1. Universal compatibility**

Any chain that supports SHA256 hashing and Relative Timelocks can be added to Garden.

**2. Timelock safety**

Funds can always be recovered if the counterparty doesn't participate within the specified timeframe.

**3. Address authorization**

Only designated parties can claim funds, preventing unauthorized access.

**4. Atomic execution**

The swap either completes fully on both chains or fails completely.

## Cross-chain coordination

The preimage revealed when redeeming on one chain can be used to claim funds on the other chain. This creates the *atomic* property:

1. **Initiator** locks funds on Chain A with `sha256(preimage)`
2. **Redeemer** locks funds on Chain B with the same `sha256(preimage)`
3. **Initiator** redeems on Chain B by revealing the preimage
4. **Redeemer** uses the revealed preimage to claim funds on Chain A

> [!NOTE]
>
> Both implementations use the same cryptographic primitives and security model, but differ in their execution environments and technical approaches.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.