1 Star 6 Fork 2

angryred/spring-fabric-gateway

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Maven Central

Spring Fabric Gateway

Provided Spring MVC services and spring boot starters based on fabric-gateway-java, more info can be found from https://ecsoya.github.io/fabric/(中文).

Dependencies

  1. Build your fabric network with Hyperledger Fabric v2.3.0.

  2. Optional, install the default common chaincode go or Java.

Springboot Starters

  1. fabric-gateway-spring-boot-starter: A spring MVC boot starter.
  2. fabric-explorer-spring-boot-starter: A simple fabric explorer starter.

How to use

Spring Boot Configure:

Firstly, add the following dependency to your project's pom.xml file:

Maven Central

<dependency>
	<groupId>io.github.ecsoya</groupId>
	<artifactId>fabric-gateway-spring-boot-starter</artifactId>
	<version>${latest_version}</version>
</dependency>

or

<dependency>
	<groupId>io.github.ecsoya</groupId>
	<artifactId>fabric-explorer-spring-boot-starter</artifactId>
	<version>${latest_version}</version>
</dependency>

Snapshots

<repositories>
	<repository>
		<id>ecsoya.io</id>
		<url>https://repo.rdc.aliyun.com/repository/42210-snapshot-BITvCn/</url>
	</repository>
</repositories>

step1

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

step2

<dependency>
	<groupId>com.github.ecsoya.spring-fabric-gateway</groupId>
	<artifactId>spring-fabric-gateway</artifactId>
	<version>${latest_version}</version>
</dependency>

Secondly, configure fabric network in application.yml

# Fabric Network Configure      
spring:         
   fabric:
      chaincode: 
         identify: your chaincode id
         name: Common chaincode
         version: 1.0
      channel: your channel name
      organizations:
      - org1
      - org2
      name: your fabric network name
      gateway:
         wallet:
            identify: admin
      network:
         file: network/connection.yml //your fabric network config file.
         name: fabric network name
# Fabric explorer
      explorer: 
         title: Fabric Explorer
         logo: img/logo.png
         copyright: Ecsoya (jin.liu@soyatec.com)
         hyperledger-explorer-url: http://www.hyperleder.org

Finally, enjoy to use the following spring components:

  1. FabricContext: wrapper class for fabric gateway.
  2. IFabricInfoService: query fabric infos such as blocks, transaction and so on.
  3. IFabricService: CRUD FabricObject if you install the default common Chaincode.
@Autowired
private FabricContext fabricContext;

Fabric Network Config File

The Fabric Network Config File is the core configuration file of fabric network, both FabricContext and Gateway are built with this kind of file. It holds details of network and channel configurations typically loaded from an external config file.

Please look at the org.hyperledger.fabric.sdk.NetworkConfig to get more details.

You can also look at my project Fabric Network Builder to learn how to create a fabric network config file.

Default common chaincode

The default common chaincode provided useful functions such as create, get, update, query. It used a CompositeKey with id and type to identify different objects, it also support pagination query.

The chaincode source can be found from here.

Fabric Explorer Starter

This will help you to build a simple fabric explorer with few codes.

Fabric Explorer

References

  1. Fabric开发手册
  2. Hyperledger Fabric Gateway SDK for Java
  3. Java SDK for Hyperledger Fabric
MIT License Copyright (c) 2020 AngryRED Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于Hyperledger Fabric的Gateway项目,结合Spring MVC做出的一套框架,简化Fabric区块链项目的开发。 Spring boot stater for fabric-gateway-java (https://github.com/hyperledger/fabric-gateway-java) 展开 收起
Java 等 5 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/angryred/spring-fabric-gateway.git
git@gitee.com:angryred/spring-fabric-gateway.git
angryred
spring-fabric-gateway
spring-fabric-gateway
master

搜索帮助