標籤:星雲鏈智能合約開發 星雲鏈Dapp開發 星雲鏈智能合約Dapp開發 Dapp開發
安裝neb.js
neb.js提供javascript開發的API介面
- 建立一個neb檔案夾,在終端命令列中進入該檔案夾,複製neb.js
git clone https://github.com/nebulasio/neb.js.git
- 會建立一個neb.js檔案夾,進入該檔案夾,安裝所有依賴
npm install
- 安裝gulp
npm install gulp
- 打包產生neb.js等檔案
gulp
- 執行成功會產生/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開發