This repository contains a set of tools to use a blockchain network based on Hyperledger's Fabric test network on any Node-RED's flow. With these tools, you can create a "proxy" node that executes the logic on a smart contract (a.k.a Chaincode) instead of Node-RED, saving the resulting message with a blockchain transaction. These "proxy" nodes are transparent to Node-RED and can be a drop-in replacement to the original ones. Here is a diagram:
If you are not knowledgeable enough of Node-RED's terminology, please refer to their glossary
With the blockchain, you have tamper-proof records that ensure the integrity and immutability of your data. Every transaction recorded on the blockchain is cryptographically secured, meaning it cannot be altered or deleted without consensus from the network participants. This makes it ideal for scenarios where trust and transparency are critical, such as:
- Auditing: Blockchain provides a verifiable history of all transactions, making it easier to conduct audits and ensure compliance with regulations.
- Data Integrity: By storing data on the blockchain, you can guarantee that it has not been tampered with, which is essential for sensitive information like financial records, medical data, or supply chain tracking.
- Dispute Resolution: In cases of disputes, the blockchain serves as an authoritative source of truth, as all parties can independently verify the data without relying on a central authority.
- Automation with Smart Contracts: Smart contracts execute predefined logic automatically when conditions are met, ensuring that processes are carried out as intended without manual intervention.
By integrating blockchain into Node-RED flows, you can leverage these benefits seamlessly, enabling secure and transparent business compliance.
- Node.js
>=22.15.0
- Run
npm ci - Run
npx blockchainize-nodes [package(s)]
Tip
blockchainize-nodes uses the same syntax you are used to with npm i. For more information, run it
without any argument to see the help message.
Example: npx blockchainize-nodes node-red-contrib-calc @statuscompliance/validation
-
A folder called
blockchain-conversionwill be created at the current directory.The folder contains a folder for each of the converted packages. In the example above, you will have 2 folders,
node-red-contrib-calcandstatuscompliance-validation. Every package's folder contains:- A
chaincodefolder, with the Hyperledger's Fabric chaincode for every node of the package. - A
.tar.gzfile, which is an npm package containing the proxy nodes.
- A
All Hyperledger Fabric's binaries and the middleware that provides the RESTful service between the proxy nodes and the blockchain are packaged as a single container to simplify its deployment and configuration.
- Docker (tested on 28.1.1)
- Linux/MacOS machine capable of running unix (bash-like) shell scripts
- Run
./build-docker.sh(at the root of this repository).
After running, the tagged image statuscompliance/blockchain:latest will be available in your Docker daemon.
tar archive files for different architectures will also be available under the docker_images folder.
-
Copy the
ledgerservice from the docker-compose.yml file of this repository to thedocker-compose.ymlfile of your full infrastructure deployment. Make sure the mountpoint of theblockchain-conversionfolder matches the location of the one you generated before. -
Add the
STATUS_LEDGER_ENDPOINTenvironment variable to the node-red container of your full infrastructure deployment. The value of the variable will beledger(or the name of the key you used for declaring the new service).See the relevant affected sections of the docker-compose.yml file
The
privileged: truekey in the ledger service is importantservices: + ledger: + restart: no + container_name: ledger + image: statuscompliance/blockchain + privileged: true + volumes: + - ./blockchain-conversion:/chaincodes + networks: + - nodered_network nodered: restart: unless-stopped container_name: node-red-status image: ghcr.io/statuscompliance/node-red-status networks: - nodered_network + environment: + STATUS_LEDGER_ENDPOINT: ledger ...rest of the properties
-
Install the proxy nodes into your Node-RED instance.
- Open Node-RED's flow editor and access the palette manager with
ALT + SHIFT + Pkeyboard shortcut. - Navigate to the Install tab and click on the upload button.
- Choose the
.tar.gzfiles generated byblockchainize-nodes
If you get lost at some point, head over the official's Node-RED's documentation
- Open Node-RED's flow editor and access the palette manager with
You are now ready to use Node-RED with the blockchain in your flows!
Tip
The sample flows that some Node-RED's npm packages include (flows.json file) are also updated to
use the proxy nodes, so you can use some of those sample nodes rightaway!