Nuchain supports functions for building supply chain systems.
The code for building supply chain systems can be found in the following two modules:
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:
- Product registration.
- Registration tracking.
- Grant access for tracker.
Tracker is an entity/individual that can do update status tracking with access permission from the organization via DID.
(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.
Registering the product, the product needs to be registered by sending a transaction using functions extrinsic
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.
Registering tracking, the product that will be _track_ed needs to be registered first. Use the function extrinsic
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.
Doing status updates, updating the status of each process that has been passed by the product by sending transactions using the function extrinsic
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
ProductTracker that is located in module
did. This access can be granted on a limited basis
(with expiration time) or unlimited (without expiration time).
Verifying is possible by doing query using the function query
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
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.
Examples of the code can be found on Github supplychain-sample-py.