Code Monkey home page Code Monkey logo

nebulas-cat's Introduction

English

欢迎使用 Nebulas Cat 星云链 DAPP 本地开发调试工具,使用过程中遇到任何问题可以到 链社区 发帖交流。

使用教程

1. 下载 Nebulas Cat 源码 git clone https://github.com/xiwangzishi/nebulas-cat.git

2. 进入 nebulas-cat 文件夹,安装依赖 npm install

3. 运行工具(合约文件更新后,需要重启调试程序):

  • 方法一(推荐):使用 Visual Studio Code 的调试功能(可以在合约里面下断点) 调试 -> 启动调试
  • 方法二:运行工具 node index.js, 然后直接在合约里面使用 console.log 打印对应信息(会输出到控制台)

4. 设置chrome 插件钱包为 localhost 网络

5. 设置 Neb.js 网络为 localhost 网络(在你 DAPP 的 JS 代码中设置) neb.setRequest(new HttpRequest("http://localhost:8685"));

6. 设置 NebPay 的 queryPayInfo API callback为 localhost 网络(如果未使用该API则跳过,此处在你 DAPP 的 JS 代码中 NebPay.queryPayInfo 处设置)


NebPay.queryPayInfo(serialNumber,{
callback:'http://localhost:8685/api/pay',
listener:undefined
})

7. 用浏览器打开 nebulas-cat 目录下的 index.html 后输入 合约文件路径,点击 部署即可使用。

原理

其实就是本地起了一个 Web 服务(基于 Koa),然后实现了 Neb.js 请求节点的一些 API ,假装自己是个记账节点而已。

目前实现的 API 有:

  • /v1/user/nebstate
  • /v1/user/call
  • /v1/user/accountstate
  • /v1/user/rawtransaction
  • /v1/user/getTransactionReceipt
  • /v1/user/getEventsByHash
  • NebPay: /api/pay
  • NebPay: /api/pay/query

点击部署按钮,就是把输入的合约文件路径 require 进来作为 Node.js 的一个模块,然后 Neb.js 的请求都是直接调用合约实例的方法,所以可以直接利用 Visual Studio Code 来调试合约功能(理论上其他 IDE 也可以,自行摸索!)。具体的源码都在 index.js 中

本项目使用了一些官方 NVM 调试工具的一些源码

联系我:d2VjaGF0Onphbmtibw==

nebulas-cat's People

Contributors

xiwangzishi avatar stv1024 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.