星雲鏈智能合約開發(七):Dapp開發

來源:互聯網
上載者:User

標籤:星雲鏈智能合約開發   星雲鏈Dapp開發   星雲鏈智能合約Dapp開發   Dapp開發   

安裝neb.js

neb.js提供javascript開發的API介面

  1. 建立一個neb檔案夾,在終端命令列中進入該檔案夾,複製neb.js
    git clone https://github.com/nebulasio/neb.js.git
  2. 會建立一個neb.js檔案夾,進入該檔案夾,安裝所有依賴
    npm install
  3. 安裝gulp
    npm install gulp
  4. 打包產生neb.js等檔案
    gulp
  5. 執行成功會產生/dist檔案夾,檔案夾中會產生我們要使用js檔案。
    • neb.js:Used in browser side. Including outside dependency.
    • neb-light.js:Used in Repl console. Not including outside dependency.
    • nebulas.js: Fully functional in the browser. Users can create an address, sign a transaction, and deploy/call a smart contract.
安裝nebPay

NebPay SDK 為不同平台的交易提供了統一的支付介面,開發人員在Dapp頁面中使用NebPay API可以通過瀏覽器外掛程式錢包、手機app錢包等實現交易支付和合約調用。

github地址:https://github.com/nebulasio/nebPay

安裝方法同上。會產生nebPay.js檔案

開發Dapp

要實現的功能非常簡單:

  • 調用合約中的save方法發布資訊
  • 調用合約中的read方法讀取資訊
建立項目

將前面產生的nebulas.js和nebPay.js放在libs檔案夾下,我的目錄結構如下:

index.html源碼
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>星雲鏈Dapp</title></head><body>    <div>        <h1>發布資訊</h1>        <div>標題:</div>        <div><input type="text" id="title" style="width:370px"/></div>        <div>內容:</div>        <div><textarea cols="50" rows="10" id="content">

星雲鏈智能合約開發(七):Dapp開發

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.