SUN Network DAppChain Developer Documents: Cross-chain Details

TRON DAO
TRON
Published in
3 min readAug 19, 2019

4.1 Overview

DAppChain contains 3 main components for cross-chain interaction: MainChain gateway contract, Oracle service, and Side-chain gateway contract.

Oracle listens to the messages from the main-chain gateway contract and the side-chain gateway contract, and realizes the interactive communication between the main-chains and side-chains. When more than 2/3 of the oracle nodes confirmed an cross-chain transaction, the transaction can be considered to be valid.

Cross-chain interaction can be classified as 3 main type: TRC20/TRC721 contract mapping, asset deposit, and asset withdraw.

4.2 TRC20/TRC721 contract mapping

Asset owner need to trigger TRC20/TRC721 mapping function to approve access for the asset to migrate to side-chain. The asset can be mapping to side-chain automatically, and no one need to deploy by themselves.

Steps:

  1. Deployer should own(deployed) an TRC20/TRC721 contract on main-chain.
  2. Asset Deployer should trigger mapping function in gateway contract for owned TRC20/TRC721 contract. Gateway contract will verified the ownership. If verified, an deploy event will be event.
  3. Oracle catches the deploy event.
  4. Oracle trigger side-chain gateway contract to create TRON standard side-chain TRC20/TRC721 contract, and do a cross-chain mapping.

4.3 Deposit

User uses deposit function in gateway contract for asset migration to side-chain purpose.

Steps:

  1. When migrate TRC20/TRC721 token, user need to trigger an approve function in TRC20/TRC721 contract on main-chain.
  2. User triggers deposit function in MainChain gateway contract.
  3. Oracle catches deposit event.
  4. Oracle call function in SideChain gateway for asset migration.
  5. For TRC20/TRC7212 token, side-chain will mint specific amount of token in the mapped contract, while TRX/TRC10 token will be added directly on user account.

4.4 Withdraw

User uses withdraw function in gateway contract for asset migration to main-chain purpose.

Steps:

  1. When migrate TRC20/TRC721 token, user need to trigger an approve function in TRC20/TRC721 contract on side-chain. Gateway contract would call TRC20/TRC721 contract directly due to our customization.
  2. Oracle catches the withdraw event.
  3. User calls the withdraw function on main-chain.
  4. MainChain gateway contract calls TRC20/TRC721 contract for withdraw operation, while TRX/TRC10 would be able to send directly to user account.

--

--