fabricsdk

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2019 License: Apache-2.0 Imports: 0 Imported by: 0

README

Hyperledger Fabric Client SDK for Go

Build Status Go Report Card GoDoc

This SDK enables Go developers to build solutions that interact with Hyperledger Fabric.

Getting started

Obtain the client SDK packages for Fabric and Fabric CA.

go get -u github.com/hyperledger/fabric-sdk-go

# Optional - populate vendor directory (if needed by your downstream vendoring solution)
# cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/
# make populate

You're good to go, happy coding! Check out the examples for usage demonstrations.

Examples
  • E2E Test: Basic example that uses SDK to query and execute transaction
  • Ledger Query Test: Basic example that uses SDK to query a channel's underlying ledger
  • Multi Org Test: An example that has multiple organisations involved in transaction
  • Dynamic Endorser Selection: An example that uses dynamic endorser selection (based on chaincode policy)
  • E2E PKCS11 Test: E2E Test using a PKCS11 crypto suite and configuration
  • CLI: An example CLI for Fabric built with the Go SDK.
  • More examples needed!
Community
  • Discussion is happening in Rocket Chat.
  • Issue tracking is handled in Jira.
  • Active development occurs in the Gerrit repository.

Client SDK

Current Compatibility

The SDK's integration tests run against three tagged Fabric versions:

  • prev (currently v1.0.0)
  • stable (currently latest of v1.0.x)
  • prerelease (currently latest of v1.1.0-x)

Additionally for development purposes integration tests also run against the devstable Fabric version as needed.

Retired versions

When the 'prev' code level is updated, the last tested fabric-sdk-go commit or tag is listed below.

  • fabric v1.0.0 & fabric-ca v1.0.0
    • fabric-sdk-go: master:HEAD
Running the test suite
# In the Fabric SDK Go directory
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/

# Optional - Automatically install Go tools used by test suite
# make depend-install

# Running test suite
make

# Clean test suite run artifacts
make clean
Go Tags

The following Go tags can be supplied to enable additional functionality:

  • experimental: includes support for experimental features.

Contributing to the Go SDK

If you want to contribute to the Go SDK, please run the test suite and submit patches to the Gerrit git repostory for review. For general guidelines, please refer to the Fabric project's contribution page.

You need:

  • Go 1.9
  • Dep
  • Make
  • Docker
  • Docker Compose
  • Git
Gerrit Git repository

To contribute patches, you will need to clone (or add a remote) from Gerrit with authentication.

Running a portion of the test suite
# In the Fabric SDK Go directory
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/

# Ensure dependencies are installed
make depend

# Running code checks (license, linting, spelling, etc)
make checks

# Running all unit tests
make unit-test

# Running all integration tests
make integration-test
Running package unit tests manually
# In a package directory
go test
Running integration tests manually

You need:

  • A working fabric and fabric-ca set up. It is recommended that you use the docker-compose file provided in test/fixtures/dockerenv. It is also recommended that you use the default .env settings provided in test/fixtures/dockerenv. See steps below.
  • Customized settings in the test/fixtures/config/config_test.yaml in case your Hyperledger Fabric network is not running on localhost or is using different ports.
Enable local hostnames

You will need to set the following hosts to 127.0.0.1 (typically in /etc/hosts): ca.org1.example.com ca.org2.example.com peer0.org1.example.com peer1.org1.example.com peer0.org2.example.com peer1.org2.example.com orderer.example.com

Testing with Fabric Images at Docker Hub

The test suite defaults to the latest compatible tag of fabric images at Docker Hub. The following commands starts Fabric:

# In the Fabric SDK Go directory
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/

# Start fabric (stable tag)
make dockerenv-stable-up

# Or more generally, start fabric at a different code level (prev, stable, prerelease, devstable)
# make dockerenv-[CODELEVEL]-up
Running Integration Tests

Fabric should now be running. In a different shell, run integration tests

# In the Fabric SDK Go directory
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go

# Use script to setup parameters for integration tests and execute them
make integration-tests-local

# Or more generally, run integration tests at a different code level (prev, stable, prerelease, devstable)
# and fixture target version
# FABRIC_CODELEVEL_VER=[VER] FABRIC_CODELEVEL_TAG=[CODELEVEL] make integration-tests-local
# It is also possible to run integration tests using go test directly. For example:
#cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/integration/
#go test

#cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/integration/orgs
#go test

# You should review test/scripts/integration.sh for options and details.
# Note: you should generally prefer the scripted version to setup parameters for you.
Testing with Local Build of Fabric (Advanced)

Alternatively you can use a local build of Fabric using the following commands:

# Start fabric (devstable codelevel with latest docker tags)
make dockerenv-latest-up

License

Hyperledger Fabric SDK Go software is licensed under the Apache License Version 2.0.


This document is licensed under a Creative Commons Attribution 4.0 International License.

Documentation

Overview

Package fabricsdk enables Go developers to build solutions that interact with Hyperledger Fabric.

Directories

Path Synopsis
api
apiconfig/mocks
Package mock_apiconfig is a generated GoMock package.
Package mock_apiconfig is a generated GoMock package.
apifabca/mocks
Package mock_apifabca is a generated GoMock package.
Package mock_apifabca is a generated GoMock package.
apifabclient/mocks
Package mock_apifabclient is a generated GoMock package.
Package mock_apifabclient is a generated GoMock package.
def
fabapi
Package fabapi is deprecated and will be removed - see pkg/fabsdk
Package fabapi is deprecated and will be removed - see pkg/fabsdk
internal
github.com/hyperledger/fabric/protos/orderer
Package orderer is a generated protocol buffer package.
Package orderer is a generated protocol buffer package.
github.com/tjfoc/gmsm/sm2
crypto/x509 add sm2 support
crypto/x509 add sm2 support
github.com/tjfoc/gmtls
add sm2 support
add sm2 support
github.com/tjfoc/gmtls/gmcredentials/echo
Package echo is a generated protocol buffer package.
Package echo is a generated protocol buffer package.
pkg
errors/retry
Package retry provides retransmission capabilities to fabric-sdk-go
Package retry provides retransmission capabilities to fabric-sdk-go
errors/status
Package status defines metadata for errors returned by fabric-sdk-go.
Package status defines metadata for errors returned by fabric-sdk-go.
fabric-client/resource
Package resource provides access to fabric network resource management, typically using system channel queries.
Package resource provides access to fabric network resource management, typically using system channel queries.
fabric-client/txn
Package txn enables creating, endorsing and sending transactions to Fabric peers and orderers.
Package txn enables creating, endorsing and sending transactions to Fabric peers and orderers.
fabric-txn/chclient
Package chclient enables channel client
Package chclient enables channel client
fabric-txn/chmgmtclient
Package chmgmtclient enables channel management client
Package chmgmtclient enables channel management client
fabric-txn/resmgmtclient
Package resmgmtclient enables resource management client
Package resmgmtclient enables resource management client
fabsdk
Package fabsdk enables client usage of a Hyperledger Fabric network.
Package fabsdk enables client usage of a Hyperledger Fabric network.
fabsdk/api/mocks
Package mock_api is a generated GoMock package.
Package mock_api is a generated GoMock package.
scripts
test
metadata
Package metadata contains variables used by tests
Package metadata contains variables used by tests
third_party
github.com/hyperledger/fabric/protos/common
Package common is a generated protocol buffer package.
Package common is a generated protocol buffer package.
github.com/hyperledger/fabric/protos/ledger/rwset
Package rwset is a generated protocol buffer package.
Package rwset is a generated protocol buffer package.
github.com/hyperledger/fabric/protos/ledger/rwset/kvrwset
Package kvrwset is a generated protocol buffer package.
Package kvrwset is a generated protocol buffer package.
github.com/hyperledger/fabric/protos/msp
Package msp is a generated protocol buffer package.
Package msp is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL