The Countdown to Blast Off is on! 
Join the 400M $SUPRA token airdrop
Robot Image
Supra

Swapping Value Across Blockchains via Atomic Swaps

August 04, 2023 - 5 min read

A primer on moving value across disparate blockchain ecosystems and how oracles enable interoperability amongst them as a decentralized validation intralayer.

transferring-value-across-blockchains

Performing Cross-Chain Token Swaps

Cross-chain swaps allow users to transfer the value contained within their digital assets by moving it from one blockchain to another. Interoperability is achieved in this way, though the mechanics of the process are not as simple as they may sound. Cross-chain swaps are risky since they can be considered like strategic choke points for attackers; this is especially true in the case of token bridges. P2P atomic swaps are more desirable for this reason. 

Interoperability via cross-chain swaps is critical to Web3’s usefulness because there are a number of disparate blockchain ecosystems hosting a variety of assets and dApps which do not operate seamlessly or securely as of now. Thus, the ability to transfer value seamlessly and securely is the fundamental layer upon which a good user experience is based upon, which ultimately gives Web3 its utility when you really stop and think about it.

Without interoperability amongst blockchains, swapping tokens is both cumbersome and inefficient. Think about swapping ETH for LTC, as an example. Users must first find an exchange which offers this trading pair, go through a KYC process and send their ETH to the exchange, thereby giving up control over their tokens. If the exchange doesn’t offer the pair, then users must sell ether for fiat or stablecoins before purchasing the litecoins they desire.

Clearly the sending of funds, selling, buying, and then withdrawing the tokens all incur undesirable fees that we’d all rather avoid. Crypto veterans all know the uneasy feeling of waiting for transactions to go through; so eliminating wait times and opportunities for critical failures cannot be understated in its importance. 

What’s more, decentralized oracles are powering interoperability infrastructure which is optimizing the Web3 user experience by offering fast and feeless token swaps without all the aforementioned hassle. With low-latency oracles, these swaps can happen incredibly quickly. Now that you know the basics about why token swaps need optimizing, we’ll cover the basics of the two most prevalent mechanisms that facilitate cross-chain swaps before we get into how oracles fit into all of this.

Direct Peer-to-Peer Trading with Atomic Swaps

Atomic swaps are trustless, peer-to-peer exchanges of assets between two different blockchains without the need for centralized intermediaries or custodians. That means that two users can swap assets across blockchains peer-to-peer without trusting third parties to carry out their interactions. Essentially, atomic swap contracts use these two keys, two encrypted keys: hash-lock keys and time-lock keys. 

Hash-lock keys allow the users to escrow their funds, while time-lock keys are automated time constraints, so that funds are returned to their owners if either party involved hasn’t fulfilled their sides of the agreement on time. That is to say that either both parties get exactly what they wanted, or neither of them do – as funds revert to their owners once time has expired.

A brief example is probably in order so we can illustrate how this works in practice:

  1. Setup: Jill wants to swap her BTC for Jack’s LTC.
  2. Exchange Details: Jill and Jack agree on the exchange rate and how much crypto they want to swap.
  3. Generate Hash and Secret: They both generate a random string of characters, called a secret, and create a hash of that secret.
  4. Create HTLCs: Jill creates a Hashed Time-Locked Contract on Bitcoin’s blockchain. The contract specifies the conditions for their swap:
    • Jill’s BTC is locked in the HTLC and can only be redeemed with the knowledge of the secret which is generated by creating the HTLC.
    • Remember, if the swap doesn’t happen within the specified time, Jill gets her BTC back via the time-lock key.
  5. Jack’s HTLC: Similarly, Jack creates an HTLC on Litecoin’s blockchain with the matching conditions.
  6. Reveal Secret and Claim: Once both HTLCs are set up and assets are visibly in escrow, they reveal their secrets and claim their swapped assets on the corresponding chains.

Oracle Infrastructure Enables Interoperability

This process ensures that neither party can cheat, as both parties must reveal their secrets and claim tokens on their sides to complete the swap successfully. If one side attempts to claim the assets from one side of the HTLC but the other party doesn’t, it will not be possible. It’s easy to see why atomic swaps are an attractive solution for direct P2P crypto trading and the utility of Web3 more broadly. 

However, doing this securely and with a smooth UX is a difficult task to undertake without a lot of research and unfortunately, a bit more time to work out the nuances. Nevertheless, we will see projects implementing atomic swaps with more sophistication for some time to come.

As mentioned, decentralized oracles play a significant role in cross-chain swaps, especially in bridge-based swaps. Oracles are third-party node networks which fetch, validate, and deliver external data to blockchains so that automated smart contracts can use it. 

First, to swap pairs of assets, oracles either track the price pair and deliver it upon request or via batched price feeds. Otherwise, oracles could triangulate a stablecoin asset with which to determine how much of each asset is required for a direct value swap from one chain to another. This is especially needed for collateralized, bridge-based swaps. 

What’s more, oracles can validate events happening on one blockchain and subsequently report the information to another corresponding blockchain, functioning as an intralayer which supports the interoperability of information across ecosystems. That can take the form of proof of reserves and blockchain state verification, while other use cases could be more specific – like atomic swaps.

For example, if tokens are deposited in a HTLC contract on Ethereum and a corresponding HTLC is arranged on Polygon, a sophisticated and low-latency blockchain oracle will be able to validate both events and give the go-ahead for both sides to execute their atomic swaps.

Final Takeaways

It’s easy to see why there needs to be a robust, yet decentralized layer of validation which enables blockchains to communicate. People are beautifully diverse, and they hold a diverse range of assets across a number of ecosystems. 

Walled gardens will not suffice in this day and age, and consumers both desire and deserve to transact with each other seamlessly. Now let’s get out there and build the tech that offers it to them. The competition out there is fierce, and the builders are working day and night – and we salute you.

Read Next

twitterlinkedinfacebookmail

RECENT POSTS

Get news, insights, and more

Sign up for the Supra newsletter for company news, industry insights, and more. You’ll also be the first to know when we come out of stealth mode.

FREE WEBINAR

The Tech Behind Supra

Join us to learn about Supra Tech and how it's shaping the future of blockchain and the decentralized world.

Week 3

May 8, 2024 | 9 PM HKT

Webinar Speakers
PrivacyTerms of UseWebsite Data Usage & CookiesBug DisclosureBiometric Information Privacy Policy

©2024 Supra | Entropy Foundation (Switzerland: CHE.383.364.961). All Rights Reserved