Gravity devnet: SuSy gateway demo


As a part of launching Gravity’s developer network, we are unveiling SuSy, a cross-chain gateway system.

As mentioned in the  about the Gravity demo launch, the protocol’s devnet version is coming out in September. This is a stable version of the network with fixed instances of custom target chain networks. This network is designed for public testing and debugging of upcoming Gravity updates, as well as for synchronizing with regular updates of supported public networks.

The devnet scope will constantly be extended and refined to better correspond to the process of onboarding developers into Gravity. The current devnet version contains three separate subprojects: a gateway for tokens, a framework for integration tests to enable quick target chain integration and a set of images for launching a node on a one-click-deployment cloud platform or on any custom cloud provider. In addition, gateways work immediately in public testnets of integrated chains.

The devnet release is split into three separate announcements, each of them highlighting a critical functionality:

1. Cross-chain gateways

2. Integration tests for target chains

3. Deploying a Gravity node from an image.

These announcements will be made within several days of each other. In this first announcement, we will review cross-chain gateways’ practical implementation and provide a token swap demo. In the demo, the  token SIGN, wrapped into an ERC20 token, will be swapped between the Waves and Ethereum blockchains.

SuSy protocol

Gravity is a blockchain-agnostic cross-chain and oracle system that supports communication of blockchains with the outside world, cross-chain communication and sidechains within a single unified structure. Nevertheless, the protocol itself makes no attempt at solving applied problems of inter-chain communication, such as, for instance, transferring tokens from one blockchain to another.

However, Gravity is a reliable foundation for such applications, allowing them to remain trustless and decentralized. A foundational functionality required for cross-chain communication is the most basic procedure: cross-chain asset swaps. There are numerous ways of tackling the task of building gateways on top of cross-chain bridges. However, we specifically focus on an oracle-based solution of implementing token transfers, which is called the SuSy protocol (). Let us describe the technical implementation of SuSy in more detail.

For starters, let’s see how a cross-chain transfer algorithm for a token can work, using an example of a transfer from ORIGIN-CHAIN ​​to DESTINATION-CHAIN, where a token (T) will be issued as a wrapped token (swT) and sent to recipient R in DESTINATION-CHAIN.

Image for post

SuSy origin-destination cross-chain transfer scheme

As shown above, a user (S) interacts with the LU-PORT smart contract by transferring an amount (A) of the T token to it and specifying the recipient’s public address in DESTINATION-CHAIN. The gateway smart contract automatically creates a unique SWAP-ID and sets the registered status. The received funds are blocked on the LU-PORT smart contract.

Information about this event is registered by extractors, the Gravity network’s service that processes received data and communicates it to Gravity. From the Gravity framework, the oracle moves hashed data about the new SWAP-ID and directions to the verification contract (NEBULA-SC), in which the signatures of the Gravity network validators and the legitimacy of the transferred context are checked.

Upon verification, the SEND-DATA-TX transaction is called, containing a set of data and instructions for issuing and sending swT tokens to the recipient (R).

Gateway Demo

Using the SIGN token as an example, let’s try to swap it between Waves’ stagenet and Ethereum’s Ropsten testnet.

Step 1:

To start off, acquire some stagenet Waves tokens to a Waves stagenet address by using the stagenet faucet:  Next, acquire some SIGN tokens using a simple faucet dApp at 

Log in with  or . Click the Invoke button near the claimToken function and confirm the operation by signing the transaction in the wallet interface.

Image for post

Step 2:

Install  and switch the network to Ropsten Test. Create an account.

Image for post

Add the ERC20 SIGN token by clicking “Add Token”. Enter the Token Contract Address: 0x48ac40f22cdec1f767bcbd460765222f3a7ba1aa. Click on “Edit” to change the token symbol (e.g. SIGN_TST).

Image for post

Step 3:

Go to the SuSy section of the Gravity website: 

Select the direction of swap (i.e. from the Waves origin chain to the Ethereum destination chain) and enter the account address from Metamask (step 2). Select the SIGN Stagenet token and enter an amount you would like to swap. Start the swap operation and approve it in Waves Keeper.

Image for post

Image for post

Step 4:

Open Waves Explorer (stagenet) and search for the swap address using a link in Waves Keeper to check the status of the swap. Find the most recent transaction.

Image for post

Note the state changes with new swap_id and its parameters.

Step 5:

Check your ETH testnet account in MetaMask or  to see the wrapped $SIGN tokens. Note the way that the IB port received the transaction.

Image for post

In upcoming articles about the Gravity devnet release, we will discuss in greater detail the cross-chain gateway components and the token flow logic, using integration tests and the logs obtained from your own Gravity node. Stay tuned!

You may also like