Blockchainbean2
This code pattern shows how to model a supply-chain network using the IBM Blockchain Platform and is based on a collaboration with Brooklyn Roasting Company. The story, along with the supply-chain documents that were used to model this network, can be found at: https://www.ibm.com/blockchainbean. Note that the 'view the blockchain' button is being migrated''
Install / Use
/learn @IBM/Blockchainbean2README
WARNING: This repository is no longer maintained :warning:
This repository will not be updated. I will check periodically for pull requests, but do not expect a quick response.
Create a fair trade supply network with Hyperledger Fabric and IBM Blockchain Platform V2
This code pattern is based on a recent proof-of-concept developed in collaboration with a coffee roasting company that was nice enough to let us use their supply-chain documents. The finished product of this code pattern is a cloud-based blockchain API, that any other UI app can call. An example UI app that leverages our blockchain API can be found in the screenshots below.
Each cup has a history based on which batch of coffee was used make the cup, which you can see below. Additionally, you can see other details such as who poured the cup, at what time the cup was poured, which type of beans were used, etc. For example, a sample cup 'NJB123' for the result shown below.

In this code pattern we will create a blockchain app that increases visibility and efficiency in the supply chain of a coffee retailer using IBM Blockchain Platform V2 Beta. We will use different transactions to show different possible actions for the different participants in the supply chain. This sample application will record all transactions on the IBM Blockchain Platform V2 Beta, and enable a coffee retailer to ensure the customer that their coffee is organic and fair-trade. The code pattern can be useful to developers that are looking into learning more about creating applications that integrate supply chains with Hyperledger Fabric.
When the reader has completed this code pattern, they will understand how to:
- Interact with the (free) IBM Blockchain Platform V2 Beta
- Build a blockchain back-end using Hyperledger Fabric
- Create and use a (free) Kubernetes Cluster
- Deploy a Node.js app in the cloud that will interact with our smart contract
Flow Diagram
<br> <p align="center"> <img src="docs/app-architecture.png"> </p> <br>Flow Description
- The blockchain operator sets up the IBM Blockchain Platform 2.0 service.
- The IBM Blockchain Platform 2.0 creates a Hyperledger Fabric network on an IBM Kubernetes Service, and the operator installs and instantiates the smart contract on the network.
- The Node.js application server uses the Fabric SDK to interact with the deployed network on IBM Blockchain Platform 2.0 and creates APIs for a web client.
- The Loopback 4 client uses the Node.js application API to interact with the network.
- The user interacts with the Loopback 4 web interface to update and query the blockchain ledger and state.
Included components
- IBM Blockchain Platform V2 Beta gives you total control of your blockchain network with a user interface that can simplify and accelerate your journey to deploy and manage blockchain components on the IBM Cloud Kubernetes Service.
- IBM Cloud Kubernetes Service creates a cluster of compute hosts and deploys highly available containers. A Kubernetes cluster lets you securely manage the resources that you need to quickly deploy, update, and scale applications.
- IBM Blockchain Platform Extension for VS Code is designed to assist users in developing, testing, and deploying smart contracts -- including connecting to Hyperledger Fabric environments.
Featured technologies
- Hyperledger Fabric v1.4 is a platform for distributed ledger solutions, underpinned by a modular architecture that delivers high degrees of confidentiality, resiliency, flexibility, and scalability.
- Node.js is an open source, cross-platform JavaScript run-time environment that executes server-side JavaScript code.
- Loopback 4 LoopBack is a highly-extensible, open-source Node.js framework that enables you to: Create dynamic end-to-end REST APIs with little or no coding. Access data from major relational databases, MongoDB, SOAP and REST APIs. Incorporate model relationships and access controls for complex APIs.
Watch the Video - Create a fair trade supply network with Hyperledger Fabric 1.4 (Cloud)
Watch the Video - Create a fair trade supply network with Hyperledger Fabric 1.4 (Local)
Prerequisites
This pattern assumes you have an IBM Cloud account, VSCode and IBM Blockchain Platform Extension for VSCode installed
- IBM Cloud account
- Install VSCode
- Install IBM Blockchain Platform Extension for VSCode
- Node v8.x or greater and npm v5.x or greater
Steps (Cloud Deployment)
To run a local network, you can find steps here.
- Clone the Repo
- Install Dependencies
- Package Contract
- Create IBM Cloud services
- Build a network
- Deploy blockchainbean2 Smart Contract on the network
- Connect application to the network
- Run the application
Step 1. Clone the Repo
Git clone this repo onto your computer in the destination of your choice, then go into the web-app folder:
HoreaPorutiu$ git clone https://github.com/horeaporutiu/blockchainbean2.git
Navigate to the web-app directory:
HoreaPorutiu$ cd blockchainbean2/web-app
Step 2. Install Dependencies
Install required dependencies using NPM:
web-app$ npm install --ignore-scripts
Step 3. Package Contract
Right-click under your folders in your workspace area and then click Add Folder to Workspace and then highlight the
blockchainbean/lib directory as shown in the picture below, and then click on add:

Next, we have to package the smart contract. Click on the F1 button on your keyboard,
which will bring up the VSCode command palette. From there, navigate and click on Package a Smart Contract Project.

Next, the extension will ask the following question:
Choose a workspace folder to package
Click on the lib folder - note we do not want to package our client (i.e. our web-app directory).

If all went well, you should see the following.

Note that this .cds file is extremely important if we want to run
our smart contract on the cloud.
Step 4. Create IBM Cloud services
- Create the IBM Cloud Kubernetes Service. You can find the service in the
Catalog. For this code pattern, we can use theFreecluster, and give it a name. Note, that the IBM Cloud allows one instance of a free cluster and expires after 30 days. <b>The cluster takes around 10-15 minutes to provision, so please be patient!</b>
- Create the IBM Blockchain Platform V2 Beta service on the IBM Cloud. You can find the service in the
Catalog, and give a name.
- After your kubernetes cluster is up and running, you can deploy your IBM Blockchain Platform V2 Beta on the cluster. The service walks through few steps and finds your cluster on the IBM Cloud to deploy the service on.
- Once the Blockchain Platform is deployed on the Kubernetes cluster, you can launch the console to start operating on your blockchain network.
Step 5. Build a network
We will build a network as provided by the IBM Blockchain Platform documentation. This will include creating a channel with a single peer organization with its own MSP and CA (Certificate Authority), and an orderer organization with its own MSP and CA. We will create the respective identities to deploy peers and operate nodes.
Create your organization and your entry point to your blockchain
-
Create your peer organization CA
- Click <b>Add Certificate Authority</b>.
- Click <b>IBM Cloud</b> under <b>Create Certificate Authority</b> and <b>Next</b>.
- Give it a <b>Display name</b> of
Org1 CA. - Specify an <b>Admin ID</b> of
adminand <b>Admin Secret</b> ofadminpw.
-
Associate the identity
- In the Nodes tab, select the <b>Org1 CA</b> once it is running (indicated by the green box in the tile).
- Click <b>Associate identity</b> on the CA overview panel.
- On the side panel, select <b>Enroll ID</b>.
- Provide an <b>Enroll ID</b> of
adminand an <b>Enroll secret</b> ofadminpw. Use th
Related Skills
node-connect
349.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。


