Foreword

As a distributed ledger technology, blockchain can be used in various sectors, such as finance, health care, supply chain, and asset management. However, limited throughput and scalability and network isolation prevent blockchain projects from better serving business applications. Among these limitations, network isolation hinders the collaboration between different blockchains and significantly limits what blockchain can do.

Introduction

In the previous articles, we introduced the key components of the Ontology multichain design, the block header synchronization contract, and the cross-chain management contract, through which cross-chain transactions are validated. In today’s article, we will introduce the ONG(x) contract, dApp contract, and Relayer. The former two are contracts that carry out cross-chain business while the Relayer is responsible for synchronizing cross-chain messages for a certain amount of mining fee.

Anyone can be a Relayer without registration, as long as they deploy an operation state information synchronization program and perform the synchronization work.

ONG(x) Contract and dApp Contract

ONG(x) contract is an ONG asset contract that enables cross-chain asset transfer. On the basis of the ONG contract, the ONG(x) contract also added the Lock and Unlock API:

Lock API

The Lock API locks assets on the chain and invokes the cross-chain management contract, which then puts the transaction into the Merkle Tree.

2. Unlock API

The Unlock API unlocks assets on the chain. The cross-chain management contract invokes this API and sends the validated transaction parameters to the API, which then unlocks the assets based on the parameters.

dApp contract is the cross-chain contract implemented by users. Apart from the business logic of users, the dApp contract also requires a certain number of APIs similar to Lock and Unlock API, which can be invoked by the cross-chain management contract.

Relayer

Anyone can be a Relayer, as long as they deploy an operation state information synchronization program, continually monitor the cross-chain request of cross-chain contract and the epoch switch block, and synchronize the cross-chain transactions or block headers.

For each cross-chain transaction or block header, only one Relayer can submit successfully. After the cross-chain transaction is submitted successfully, the Relayer can then receive the incentives for cross-chain interaction. The Relayer does not need to stake tokens and they can decide whether to synchronize transactions with low mining fees by setting a threshold for mining fees.

During the cross-chain interaction process, Relayers need to synchronize two types of key information: key block headers and cross-chain transactions. Cross-chain transaction fees are paid by users to Relayers who sync the data. Key block headers may not include cross-chain transactions, therefore there might be no one who will pay the fees for syncing the key block headers. However, since key block headers will affect cross-chain transactions during the entire round, if no Relayer will sync the key block headers, then cross-chain transactions after this key block header in the entire round will not be able to proceed. Therefore, a portion of the cross-chain transaction fees in the entire round will be used to incentivize Relayers who sync the key block headers.

Figure: Transfer of Mining Fee from Main Chain to Side-Chain

Users of cross-chain transactions can submit state information themselves, or they can include a mining fee in a cross-chain transaction to entrust the Relayer to synchronize the transactions. Specifically, when the user conducts a cross-chain transaction on the source chain, it needs to lock an amount of ONG or burn an amount of ONGx as the mining fee. After the Relayer monitors the cross-chain request, it will look at whether the mining fee is higher than the threshold it set to decide whether to submit this cross-chain transaction.

When it is higher than the mining fee threshold set by itself, the Relayer will submit the cross-chain transaction to the target chain. After the cross-chain transaction is successfully executed, a corresponding amount of ONG is released on the target chain or a corresponding amount of ONGx is issued as the mining fee for the Relayer who submitted the cross-chain transaction.

Figure: Transfer of Mining Fee from Side-Chain to Main Chain

Afterword

We will share more about the Ontology multichain design in future tech point articles. Also, the Ontology cross-chain TestNet was launched in May and we have prepared detailed Developer Manual and video tutorials for fellow developers. Try developing on the TestNet and give us your feedback.

Ontology Multichain Documentation Link:

Ontology Multichain Developer Manual

Cross-Chain Tutorial

Video Tutorials Link:

Ontology Multichain TestNet

Ontology Cross-chain Contract Development