Dapp Development Guide

1.Requirement

2.Dapp Template Structure

Download NASGO-DAPP-Template form github repository

dapps/your dapp id/
├── blockchain.db        
├── config.json                                                                   
├── contract              
│   └── mycontract.js        
├── dapp.json             
├── genesis.json           
├── init.js               
├── interface             
│   └── api.js
├── logs                  
├── model
│   └── table.js    
└── public
    └── css
    └── js
    └── index.html

3. Customize Your Dapp Configuration

3.1 dapp.json

  • Dapp Name #The name of Dapp, e.g. "Hello World"

  • Dapp Descryption #The description of Dapp

  • Delegates List #Input the list of public keys of DApp's initial delegates, seperated by comma. you should specify at least 5 delegates

    {
      "name": "Hello World",
      "description": "My first Dapp",
      "delegates": [
        "13ef60173dcf2a050dacfabb21600bae54200c341fad67031231eacd02c4420e",
        "01c07dab1eff8f9f00dcb88b6c3ba706c0fe10dbe8f0bd72cc10c998182d238e",
        "b15d9a5c7522e38bb02c0d4c7639d16dc3395f261e48c16133a7b64bd4b571cc",
        "3757568499c5710bc2d895d8227448a504b13cd5030e24f9ee477f638e8d1b63",
        "ed21df88c5cca5afc14c34b613b05fc8ce55dc74256eb35a62d020a798fe48a7"
      ]
    }
    

4.Implement Your Dapp

  • Define your data model of Dapp
  • Implement contract of Dapp
  • Implemet Http Interface of Dapp

5.Deploying your Dapp on Mainnet

  1. create genesis block
./nasgo-dev createGenesis -e "account secret"

​ copy result and paste into genesis.json

{
  "delegate": "eec16080247e802ed2e1b9ca14a8f64a3263bcd65a954db1edadfb98be131f86",
  "height": 1,
  "pointId": null,
  "pointHeight": null,
  "transactions": [],
  "timestamp": 0,
  "payloadLength": 0,
  "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  "count": 0,
  "signature": "68fa8253ca25a1917736bea091ea80be320bc573e2c29ae00312b25bc736f45ffe7bb430ef6616951e2adc2f025f534302715095d5620abce9d85471ac909804",
  "id": "643c18eaef0cf24191b75bbf2f7bca05de4eb381769d3c2b09b3be18137e4bff"
}
  1. Deploy in NASGO Mainnet
./nasgo-dev publishDapp -f path/to/dapp.json -e "account secret" -s "sercure code if set"

you will get a transaction id if your dapp is deployed in NASGO MainNet successfully

3654a6100280df0d296653e89177b9011304d971fb98aba3edcc5b937c4183fb

notice: the transaction id is used as your Dapp's ID

6.Running your dapp

  • Rename your dapp project folder's name to the deployment transaction id

  • move your dapp project folder into NASGO-Node-root-directory/dapps

  • restart NASGO-Node

    ./nasgo stop
    ./nasgo start
    
  • Access your dapp in browser

    http://NASGO-Node's IP:9040/dapps/dappid
    

results matching ""

    No results matching ""