GithubHelp home page GithubHelp logo

kant / blockchain-enabled-crowdfunding Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ibm/blockchain-enabled-crowdfunding

0.0 0.0 0.0 31.49 MB

**work in progress**

Java 58.57% Go 11.58% JavaScript 15.15% CSS 4.76% HTML 9.94%

blockchain-enabled-crowdfunding's Introduction

** Work in progress **

Blockchain enabled Crowdfunding

Demonstrate the use of Hyperledger Fabric for building a collaboration platform for Crowd Funding.

Crowdfunding is practice of funding that operates independently of any government and is a way for people, businesses and charities to raise money. Its a way of raising finance by asking a large number of people each for a small amount of money. People invest simply because they believe in the cause.

Green areas also have a huge role in protection of ecosystems. As forest lands and natural ecosystems reduce just because of the urbanization and creation of the cities, it is necessary to make sure biodiversity is not reducing or at least not becoming extinct. Green areas make cities and neighborhoods more attractive places for people to live and work. Although people like cities, because they are more convenient places for living, they need some rural influence as well, beside lack of plants and trees can even make living impossible.

Here is a blockchain enabled solution for Crowdfunding supporting "Go Green Movement", in which people with a diverse/same portfolios can come forward and be a part of this moment by funding for the cause. This network will give the holistic view of the requirement and its current status. This way a need is catered to in an efficient manner. The problems of over collection or under collection for a need is reduced. The platform brings in trust, accountability and transparency of operations.

When the reader has completed this Code Pattern, they will understand how to:

  • Setup blockchain Network using IBM Blockchain Platform
  • Interact with blockchain network using Fabric Java SDK
  • Build a client application which will interact with blockchain network with the help of Java SDK

Flow

  1. Setup Blockchain Network using IBM Blockchain Platform on IBM Cloud.
  2. Deploy the client application using Fabric Java SDK. It works as middle layer and exposes REST API.
  3. Deploy Web UI application built using NodeJs.
  4. User can perform following task using the web interface which internally interacts with Blockchain Network with the help of middle layer.
    • Current status of Funds raised
    • Donate for the cause
    • View all Supporters who have donated

Pre-requisites

Steps

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

  1. Get the code
  2. Create IBM Cloud Services
  3. Setup Hyperledger Fabric Network using IBM Blockchain Platform
  4. Build the client application using Fabric Java SDK
  5. Build and deploy webapp
  6. Analyze the Results

1. Get the code

  • Clone the repo using the below command.

    git clone https://github.com/IBM/blockchain-enabled-crowdfunding
    
  • In this repository,

    • Chaincode : Go lang based smart contract with application logic that has to be installed on the network.
    • Client code using Fabric Java SDK: application code built using Fabric Java SDK to invoke and query chaincode on the hyperledger fabric network. The operations are exposed as ReST APIs when deployed enabling other applications to consume.
    • Web application code: NodeJS based application code to render UI and integrates with the REST APIs exposed by the client application built on Fabric Java SDK.

2. Create IBM Cloud Services

Create IBM Kubernetes Service

Create a Kubernetes cluster with Kubernetes Service using IBM Cloud Dashboard. This pattern uses the free cluster.

Note: It can take up to 15-20 minutes for the cluster to be set up and provisioned.

Create IBM Blockchain Platform Service

Create IBM Blockchain Platform service instance using IBM Cloud Dashboard.

3. Setup Hyperledger Fabric Network on IBM Blockchain Platform on IBM Cloud

In this step, we will setup the Hyperledger Fabric network using IBM Blockchain Platform as explained below.

Create Hyperledger Fabric Network on IBM Blockchain Platform

The blockchain network should consist of two organizations with single peer each and an orderer service for carrying out all the transactions. For detailed steps to create fabric network, please refer to the quick start guide for IBM Blockchain Platform.

Deploy Smart Contract on IBM Blockchain Platform

Smart contract(chaincode) is available here.

Package the smart contract To package follow the instructions provided here as step 12. For your convenience, packaged smart contract(.cds) is also provided in repo under chaincode directory. Use this file to install smart contract.

Install and Instantiate smart contract

  • Install smart contract using the .cds file generated/downloaded as explained in previous step.
  • Instantiate the smart contract. Function name to be provided during instantiation is init and no parameters OR we can leave it blank as we are using the default function name (init) only.

Download connection profile

Instantiation of smart contract has to be followed by integrating the blockchain network with Fabric Java SDK. Follow the below steps to download Connection Profile.

  • Under Instantiated smart contracts section, click on the three vertical dots for your smart contract as shown. Click on Connect with SDK option.

  • Provide the MSP name and Certificate Authority. Scroll down and click on Download Connection Profile.

  • Rename the downloaded json file as connection_profile.json.

  • Place this file in fabric-java-sdk-app/src/main/resources/. It gets loaded through ConnectionProfileLoader.java

3. Build the client application using Fabric Java SDK

Here, we use the Fabric Java SDK App to build a client to invoke and query chaincode on the hyperledger fabric network.

Open the manifest.yml file under fabric-java-sdk-app directory. Under env section, provide the valid credentials for an user who can execute transactions in the network. Also update Organization Affiliation and Chaincode name.

applications:
- name: blockchain-enabled-crowdfunding-java
  random-route: true
  memory: 1024M
  path: target/crowdfunding-java.war
  buildpack: java_buildpack
  env:
    admin: <admin-username>
    adminpw: <admin-password>
    OrgAffiliation: <affiliation>
    ChainCodeName: <Chaincode-Name>

Note: In this pattern, we are using admin credentails directly for executing transactions and not registering a new user.

Next, on the command terminal go to blockchain-enabled-crowdfunding directory, and execute the below commands:

cd fabric-java-sdk-app
mvn clean install
ibmcloud cf push

Login to IBM Cloud. On the Dashboard, verify that an app blockchain-enabled-crowdfunding-java is running fine.

Make a note of this Fabric Java SDK client application's url. On IBM Cloud dashboard, click on the application. When application page opens, click on Visit App URL. Now make a note of the url, as shown on the browser, even if the page shows some error. If the url ends with a / then remove the trailing forward slash. This url should be provided in web application that interacts with this Fabric Java SDK client application.

4. Build and deploy webapp

A web application is provided to perform various operations like Donate Money, View Supporters etc. Web appication code can be found under webapp directory.

This web application invokes rest interfaces implemented in Fabric Java SDK client application as explained above. Hence the web application needs Fabric Java SDK client application url for rest invocations.

Perform the following steps:

  • Run the below command.

    cd webapp
    
  • Update the Java application url (as noted in section 3) in config.js file of webapp directory.

  • Deploy the application to IBM Cloud using the command:

    ibmcloud cf push
    

    Deployment might take a few minutes to complete. Ensure that there are no errors while deploying the application.

5. Analyze the Results

Login to IBM Cloud. On the Dashboard, verify that an app blockchain-enabled-crowdfunding-webui is running fine. Click on the web application entry. When application page opens, click on Visit App URL. Web application page opens.

It shows the crowdfunding project details, current status of funds raised and the tasks that you can perform.

There are no donations done by default. To donate, click on Donate.

Provide the required details and click on Donate Now to donate. A pop up message appears with the result of the donation request . Click OK. Once done click on Back button to return to tasks list.

Click on View Supporters to view the list of supporters who have donated, as shown in below image.

Learn More

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

blockchain-enabled-crowdfunding's People

Contributors

ljbennett62 avatar maheshwarishikha avatar muralidharchavan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.