Giter Site home page Giter Site logo

simple-supply-chain-using-solidity's Introduction

Supply chain & data auditing

This repository containts an Ethereum DApp that demonstrates a Supply Chain flow between a Seller and Buyer. The user story is similar to any commonly used supply chain process. A Seller can add items to the inventory system stored in the blockchain. A Buyer can purchase such items from the inventory system. Additionally a Seller can mark an item as Shipped, and similarly a Buyer can mark an item as Received.

The Farmer can/must include a picture of the good which will be stored on the IPFS server using the infura API. The Hash of the image will be included in the struct of the good.

It now includes the usage of access control which means that the owner of the contract has first to set the different roles (Farmer, Distributor, Retailer), and only these addresses can now execute their respective functions:

  • Farmer can only: HARVEST, PROCESS, PACK, SELL

  • Distributor can only: BUY, SHIP

  • Retailer can only: RECEIVE

CURRENT: live version of contract: ETHERSCAN

OTHER UPDATES COMING SOON

  • Unique Product Code Generator
  • Include OpenZeppelin structures
  • User Interface Design
  • Code optimization

Preview

app-preview-image-1 app-preview-image-2 app-preview-image-3 app-preview-image-4 app-preview-image-5

Getting Started

These instructions will get you a copy of the supply chain and lets you run the client on the local machine and deploys your own supply chain contract to the love test network rinkeby.

Prerequisites

Please make sure you've enabled MetaMask extension in your browser and gulp installed.

Installing and Using the Supply Chain Contract for Yourself on the RINKEBY TESTNETWORK

  1. Clone this repository:

    $ git clone https://github.com/Userrick/Simple-Supply-Chain-Udacity
  2. Install all requisite npm packages (as listed in package.json):

    $ npm install
  3. Create a new file in the project folder with the name migration-secrets.js:

    $ touch migration-secrets.js
  4. Copy the following into it (attention to https://):

    const secrets = {
        mnemonic: "YOUR-SEED-WORDS-FROM-METAMASK-ACCOUNT",
        ENDPOINT: "https://YOUR-INFURA-ENDPOINT_KEY"
    }
    
    module.exports = secrets;
  5. Follow this guide to reveal your seed words from your METAMASK account.

    a) Be sure to be on the rinkeby testnetwork

    b) Copy your seed words from your METAMASK into the respective marked section of the secrets-migration.js file

  6. Visit the infura website

    a) login or create account

    b) create a new project

    c) COPY the endpoint from the project to clipboard

    INFURA-key

    d) PASTE it into the respective field in the secrets-migration.js file

  7. Now launch your personal supply chain to the network by following these commands:

    $ truffle compile
    
    $ truffle migrate --reset --network rinkeby
  8. Now launch the client by the following command:

    $ npm run dev

    Now you should be able to interact with your contract at LOCALHOST via METAMASK on the rinkeby test network.

    If you encounter some issues let me know!

    Enjoy!

Running the Tests

  1. Install ganache-cli

    $ npm install -g ganache-cli
    
  2. Open a seperate terminal window and run ganache-cli:

    ganache-cli -m "spirit supply whale amount human item harsh scare congress discover talent hamster"
    
  3. Run the tests:

    truffle test
    

Built With

  • Ethereum - Ethereum is a decentralized platform that runs smart contracts
  • IPFS - IPFS is the Distributed Web | A peer-to-peer hypermedia protocol to make the web faster, safer, and more open. Is used via the API of INFURA ipfs.infurs.io to save the image.
  • Truffle Framework - Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier.
  • Gulp - Is used as building tool for e.g. to minify, convert ES6 to ES5, etc
  • truffle-hdwallet-provider - HD Wallet-enabled Web3 provider. Use it to sign transactions for addresses derived from a 12-word mnemonic.
  • NODE + NPM

Version Used

  • Truffle v5.0.17 (core: 5.0.16)
  • Solidity v0.5.0 (solc-js)
  • Node v10.15.3
  • Web3.js v1.0.0-beta.37

Authors

Starter code was provided by Udacity

Acknowledgments

  • Solidity
  • Truffle
  • IPFS

simple-supply-chain-using-solidity's People

Contributors

nishammahsin avatar

Stargazers

 avatar

Watchers

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