The Global Finance application using blockchain technology tracks actions on an order by the various members of a network -- buyer, seller, provider, shipper, and finance company. These actions include:
- Buyer creates the order
- Seller contacts a provider for the items
- Shipper delivers the items
- Finance company processes payments to the seller
This use case addresses dispute resolution and can be applied across industry verticals to resolve disputes. This use case is inspired by the RedBook tutorial by Bob Dill and uses the same application interface. This use case employs a Node.js smart contract and a Node.js web application.
The code pattern demonstrates how a Node.js smart contract can be packaged using the IBM Blockchain Platform Extension for VS Code. Then, using the extension, you can set up a local instance of the Hyperledger Fabric network, on which you can install and instantiate the contract. The Node.js web application can interact with the network using the 'fabric-network' sdk.
When you have completed this code pattern, you will understand how to:
- Develop a Node.js smart contract
- Package and deploy the smart contract to a local instance of Hyperledger Fabric using IBM Blockchain Platform Extension for VS Code
- Develop a Node.js blockchain web application to interact with the deployed Fabric network
The developer uses the IBM Blockchain Platform Extension for VS Code to:
- Package a smart contract.
- Launch a local Hyperledger Fabric Network.
- Install chaincode on the peer node.
- Instantiate the chaincode on the peer node.
- Use a Global Finance application to interact with the Hyperledger Fabric network through API calls using the
fabric-network
npm library. Admins can also use the application to create new participants.
- 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.
- 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.
- Visual Studio Code is a code editor that's redefined and optimized for building and debugging modern web and cloud applications.
- Nodejs is an open source, cross-platform JavaScript run-time environment that executes server-side JavaScript code.
- Bootstrap is an open source toolkit for developing with HTML, CSS, and JavaScript.
Follow these steps to set up and run this code pattern. The steps are described in detail below.
You will need to follow the requirements for the IBM Blockchain Platform Extension for VS Code:
- VSCode version 1.26 or greater
- Node v8.x or greater and npm v5.x or greater
- Yeoman (yo) v2.x
- Docker version v17.06.2-ce or greater
- Docker Compose v1.14.0 or greater
- Clone the repo
- Use the VS Code extension to set up a smart contract on a basic Fabric network
- Run the application
Clone this repository in a folder your choice:
git clone https://github.com/IBM/global-financing-blockchain.git
Open Visual Studio code and open the contract
folder.
Press the F1
key to see the different VS code options. Choose IBM Blockchain Platform: Package a Smart Contract Project
.
Click the IBM Blockchain Platform
extension button on the left. This will show the packaged contracts on top and the blockchain connections on the bottom.
Click on local_fabric
to start a network. This will download the Docker images required for a local Fabric setup, and start the network. You should see the output window as the network sets up.
Click on local_fabric
again; it should have a full white circle next to it. This should bring up mychannel
. You are now ready to install the smart contract.
Click on mychannel
, then Peers
. This will display peer0.org1.example.com
. Right click on it and choose Install Smart Contract
:
Choose the globalfinancing@0.0.1
contract:
You are now ready to instantiate the smart contract. Right click on mychannel
and choose Instantiate Smart Contract
:
Choose the globalfinancing@0.0.1
contract:
Type in instantiate
for the function:
You can press Enter for optional arguments.
Once this is successfully instantiated, you should see a successful notification in the output view.
In a new terminal, navigate to the web-app
directory:
cd global-financing-blockchain/web-app/
Build the node dependencies:
npm install
Run the application:
npm start
Unified member's view:
This application can be expanded in a couple of ways:
- Create a wallet for every member and use the member's wallet to interact with the application.
- Update the application to interact through the IBM Blockchain Platform starter plan on IBM Cloud.
This code pattern is licensed under the Apache Software License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.