Coder Social home page Coder Social logo

fabton's Introduction

Fabton

Fabton是一个针对Hyperledger Fabric的脚手架工具,用户可在配置文件中定义模型和属性,来快速生成一个规范的Fabric应用项目。

设计思路

典型的fabric应用开发流程是这样的:
部署区块链网络->新建通道->加入通道->编写合约->安装合约->发布合约->客户端(cli或sdk)调用
其中,最核心的步骤在于编写合约,为了方便合约的开发,fabric提供了dev mode,是开发者能够省略安装、升级等步骤,但仍然不够方便。
fabton框架希望简化fabric的应用开发流程,提供一站式的开发、调试环境

特性:

  • 根据用户定义的模型,快速生成智能合约和服务应用
  • 提供基础的增、删、改、查功能,及配套的Restful API
  • 集成了合约开发的dev mode,提供简易的调试环境

依赖环境

  • Docker
  • Docker-Compose
  • Node 8.x or greater

编译安装

git clone https://github.com/Gordon-H/fabton.git
cd fabton
npm install
npm link

基本功能

fabton init <options>
选项:  
    -f, --file <path>  the config file 

配置信息

参照default.json,默认的配置是以Fabric-Samples中的Fabcar为基础的:

{
  "app": "FabCar",
  "version": "1.0.0",
  "fabricVersion": "1.4.1",
  "description":"This project is generated by Fabton.",
  "author": "nobody",
  "contract": "testcc",
  "namespace": "com.example.fabcar",
  "models": [
    {
      "namespace": "com.example.car",
      "name": "Car",
      "description": "example car",
      "keys": [
        "carNumber"
      ],
      "properties": [
        "color",
        "make",
        "model",
        "owner"
      ]
    },
    {
      "namespace": "com.example.user",
      "name": "User",
      "description": "example user",
      "keys": [
        "userId"
      ],
      "properties": [
        "name",
        "age",
        "gender"
      ]
    }
  ]
}

目录说明

生成后的项目主要有如下5个目录:

├── application: 应用程序代码,提供restful API供后台业务程序调用  
├── contract: 合约代码,使用Node.js编写,需要预先安装到节点上并进行部署  
├── devmode: 与合约的dev mode相关的文件,方便开发和调试  
├── gateway: 区块链网络的配置信息,包括peer、orderer、channel等相关信息  
├── wallet: 钱包目录。很重要!需要挂载到可靠的目录并进行备份  

启动步骤

新建一个目录,在该目录下通过fabton init初始化项目

  • 通过Dev Mode运行调试合约
cd contract
npm install
npm run dev-init
npm start
npm run dev-deploy

运行合约后,如果需要修改代码,只需要重启合约即可生效,无需install、upgrade或instantiate

  • 启动应用服务
cd application/
npm install
npm start

访问swagger在线API文档:
http://localhost:3000/api-docs

fabton's People

Contributors

gordon-h avatar

Watchers

 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.