Atomic swaps: how 1inch powers secure cross-chain swaps
In this post, we’ll explain how atomic swap technology enables smooth, efficient and secure cross-chain swaps on 1inch.
In the highly fragmented crypto landscape, the ability to conduct swaps across various blockchains is essential. Various solutions have been developed to enable cross-chain swaps, with atomic swap technology being one of the most promising options. This technology marks a significant step towards true decentralization, enabling direct crypto swaps between two parties without the need for an intermediary.
Atomic swaps are facilitated by smart contracts that enable two swappers to exchange different cryptos from separate blockchains. The term "atomic" reflects the idea that these swaps are either completed in their entirety, or not at all: there's no room for partial completion or failure where one of the swapping parties could lose out.
For example, Alice and Bob want to exchange their cryptocurrencies. Alice has ETH on the Ethereum blockchain, and Bob has USDT on Arbitrum. As opposed to using an exchange, these two users can go for an atomic swap, ensuring that their swap either fully happens or doesn't happen at all. Smart contracts enabling atomic swaps are called hashed timelock contracts (HTLCs). This is how an atomic swap with an HTLC works:
- Agreement and secret value generation: Alice and Bob agree to swap cryptocurrencies across the Ethereum and Arbitrum blockchains. Alice generates a secret value and calculates its hash.
- Creating the first escrow contract: Alice deposits the agreed amount into an HTLC on the Ethereum blockchain, locking the cryptocurrency with a hashlock and a timelock (T1) for Bob as the receiver. This escrow contract ensures that Bob can only claim the funds if he provides the secret value within the time limit set by Alice.
- Creating the second escrow contract: Bob deposits the agreed amount into an HTLC on Arbitrum, using the same hash and a shorter timelock (T2) to ensure that Alice reveals the secret before T1 expires.
- Claiming the assets: Alice claims Bob’s cryptocurrency on Arbitrum by revealing the secret value. Once Alice reveals the secret, Bob can use it to claim the cryptocurrency locked in Alice’s HTLC on the Ethereum blockchain.
- Timelock protection: Bob doesn’t know the secret value, but if the timelock expires, he can recover the assets
This process is absolutely trustless, meaning that neither Alice nor Bob needs to trust each other or a third party to make the swap happen. The entire swap is executed automatically and securely by the smart contract.
Atomic swaps are crucial because they pave the way for a more decentralized and secure crypto space. They allow for direct, peer-to-peer trading across different blockchains, reducing the dependency on centralized exchanges (CEXes). As a result, privacy is enhanced, while the risks of hacking, fraud or other problems associated with third-party involvement are reduced.
However, while atomic swaps are highly promising, they are still relatively new and come with their own challenges, such as requiring both cryptocurrencies involved to support the same cryptographic hash function.
Nevertheless, atomic swaps represent a significant innovation in the crypto space, offering a more secure and decentralized method for exchanging digital assets across different blockchains.
On 1inch, you can swap tokens across all supported chains.
Make your swap now.
Recent Posts
Build trading agents and integrate Web3 APIs in minutes with the 1inch Business MCP
AI agents can now directly access 1inch infrastructure via the 1inch MCP, enabling them to plan and execute swaps, analyze portfolio data and interact with on-chain markets in real time.
How to set limit orders on 1inch
In this post, we’ll explain why you need limit orders and how to make
1inch launches a US DeFi education campaign
1inch is launching 1inch Forward, a US education campaign designed to close that gap. It starts with an open letter to educators and continues with a campus tour across top universities.