Skip to main content

Supply Chain

Nuchain supports functions for building supply chain systems.

The code for building supply chain systems can be found in the following two modules:

info

To be able to follow this section make sure you have read the section Getting Started and Build.

The supply chain system requires organizations as product holders. About the organization and how to create it can be found in section Organization

Broadly speaking, the supply chain system at Nuchain is controlled by the organization. You can use organizations for:

  1. Product registration.
  2. Registration tracking.
  3. Grant access for tracker.

Tracker is an entity/individual that can do update status tracking with access permission from the organization via DID.

Nuchain Supply Chain

(image: supply chain in Nuchain)

Every update done by tracker will produce event and event will be held by off-chain worker to generate notification.Then the notification will be pushed via webhook.

Workflow#

  1. Registering the product, the product needs to be registered by sending a transaction using functions extrinsic productRegistry.register with parameter:

    • id - this is the id product. It can be numeric, alpha-numeric, GS1 GTIN (Global Trade Item Number) or ASIN (Amazon Standard Identification Number).
    • org_id - is the ID of the organization/agency that represents ownership of the products.
    • props - a list of data containing key values ​​that describe the product. It usually contains at least the SKU or description of the product. It can also contains other information such as product's content, expiration date, weight, agricultural origin, harvest time, etc.
  2. Registering tracking, the product that will be _track_ed needs to be registered first. Use the function extrinsic productTracking.register with parameter:

    • id - its tracking id.
    • org_id - the ID of the organization/agency that represents ownership of the product.
    • year - tracking initiation year, e.g. "2021".
    • products - list/array ID of the product to be registered.
  3. Doing status updates, updating the status of each process that has been passed by the product by sending transactions using the function extrinsic productTracking.updateStatus with parameters:

    • id - ID code tracking.
    • status - (string) the status to be given.
    • timestamp - timestamp (in milliseconds).
    • location - the location where tracking is performed.
    • readings - additional information about the product.

To be able to update status, caller must have access as tracker assigned by the organization to the designated account. To give an access, you can use extrinsic function did.createDelegate of type ProductTracker that is located in module did. This access can be granted on a limited basis (with expiration time) or unlimited (without expiration time).

Verification#

Verifying is possible by doing query using the function query productTracking.tracking(ID). This function can be used to get detailed tracking data that contain metadata and a list of included product IDs.

Meanwhile, to get the events that occur in the tracking object, you can use the function query productTracking.eventsOfTracking(ID). The function only returns the ID of the event. To get the details of the event, you can query using the function productTracking.eventByIdx(IDX).

Notifications#

Nuchain can send real-time notifications out of the network (off-chain) using Web hook for every event that occurs on tracking on the blockchain network.

Nuchain uses Off-chain Worker for this purpose.

Demo#

Examples of the code can be found on Github supplychain-sample-py.