Provided Spring MVC services and spring boot starters based on fabric-gateway-java, more info can be found from https://ecsoya.github.io/fabric/(中文).
Build your fabric network with Hyperledger Fabric v2.3.0.
fabric-gateway-spring-boot-starter
: A spring MVC boot starter.fabric-explorer-spring-boot-starter
: A simple fabric explorer starter.Firstly, add the following dependency to your project's pom.xml
file:
<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:
FabricContext
: wrapper class for fabric gateway.IFabricInfoService
: query fabric infos such as blocks, transaction and so on.IFabricService
: CRUD FabricObject if you install the default common Chaincode.@Autowired
private FabricContext fabricContext;
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.
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.
This will help you to build a simple fabric explorer with few codes.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型