salmanbao / global-financing-blockchain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Global financing with blockchain

The Global Finance application using blockchain technology tracks actions on an order by the 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

Architecture flow

The developer uses the IBM Blockchain Platform Extension for VS Code to:

  1. Package a smart contract.
  2. Launch a local Hyperledger Fabric Network.
  3. Install chaincode on the peer node.
  4. Instantiate the chaincode on the peer node.
  5. 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.

Included components

  • 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.3 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.

Featured technologies

  • 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.

Running the application

Follow these steps to set up and run this code pattern. The steps are described in detail below.

Prerequisites

You will need to follow the requirements for the IBM Blockchain Platform Extension for VS Code:

Steps

  1. Clone the repo
  2. Use the VS Code extension to set up a smart contract on a basic Fabric network
  3. Run the application

1. Clone the repo

Clone this repository in a folder your choice:

git clone https://github.com/IBM/global-financing-blockchain.git

2. Use the VS Code extension to set up a smart contract on a basic Fabric network

Open Visual Studio code and open the contract folder.

Package the smart contract

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.

Setup local_fabric

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.

Install and instantiate 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 the contract in your Blockchain Connection with all the contract functions:

You can directly submit transactions from here. Once you have reviewed the contract, you can try out the transactions directly to register participants and try out functions to update the order.

3. Run the application

Before running the application, you need to update the ports in the network-vs.yaml file.

  • First in your terminal, type in docker ps. This will display your Docker containers:

  • Update the network-vs.yaml file with the ports for the peers, orderer, and certificate-authority:

  • In a terminal, navigate to the web-app directory:

    cd web-app/

    Build the node dependencies:

    npm install

    Run the application:

    npm start

Unified member's view:

Extending the code pattern

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.

Links

License

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.

Apache Software License (ASL) FAQ

About


Languages

Language:JavaScript 87.7%Language:HTML 6.5%Language:CSS 5.3%Language:DIGITAL Command Language 0.5%