Coder Social home page Coder Social logo

saw-food-chain's Introduction

SawChain

SawChain is a distributed application designed for improving food supply-chain management through blockchain technology. It enables different parties to rely on a unique source of information and trust along the entire supply-chain. Smart contract technology makes possible to perform sales of products, backtracking of events and non-anonymity of recordings. A consortium can make up the whole configuration of the system using a customizable set of users and types in order to match their specific needs. The benefits of SawChain are equally distributed from supply-chain stakeholders to external individuals. The security of data relies on a transaction ledger which mitigates the lack of trust and transparency, satisfying the high-demand of information availability and integrity requested by customers.

Contents

Why Hyperledger Sawtooth

SawChain is designed to achieve data integrity and availability through a unique source of information between mutually-untrusted parties. The food supply-chain management involves different kind of parties, such as industries, certification authorities, customers and operators. To guarantee interoperability with regulators a permissioned-blockchain seems to be the best fit because forbids the write permission to unauthorized individuals. SawChain is based on Hyperledger Sawtooth which gives an high-degree of customization, scalability and user permissions. Taking advantage from the core features of Sawtooth, a generic customizable infrastructure for users, types, products and events is defined. The system startup is made by an external peer who acts as a system administrator and allows every authorized operator to execute I/O operations on batches of products. Each record has to pass through time and quantity constraints that aims to mitigate the introduction of un-tracked products and to reduce error rate of the users. Certification and control authorities are enabled to record a unique document fingerprint (hash) for their product certifications of quality. The huge volume of IoT transactions is easily handled exploiting the high-scalability of Sawtooth.

Architecture

Architecture overview

Running alongside the core components from Hyperledger Sawtooth, SawChain provides the smart contract (or Transaction Processor (TP) in Sawtooth jargon) responsible for the entire supply-chain application logic. Each component will run in an individual "container" using Docker. The project main directory includes a docker-compose file that contains the instructions for Docker to make up multiple components and network them together. The core pre-packaged Sawtooth components are downloaded from DockerHub.

Components

This table reports the endpoint connection, the download source and a short description for each component sketched in the architecture overview.

Name Endpoint Source Description
validator tcp://localhost:4004 DockerHub Validates blocks and transactions.
rest-api http://localhost:8008 DockerHub Provides blockchain via HTTP/JSON.
sawchain-processor -- custom The whole food supply-chain application logic.
shell -- DockerHub Environment for running Sawtooth commands.
settings-tp -- DockerHub Built-in Sawtooth transaction processor.

Getting Started

This project use Docker to simplify dependencies and deployment. After cloning this repo, follow the instructions specific to your OS to install and run whatever components are required to use docker and docker-compose from your command line. This is the only dependency required to run SawChain components because Docker takes care of each component. If you would like to locally test the SawChain TP functionalities without downloading and running every Docker container, you need to follow the instructions specific to your OS to install and run NodeJS. The JavaScript SDK it is the most consistent Sawtooth SDK and has been used to define the entire SawChain TP. The TDD process it was performed using both Mocha and Chai libraries.

In case that you're in troubles with Docker or Sawtooth.

Requirements

You need to have installed:

  • NodeJS >= 12.13.0
  • Docker >= 19.03.5
  • Docker Compose >= 1.24.1

How to start a Sawtooth node

Once Docker is installed and you've cloned this repo, navigate to the root project directory and run

docker-compose up

The first attempt it might take a while because Docker needs to download each required image from DockerHub. However, when complete will be running all required components in separate containers. Many of the components will be available through HTTP endpoints as reported in table.

In bash you can shutdown these components with the key combination ctrl-C. You can shutdown and remove the containers (destroying their data), with the command

docker-compose down

Finally, the Sawtooth Node is locally deployed and ready to be called through the REST APIs.

How to test the SawChain TP

To speed up the TDD process, a series of wrapper classes for Sawtooth context, transactions and handler features has been defined. These can be used for testing the SawChain TP features without downloading and running every Docker component. From root folder, follow these instructions to run every test defined during the development of SawChain TP.

cd /processor
npm i
npm run test

Contributions

Keep in mind that this work is a Proof of Concept (PoC) application. The project guidelines are defined according to a previous study which aim was to strengthened food supply-chains with blockchain technology (paper). The repo contains the definition of each state entity, the TP logic and its tests as reported in the paper. If you would like to interact with the blockchain, you can use simple calls to Sawtooth's standard REST API module from any type of client.

This project is NOT production ready by any means.

You are most warmly invited to play around with the repo.

License

SawChain is under the MIT software license.

Check LICENSE for more information.

saw-food-chain's People

Contributors

unicorndev99 avatar

Watchers

 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.