Developers Forum for XinFin XDC Network

Cover image for [Informative] Subswap: Connecting Chains, Empowering Free Flow of Cross-Chain Assets
Galaxy
Galaxy

Posted on • Updated on

[Informative] Subswap: Connecting Chains, Empowering Free Flow of Cross-Chain Assets

What is subswap

A token cross-chain Dapp based on XDC Zero will integrate token interoperability between multiple subnets and the mainnet, and also support token swaps on the mainnet.

OK , Let’s review what is xdc zero is in case we forget

XDC Zero: A Cross-Chain Communication and Data Transfer System

XDC Zero is a cross-chain system that enables seamless communication and data transfer between different blockchains. It consists of three main components: endpoint contracts, a relayer, and checkpoint contracts.

Components:

  • Endpoint contracts: Endpoint contracts are deployed on both the source and destination chains. They serve as gateways for data transfer, receiving requests from applications on the source chain and forwarding them to the destination chain.
  • Relayer: The relayer is a critical component that facilitates data transfer between chains. It continuously monitors endpoint contracts for new data and transfers it to the corresponding endpoint contract on the destination chain.
  • Checkpoint contracts: Checkpoint contracts are responsible for verifying the authenticity and integrity of data transferred between chains. They achieve this by utilizing Merkle trees, which provide a secure and efficient way to verify data without requiring the entire blockchain to be downloaded.

Workflow:

The workflow of XDC Zero can be summarized as follows:

  1. An application on the source chain initiates a data transfer request by sending a call data to the source chain's endpoint contract.
  2. The source chain's endpoint contract stores the call data and notifies the relayer about the new data.
  3. The relayer retrieves the call data from the source chain's endpoint contract and transfers it to the destination chain's endpoint contract.
  4. The destination chain's endpoint contract requests the Merkle tree root from the destination chain's checkpoint contract to verify the authenticity of the call data.
  5. The destination chain's checkpoint contract verifies the Merkle tree root and, if valid, executes the call data on the destination chain's application.

Benefits:

XDC Zero offers several key benefits, including:

  • Seamless cross-chain communication: XDC Zero enables applications on different chains to communicate and exchange data seamlessly without the need for complex integration or intermediaries.
  • Enhanced security and data integrity: XDC Zero utilizes Merkle trees to ensure the authenticity and integrity of data transferred between chains, providing a high level of security and trust.
  • Efficient data transfer: The relayer in XDC Zero optimizes data transfer by efficiently routing data between chains, minimizing latency and transaction costs.

Applications:

XDC Zero can be applied in a variety of use cases, including:

  • Cross-chain asset transfer: XDC Zero can be used to transfer assets between different chains, such as transferring tokens from a DEX on one chain to a lending protocol on another chain.
  • Cross-chain dApp development: XDC Zero can be leveraged to develop dApps that interact with multiple chains, enabling more complex and sophisticated functionality.
  • Cross-chain data sharing: XDC Zero can facilitate the secure sharing of data between different chains, such as sharing KYC information or market data across different blockchains.

Image description

OK , We already know what xdc zero is. Let’s take a look at what subswap is and what the first xdc zero-based application consists of.

Subswap: A Cross-Chain Asset Transfer and Swapping Application

Subswap is a groundbreaking application built on XDC Zero that enables seamless cross-chain asset transfer and swapping on the mainnet.

Components:

  • Subswap contracts: Deployed on both the mainnet and subnet, these contracts facilitate cross-chain asset locking, minting, and swapping.
  • XDC Zero: Provides the underlying infrastructure for secure and efficient cross-chain communication and data transfer.

Workflow:

  1. Cross-chain asset transfer:
    • A user locks their tokens in the Subswap contract on the subnet.
    • Subswap utilizes XDC Zero to transfer the locked tokens to the mainnet.
    • The mainnet Subswap contract mints replica tokens with a 1:1 mapping to the original tokens.
  2. Cross-chain asset swapping:
    • Users can swap their mainnet tokens on the Subswap contract, e.g., tokenA for tokenB.
    • This enables trading of tokens from different subnets on the mainnet.
    • Users can then transfer their swapped tokens back to their desired subnet.

Benefits:

  • Seamless cross-chain asset transfer: Users can easily move their assets between subnets and the mainnet without the need for complex intermediaries.
  • Cross-chain asset swapping: Subswap enables users to trade tokens from different subnets on a single platform, increasing liquidity and market efficiency.
  • Enhanced security and data integrity: XDC Zero ensures the authenticity and integrity of all cross-chain transactions, providing a high level of security and trust.

Image description

Let's see what our demo can do now

First login the website
https://subswap-frontend-eta.vercel.app/bridge

1.Connet your wallet
(https://www.xdc.dev/uploads/articles/fxrcpqvxdswr877kf66a.png)

  1. choose your network Image description 3.submit your network name and network url Image description 4.switch your network Image description 5.choose your token Image description 6.choose your token Image description 7.choose the amount you want to send,and Select the address you want to receive tokens on the mainnet Image description 8.you can see the transaction on the mainnet , you can receive the token Image description

Subswap: Looking Ahead

Future Developments:

  • Enhanced Cross-Chain Functionality: Expanding cross-chain support to facilitate seamless asset movement from the mainnet back to individual subnets.
  • Mainnet Swapping: Introducing native swap functionality on the mainnet, allowing users to trade tokens directly without needing to interact with subnets.
  • Decentralized Relay Network: Building a more decentralized XDC Zero ecosystem, empowering individuals to run relayers and potentially earn rewards for their contribution.
  • Strategic Collaboration: Strengthening collaboration with the XDC team across engineering, marketing, and business development to accelerate Subswap's growth and adoption.

Discussion (4)

Collapse
0xbeny profile image
Beny

Great to see progress on utilizing and making projects around XDC Subnets

Collapse
ryan_mcbride_1759097aafd3 profile image
Ryan Mcbride

This sounds like it can be very very useful. We'll done.

Collapse
cryptosandtokens profile image
Robert Aronovici

Bringing utility to the network! Let's go!

Collapse
cifi profile image
Circularity Finance

Let us know whenever you are ready to pilot!

Love whats being developed - keep it up!