Code Monkey home page Code Monkey logo

spring-fabric-gateway's Introduction

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 ([email protected])
         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

spring-fabric-gateway's People

Contributors

ecsoya 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.