Giter Site home page Giter Site logo

sample-supply-chain-ethereum's Introduction

Important Links

  1. Demo link
  2. Contract Address
  3. Contract Creator
  4. Tx Hash of contract creation

Pfizer's Supply Chain Management (Life-saving drugs)

Problem

Lack of vaccine monitoring bodies can hamper purchase, delivery, monitoring, and transparency in the VSC. Supply chains around the globe are confronting significant interruption, and the lack of correspondence between supply chain members can impede a proper production and distribution of the COVID-19 vaccine.

Solution

By managing the supply chain, companies can cut excess costs and deliver products to the consumer faster.

Since 1990's thanks to the use of enterprise resource planning (ERP) systems considerable advancement in supply chain information sharing has taken place in last 3 decades. However, visibility remains a challenge in large supply chains involving complex transactions.

Let us consider a scenario, a simple transaction involving a manufacturer that sources a product to a supplier, and a vendor that sources the product from supplier and later sell it to customers. However in the flow from manufacturer to supplier to vendor the financial institutions which are key to financing are in a blind spot. The transaction involves information flows, inventory flows, and financial flows. The state-of-the-art ERP systems, manual audits, and inspections can’t reliably connect all the flows, which makes it hard to eliminate execution errors, improve decision-making, and resolve supply chain conflicts. The below diagram depicts the difference between conventional record keeping in supply chain management against blockchain. Read more

Implementation of Supply Chain Management:

Required:

  • Users Role: Manufacturer, Suppliers, Vendors & Customers
  • Smart Contract consisting of all the rules and protocols required for Supply chain Management. We have created 2 contacts for Users and Products, and inherited those contract within main supply-chain contract.
  • Blockchain Network to deploy the Contract. We have used Rinkeby for our contract.
  • Website for user Interface where Users according to their role can access informfation. We have created webpage with React & Native Base.

Assumptions:

  • One Manufacturer. Here we took Pfizer reference for the critical Life Saving drugs Manufacturer.
  • Only Manufacturer can add the products to Inventory.
  • Manufacturer can only add Supplier to the database and sell the products to Suppliers.
  • Supplier can only add Vendors to the database and sell the products to Vendors.
  • Vendors can only add Customers to the database and sell the products to Customers.
  • All the user roles should have mandatory metamask address on the network except Customers. Customers may or may not have meta mask address.
  • Product details and supply chain lifecycle should be public to all the users.
  • The User who deploy the contract to the main net will be considered as Manufacturer.

How it works

supply-chain-flowdiagram

How the product ownership get transfer

supply-chain-flowdiagram

Let's start with Supply-Chain-Management Smart Contracts

Do platform Setup!

Solidity

Supply Chain Objects

    // Users
    enum UserRole {
        Manufacturer,
        Supplier,
        Vendor,
        Customer
    }
    struct UserDetails {
        UserRole role;
        address id_;
        string name;
        string email;
    }

    // Products
    enum ProductType {
        BCG,
        RNA,
        MRNA,
        MMR,
        NasalFlu
    }
    struct Product {
        string name;
        address manufacturer;
        uint256 manDateEpoch;
        uint256 expDateEpoch;
        bool isInBatch; // few products will be packed & sold in batches
        uint256 batchCount; // QTY that were packed in single batch
        string barcodeId;
        string productImage;
        ProductType productType;
        string scientificName;
        string usage;
        string[] composition;
        string[] sideEffects;
    }

    // Products History
    struct UserHistory {
        address id_; // account Id of the user
        uint256 date; // Added, Purchased date in epoch in UTC timezone
    }
    struct ProductHistory {
        UserHistory manufacturer;
        UserHistory supplier;
        UserHistory vendor;
        UserHistory[] customers;
    }

Supply Chain functions list

Function Name Input Params Return value Description
getMyDetails() - UserDetails To get the details of the current logged-in user
getMyUsersList() - UserDetails[] To get all the users that current logged-in user has added
getUserDetails() metamask address of user UserDetails To get the details of the current logged-in user
addParty() UserDetails - To add vendors, Suppliers & customer's prior
getAllProducts() - Product[] To get all the products list
getSingleProduct() barcodeId Product,
ProductHistory
To get the details of the single product along with the history of the product
getMyProducts() - Product[] To get all the products that were linked to current logged-in user
addProduct() Product,
currentTime in epoch
- To add a new product to the system. Only manufacturer can add the products
sellProduct() party metamask address,
barcodeId,
currentTime in epoch
- To trasnfer the ownership to next level (By the selling-buying concept)

Events

Event Name Params Description
NewUser name
email
role's index
When a new user is added, it gets triggered with the public details
LostUser name
email
role's index
When a user is removed from the system, this gets triggered
NewProduct manufacturerName,
scientificName,
barcodeId,
manDateEpoch,
expDateEpoch
Triggers when a new product is added to system by the manufacturer
ProductOwnershipTransfer manufacturerName,
scientificName,
barcodeId,
buyerName,
buyerEmail
When the product is sold to next level in the cycle then this gets triggered

Versions

Compiler: solc: 0.8.12+commit.f00d7308

Truffle: v5.5.5

Node: v14.17.0

Quick Start

  1. cd into project repro

    cd sample-supply-chain-ethereum
    cd blockchain
    
  2. download truffle dependencies

    npm install
    
  3. Download/Start ganache

https://truffleframework.com/ganache

  1. Compiling contracts

    truffle compile
    
  2. Migrating to ganache

Note depending on ganache cli/ui you my need to change truffle.js port settings Current listing on port : 7545

    truffle migrate --network development  --reset --all
  1. Testing on ganache

    truffle test
    
  2. Switch to FrontEnd & Testing

Note Change settings to your Contract address to point to local

      cd ..
      cd front-end
      npm install
      npm start
  1. Migrating to Rinkeby

Note Change truffle settings to your Contract Creator address within the "from" rinkeby configuration

    truffle migrate --network rinkeby  --reset --all
  1. Start FrontEnd on Rinkeby

Note Revert back all your local configurations & configure it to point to rinkeby

    npm start

Team ✨

Meet the amazing team who developed this project.


Suresh Konakanchi

💻 📖 🚧

Pushkar Kumar

💻 📖 🚧

Ruchika Gupta

💻 📖 🚧

How frontend works

Pfizer Home




Pfizer Products




Add Users according to Role and View all added Users




Product Add Form by Manufacturer






Products Sell according to User's role




Products details and History





sample-supply-chain-ethereum's People

Contributors

geekruchika avatar sur950 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sample-supply-chain-ethereum's Issues

User issue

Hello,
Thanks for sharing this code. I am doing a POC for the supply chain and came across it. However, I followed the steps and set up my environment. There are two issues I'm facing.

  1. When I click on the login button I get a "Couldn't retrieve user details" error
  2. I figured maybe I need to deploy the contract and use a different contract and ABI. The trouble here is I'm not sure which sol file to use, the instructions say "ballot.sol" which is missing in the contract folder, therefore, I went ahead and used the supplychain.sol file. This proves to be too big and fails when creating a contract with "Warning! Error encountered during contract execution [max code size exceeded] " It also produces a completely different json from the one in the repo. This causes the product page to say "No products found"
    Please let me know where I am going wrong.

Thanks,
Moody

Installation Guide issue

installation steps explain step 2 as
download truffle dependencies using npm install
but there is no package.json file exist inside blockchain folder how could npm install work there.
to overcome this issue i first executed npm install @truffle/hdwallet-provider it sidplayed error of missing package that was
Error: Cannot find module '@truffle/hdwallet-provider'
to remove this error i executed npm install @truffle/hdwallet-provider then truffle compile it worked fine.
or we need to add package.json file inside blockchain folder with code

{
  "dependencies": {
    "@truffle/hdwallet-provider": "^2.1.11"
  }
}

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.