Dapp Development Tutorial One Asch Dapp Hello world

Source: Internet
Author: User
Tags config empty json zip git clone
1 Basic Flow

Asch has three kinds of net,localnet,testnet,mainnet, the latter two are published to the online, can be accessed through the public network. The first type of localnet is a private chain that runs locally and has only one node, primarily for local testing and development purposes. The development of DAPP also involves these three kinds of networks, namely the first step, the second step in localnet development, local testing, the third step in the Testnet test, officially released to Mainnet 2 launch localnet

Each developer can launch their own localnet locally and need to download the Asch source code first.

git clone Https://github.com/sqfasd/asch

After the download, you can refer to the project's readme for subsequent installation and operation. 3 Installing ASCH-CLI

NPM instal-g ASCH-CLI

Note This step do not use Taobao cnpm, there is a bug 4 to create an application locally

First go to your Asch source directory and make sure LocalNet starts

CD <asch source code dir>
node App.js

Then use the ASCH-CLI DAPPS subcommand to create the app

ASCH-CLI dapps-a

Next, we're going to answer a series of questions to generate the application's Genesis block

?
Enter Secret of your Testnet account ******************************************************************************* # Here you need to enter a Genesis account, which can be any common Asch master password (the one with 12 words)? Enter second secret of your testnet accounts if you have set up a two level password on the creation account, the default is no, we directly enter the return? Enter Dapp name Hello Dapp # Dapp, we entered the Hello Dapp? Enter Dapp Description Hello World Demo for Asch Dapp # Dapp Description, can be empty? Enter Dapp Tags Hello,asch,dapp # Dapp tags, in order to better search in the future, can be empty? Choose dapp Category 1) Common 2) Business 3) Social 4) Education 5) Entertainment 6) News (Move up and down t O reveal more choices) Answer: # Dapp Type, you can choose any of your dapp's business scope or domain, enter the number in the list? Enter Dapp link Https://github.com/sqfasd/asch-hello/archive/master.zip # Enter the Dapp source of the compressed package, must be at the end of the zip, installation needs to be downloaded through this link? Enter the URL of dapp icon URL https://www.asch.com/logo.png # Dapp? Do you want publish a inbuilt asset in this Dapp? No # Do I need to have an asset built into the DAPP, we don't need this option at the moment and enter no? Enter public keys of Dapp Forgers-hex array, use ', ' for separator8065A105C785A08757727FDED3A06F8F312E73AD40F1F3502E0232EA42E67EFD # Enter Dapp's initial trustee public key list, separated by commas, and later Dapp trustees can be dynamically added, So we just need to enter a key to the Genesis account Creating Dapp Genesis block fetching Asch Dapps SDK saving Genesis block saving Dapp Meta Informatio N Registering Dapp in localnet do (Dapp ID is 6299140990391157236) # then the program will automatically register the application on the localnet, in this case our app ID is 62991409
 90391157236
5 directory Structure

We can view Dapps a new directory is added below, and the directory name is the ID of the newly created Dapp

Ls-1 dapps/<dapp id>

blockchain.json         # Dapp database describes
the             configuration file for Config.json # Dapp, primarily a list of seed nodes, similar to the primary chain configuration, Developers can also add other custom configuration
dapp.json               # Dapp meta-information, including name, description, source package, etc., this file can be used to re-register on different networks using the
Genesis.json            # creation block, Command line generated automatically, you can also write your own program generation, so you can more flexibly allocate the assets of the Genesis account
index.js                # Dapp's entry file
init.js                 # The initialization code for each module here
LICENSE                 # source License Description
Modules                 # main code here
Modules.full.json       # need to load the module configuration, if you need to add a module, can be configured
here Modules.genesis.json    # (simplified version of module configuration, not required temporarily)
node_modules            #
Package.json            #
Public                  # front-end directory
Routes.json             # HTTP Routing configuration, if you want to add a new interface, you need to modify this configuration file

If developers feel complex, do not need detailed investigation, first of all, probably understand. The most relevant files for developers are in the modules/contracts/directory and we see that this directory already has 4 built-in contract types.

Ls-1 dapps/<dapp id>/modules/contracts/

delegates.js            # Trustee Registration contract
Insidetransfer.js       # Intra-Link transfer contract
outsidetransfer.js      # xas Reload contract
Withdrawaltransfer.js   # Xas withdrawal contract

What developers need to do is create new contracts to express your business logic, that's all. No other unrelated code needs to be understood. 6 Configuring the Dapp creation key

We need the master password and the corresponding Dapp ID that we used in the Genesis block in the Config.json dapp field configuration.

When you publish to the official network in the future, you also need a node to configure the key, which requires only one

"params": {
  "6299140990391157236": [
    "Someone manual strong movie roof episode eight spatial Brown soldier soup mo Tor "
  ]
}
7 access Front end

OK, now let's relax, open the Dapp front link and experience the basic functionality of the side chain. You can find the Dapp portal in the list of installed apps in the Wallet UI or directly access the Urllocalhost:4096/dapps/<dapp of Dapp id>

In this Hello World project, we can do top-up, intra-link transfers and withdrawals. The current recharge can only be operated by command (in the main wallet later), and other functions can be operated directly on this interface.

Asch-cli dapps-d

? Enter Secret *******************************************************************************
? Enter amount
? Dapp Id 6299140990391157236
? Enter secondary Secret (if defined)
? Host and port localhost:4096
null {success:true, TransactionID: ' 10589988261732949004 '}
10589988261732949004

Recharge and withdraw operations are 30 seconds to refresh, we wait a moment, we can see the balance on the interface refreshed.


About Asch system and blockchain development issues, welcome to add QQ Group 485979564, together with the exchange.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.