Introduction to Asch Dapp Development

As mentioned in the white paper, Asch applies a side chain architecture different from that used in Ethereum and Bitcoin: dapp runs on the side chain and each side chain corresponds to one dapp.

Independence of side chain

The side chain architecture has an advantage that the code is independent from the data, which releases the burden on the main chain and avoids an excessive data expansion. As a matter of fact, it is a natural fragmentation mechanism. The side chain has a separate block chain, an independent trustee or witness, and a separate node network, that is, the block produced by the side chain is broadcast only between the nodes installed with the side chain.

Independence is both an advantage and a disadvantage. After developing the dapp, a developer still have to consider the operation and maintenance, that is, it requires enough nodes for running to ensure adequate security. Therefore, compared with Ethereum, the independence is a flaw of the side chain; once Ethereum releases a dapp, all nodes can work for it and provide security for it.

Flexibility of the Side chain

The side chain architecture still exists since not all applications need very high security. Asch provides the user with a choice of flexibility. For example, assuming that Asch has 1000 nodes, some of the dapp is more important and they need 500 nodes to run it, while some dapp is not so important, maybe only 100 nodes is enough, the number is entirely determined by the user and the developer. In the Etherium platform, you have only one choice with all the nodes to run it. It is said that the Etherium platform will have a fragmentation mechanism in the future. Actually, Asch platform has solved this problem long time ago. In addition, for applications with more importance and more security requirements, we can still choose to develop the applications on the main chain, but it is impossible to give this right to all the developers, in order to avoid the expansion and out of control (DAO events) of the main chain.

The flexibility of the side chain is also shown with the fact that all the block chain parameters can be customized, such as block spacing, block rewards, transaction fees, etc., advanced users can also modify the consensus algorithm. But the most important thing is the business strategy. The side chain can be easily developed with your business-related transaction type or smart contract. This is different from the side chain developed by the blockstreams, whose side chains is just a different currency system, and it is not easy to develop new transactions and smart contracts.

As shown in the figure, the black circle represents a node, and 64 nodes form the network of the main chain. In the red box, it is №1 side chain, whose side chain network is composed of 12 nodes. In the blue box, it is the №2 side chain, whose network is composed of 36 nodes.

The mutual beneficial relationship between mainchain and sidechain

It’s a mutual beneficial relationship of Asch’s mainchain and sidechain in which the mainchain provide infrastructure for side chain, such as database write API, network communication API, encryption API, etc., and side chain can be added more nodes to strengthen the whole system of Asch in return. The sidechain developers do not need to provide all the machines but to use the existed mainchain node as long as the node owner install this application. In addition, XAS which is the token of mainchain can be transferred into the sidechain, providing a valuable medium for the assets of sidechain since XAS can be traded on the exchange. So the sidechain asset can be converted into XAS directly after issued without considering to list on the exchange.

Solve the problem of productivity

We provide a set of templates for the sidechain in SDK, which can also be called scaffolding or development framework. Since most of the underlying functions of sidechain are written, the developers of DAPP only need to care about the specific business logic, which means the same development difficulty of DAPP with Ethereum at this point. The sidechain framework of Asch use nodejs as the language, and we build lots of commonly used library for developers to use directly, of course, developers can also install what they need, there is a huge javascript community behind.

Following is the built-in module of Asch:

Solving security problems

The security issues here are different from those mentioned above because of insufficient nodes. The security problem here refers to the code of side-chain that infringes the installer.We want each node of Asch to install a side-chain, and the owner of the node of Asch does not need to trust the developers of the side-chain.

This requires a security precaution, such as preventing the code of side-chain from reading the file system and performing network operations. In the Asch system, the code of side-chain will start with a sub process, then the subprocess firstly will be loading a virtual machine of JavaScript , insulated with sandbox isolation mechanism, this virtual machine of JavaScript is a naked virtual machine without require and any extra module.Then we implanted a custom require and some commonly used and secure modules for the virtual machine, and loaded the code of side-chain finally . We also provide a series of API through interprocess communication. In this way, the frame of side-chain has enough API, and the installer of side-chain has no risk at all.

Case tutorial

Next, we will provide a tutorial from the shallower to the deeper, which will help developers get started quickly.

Dapp development tutorial — Asch Dapp Hello World

This document will teach you how to create and publish a basic side chain application, and introduce the source structure of the side-chain framework.