the standard Fabric common connection profile (CCP) file that describes the target Fabric network, at the location specified in the main config file above under rpc.configPath. For details on the CCP file, see Fabric SDK documentation. Note that the CCP file must contain the client section, which is required for the fabconnect to act as a client to Fabric networks.
Use the following command to launch the connector:
The API spec can be accessed at the endpoint /api, which is presented in the Swagger UI.
Hierarchical Configurations
Every configuration parameter can be specified in one of the following ways:
configuration file that is specified with the -f command line parameter. this is overriden by…
environment variables that follows the naming convention:
given a configuration property in the configuration JSON “prop1.prop2”
capitalized, exchanging . with _, then add the FC_ prefix
becoming: FC_PROP1_PROP2
this is overriden by…
command line parameter with a naming convention that follows the same dot-notaion of the property:
given “prop1.prop2”
the command line parameter should be --prop1-prop2 or a shorthand variation
Support for both Static and Dynamic Network Topology
There is support for using a full connection profile that describes the entire network, without relying on the peer’s discovery service to discover the list of peers to send transaction proposals to. A sample connection profile can be seen in the folder test/fixture/ccp.yml. This mode will be running if both rpc.useGatewayClient and rpc.useGatewayServer are missing or set to false.
There is also support for using the dynamic gateway client by relying on the peer’s discovery service with a minimal connection profile. A sample connection profile can be seen in the folder test/fixture/ccp-short.yml. This mode will be running if rpc.useGatewayClient is set to true.
Support for server-based gateway support, available in Fabric 2.4, is coming soon.
Structured Data Support for Transaction Input with Schema Validation
When calling the POST /transactions endpoint, input data can be provided in any of the following formats:
in the “traditional” array of strings corresponding to the target function’s list of input parameters:
provide a payloadSchema property in the input payload headers, using JSON Schema to define the list of parameters. The root type must be an array, with prefixItems to define the sequence of parameters:
when using payloadSchema, complex parameter structures are supported. Suppose the CreateAsset function has the following signature:
type Asset struct {
ID string `json:"ID"`
Color string `json:"color"`
Size int `json:"size"`
Owner string `json:"owner"`
Appraisal *Appraisal `json:"appraisal"`
}
type Appraisal struct {
AppraisedValue int `json:"appraisedValue"`
Inspected bool `json:"inspected"`
}
// CreateAsset issues a new asset to the world state with given details.
func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id string, color string, size int, owner string, appraisal Appraisal) error {
// implementation...
}
Note that the appraisal parameter is a complex type, the transaction input data can be specified as follows:
If a chaincode publishes events with string or JSON data, fabconnect can be instructed to decode them from the byte array before sending the event to the listening client application. The decoding instructions can be provided during subscription.
For example, the following chaincode publishes an event containing a JSON structure in the payload:
Notice the payloadType property, which instructs fabconnect to decode the payload bytes into a JSON structure. As a result the client will receive the event JSON as follows:
Besides stringifiedJSON, string is also supported as the payload type which represents UTF-8 encoded strings.
Fixes Needed for multiple subscriptions under the same event stream
The current fabric-sdk-go uses an internal cache for event services, which builds keys only using the channel ID. This means if there are multiple subscriptions targeting the same channel, but specify different fromBlock parameters, only the first instance will be effective. All subsequent subscriptions will share the same event service, rendering their own fromBlock configuration ineffective.
firefly-fabconnect
A reliable REST and websocket API to interact with a Fabric network and stream events.
This component provides 3 high level sets of API endpoints:
Architecture
High Level Components
Objects and Flows
Getting Started
After checking out the repo, simply run
maketo build and test.To launch, first prepare the 2 configurations files:
// TODO clean this up
rpc.configPath. For details on the CCP file, see Fabric SDK documentation. Note that the CCP file must contain theclientsection, which is required for the fabconnect to act as a client to Fabric networks.Use the following command to launch the connector:
API Specification
The API spec can be accessed at the endpoint
/api, which is presented in the Swagger UI.Hierarchical Configurations
Every configuration parameter can be specified in one of the following ways:
-fcommand line parameter. this is overriden by….with_, then add theFC_prefixFC_PROP1_PROP2--prop1-prop2or a shorthand variationSupport for both Static and Dynamic Network Topology
There is support for using a full connection profile that describes the entire network, without relying on the peer’s discovery service to discover the list of peers to send transaction proposals to. A sample connection profile can be seen in the folder test/fixture/ccp.yml. This mode will be running if both
rpc.useGatewayClientandrpc.useGatewayServerare missing or set tofalse.There is also support for using the dynamic gateway client by relying on the peer’s discovery service with a minimal connection profile. A sample connection profile can be seen in the folder test/fixture/ccp-short.yml. This mode will be running if
rpc.useGatewayClientis set totrue.Support for server-based gateway support, available in Fabric 2.4, is coming soon.
Structured Data Support for Transaction Input with Schema Validation
When calling the
POST /transactionsendpoint, input data can be provided in any of the following formats:payloadSchemaproperty in the input payloadheaders, using JSON Schema to define the list of parameters. The root type must be anarray, withprefixItemsto define the sequence of parameters:payloadSchema, complex parameter structures are supported. Suppose theCreateAssetfunction has the following signature:Note that the
appraisalparameter is a complex type, the transaction input data can be specified as follows:JSON Data Support in Events
If a chaincode publishes events with string or JSON data, fabconnect can be instructed to decode them from the byte array before sending the event to the listening client application. The decoding instructions can be provided during subscription.
For example, the following chaincode publishes an event containing a JSON structure in the payload:
An event subscription can be created as follows which contains instructions to decode the payload bytes:
Notice the
payloadTypeproperty, which instructs fabconnect to decode the payload bytes into a JSON structure. As a result the client will receive the event JSON as follows:Besides
stringifiedJSON,stringis also supported as the payload type which represents UTF-8 encoded strings.Fixes Needed for multiple subscriptions under the same event stream
The current
fabric-sdk-gouses an internal cache for event services, which builds keys only using the channel ID. This means if there are multiple subscriptions targeting the same channel, but specify differentfromBlockparameters, only the first instance will be effective. All subsequent subscriptions will share the same event service, rendering their ownfromBlockconfiguration ineffective.A fix has been provided for this in the forked repository https://github.com/kaleido-io/fabric-sdk-go.
Follow these simple steps to integrate this fix (until it’s contributed back to the official repo):
firefly-fabconnectfolder:eventservice-cache-keymakeLicense
This project is licensed under the Apache 2 License - see the
LICENSEfile for details.