For information on using the Fabric Gateway, including client API documentation, please visit the Fabric Gateway documentation.
The original proposal is described in the Fabric Gateway RFC. Adding a gateway component to the Fabric peer provides a single entry point to a Fabric network, and removes much of the transaction submission logic from the client application.
The Gateway component in the Fabric Peer exposes a simple gRPC interface to client applications and manages the lifecycle of transaction invocation on behalf of the client. This minimises the network traffic passing between the client and the blockchain network, as well as minimising the number of network ports that need to be opened.
See the gateway.proto file for details of the gRPC interface.
This repository comprises three functionally equivalent client APIs, written in Go, Typescript, and Java. In order to build these components, the following needs to be installed and available in the PATH:
- Go 1.16
- Node 14
- Java 8
- Docker
- Make
- Go tools:
go install github.com/cucumber/godog/cmd/[email protected]
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/golang/mock/[email protected]
go install github.com/securego/gosec/v2/cmd/gosec@latest
- pkcs11 enabled fabric-ca-client
go get -tags 'pkcs11' github.com/hyperledger/fabric-ca/cmd/fabric-ca-client
- SoftHSM, which can either be:
- installed using the package manager for your host system:
- Ubuntu:
sudo apt install softhsm2
- macOS:
brew install softhsm
- Windows: unsupported
- Ubuntu:
- or compiled and installed from source:
- install openssl 1.0.0+ or botan 1.10.0+
- download the source code from https://dist.opendnssec.org/source/softhsm-2.5.0.tar.gz
tar -xvf softhsm-2.5.0.tar.gz
cd softhsm-2.5.0
./configure --disable-gost
(would require additional libraries, turn it off unless you need 'gost' algorithm support for the Russian market)make
sudo make install
- installed using the package manager for your host system:
The following Makefile targets are available
make generate
- generate mock implementations used by unit testsmake unit-test-go
- run unit tests for the Go client APImake unit-test-node
- run unit tests for the Node client APImake unit-test-java
- run unit tests for the Java client APImake unit-test
- run unit tests for all client language implementationsmake pull-latest-peer
- fetch the latest peer docker image containing the gateway servermake scenario-test-go
- run the scenario (end to end integration) tests for Go client APImake scenario-test-node
- run the scenario tests for Node client APImake scenario-test-java
- run the scenario tests for Java client APImake scenario-test
- run the scenario tests for all client language implementationsmake test
- run all unit and scenario testsmake sample-network
- create the sample network used to run samplesmake sample-network-clean
- remove the sample networkmake run-samples-go
- run the samples for the Go client APImake run-samples-node
- run the samples for the Node client APImake run-samples-java
- run the samples for the Java client APImake run-samples
- create the sample network, run samples for all client language implementations, and remove the sample network
Note that immediately after creating a fresh copy of this repository, auto-generated test mocks will not be preset so
Go code will show errors. Running the unit-test
make target will generate the required mock implementations, and they
can also be generated explicitly by running make generate
.
The scenario tests create a Fabric network comprising two orgs (one peer in each org) and a single gateway within a set of docker containers. The clients connect to the gateway to submit transactions and query the ledger state.
The tests are defined as feature files using the Cucumber BDD framework. The same set of feature files is used across all three client language implementations to ensure consistency of behaviour.