A Hyperledger Fabric Gateway for Node Red 3.x implementation nodes to work with recent HLF networks v2.4 (or later)
Built in Typescript, this package aims to provide an easy to use and up-to-date set of Node Red nodes that enable seamless integration with Hyperledger Fabric blockchain networks.
Developers can leverage the power of the Hyperledger Fabric programming model to rapidly build blockchain-connected applications using Node Red.
This Nodes are based on fabric gateway and requires Fabric v2.4 (or later) with a Gateway enabled Peer. Additional compatibility information is available in the documentation:
To use this Node-RED package, you first need to configure a connection to your Hyperledger Fabric network.
A connection requires specifying:
This connection information can then be leveraged in a modular way across nodes that need to interact with the Fabric network.
Gateway needs a peer definition. This peer will be used to execute all requests to HLF.
TODO: Enable selection multiple peers to get complex transaction request.
To connect to a Hyperledger Fabric peer, you will need to specify the following configuration:
{
"grpc.default_authority": "testpeer.com:9999",
"grpc.ssl_target_name_override": "testpeer.com"
}
Refer to the gRPC documentation for full options.
An identity can be configured in three different ways using the Cert Type
parameter:
Embedded
- Identity credentials are provided in base64 and stored as credentials in Node-RED. Private Key
and Cert
fields must be provided.
Filesystem
- Identity credentials are read from a local file:
Legacy Key/Cert Identity
- Certificate and Key file paths must be provided in PEM format.
Fabric Operations Console Identity
- The identity is loaded from a single JSON file containing the certificate and private key embedded as base64 strings. This matches the format used by Hyperledger Fabric Operations Console:
{
"name": "admin",
"cert": "LS0tL......",
"private_key": "LS0tl...."
}
Microfab
- The identity is loaded remotely using the Microfab management REST API. This requires configuring the Microfab host and specifying the ID of the identity.
Node to configure the channel name
Once the connection nodes are configured properly, you can operate with HLF using Hyperledger Gateway
nodes.
These nodes work in the same way as HLF's own operations. Configuration can be added to the node or passed as parameters in payload
object.
Block listener
node reads all block events and publishes a message for each block and transaction processed. To prevent saturation of the JavaScript event loop, each message must be acknowledged. If the node restarts, it will resume reading from the last checkpoint.
Block listener commit
node will mark the message as done so next message event will be published. No Configuration needed
Provide information about the selected channel.
Channel Info
query the ledger and return the channel info: Last block and it's hash
Get Block
query the ledger and return the block based on:
By Number
will recover a block by it's number. Must be a number
By Hash
will recover a block by it's hash
By TxId
will recover a block by any of it's transaction id
Do you like my work? Buy me a coffee - or pizza 😜🍕
Source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the [LICENSE] file.