The Product Tracking pallet provides functionality for registering and tracking shipments, and monitoring their storage and transportation conditions, within a fictitious supply chain between various stakeholders. The high-level flow is shown below.
This pallet is part of the Substrate Enterprise sample.
It is inspired by existing projects & standards:
NOTE: This pallet implements the aforementionned process in a simplified way, thus it is intended for demonstration purposes and is not audited or ready for production use.
To register a shipment, one must send a transaction with a productTracking.registerShipment extrinsic with the following arguments:
idas the Shipment ID, an arbitrary numeric or alpha-numeric code that uniquely identifies the shipment.owneras the Substrate Account representing the person (or function within an organization) responsible for the shipping process of the given shipment.productswhich is a series of product IDs associated with the given shipment.
When a shipment has been registered, the related shipping events can be recorded on-chain by sending a productTracking.recordEvent extrinsic with an event argument, a data structure containing information about a shipping event for a given shipment:
idthe event ID, an arbitrary numeric or alpha-numeric code that uniquely identifies the event (e.g. GUID).event_typeas the type of shipping event to be recorded:ShipmentPickup,ShipmentDeliveryorSensorReading.shipment_idis the Shipment ID which identifies which shipment the given event is related to.locationis an optionalReadPointwhich contains the geographic position (latitudeandlongitude) where the event was captured.readingswhich is a series ofReadingthat represent data captured by various sensors (humidity, Temperature, vibration, etc). AReadingincludes adevice_id(unique idenfitier of the device), areading_type(type of sensor / measurement, seeReadingTypeenum), atimestamp(time at which the reading was recorded), and avalueas the actual measurement recorded by the sensor.timestampas time (represented as UNIX time) at which the event was captured by an external system or sensor.
This pallet does not depend on any externally defined traits.
This pallet depends on on the FRAME Timestamp pallet.
Run the tests with:
```
cargo test
```
To add this pallet to your runtime, simply include the following to your runtime's Cargo.toml file:
[dependencies.product-tracking]
default_features = false
git = 'https://github.com/stiiifff/pallet-product-tracking.git'
package = 'pallet-product-tracking'
version = '2.0.0-rc4'and update your runtime's std feature to include this pallet:
std = [
# --snip--
'product-tracking/std',
]You should implement it's trait like so:
/// Used for test_module
impl product_tracking::Trait for Runtime {
type Event = Event;
}and include it in your construct_runtime! macro:
ProductTracking: product_tracking::{Module, Call, Storage, Event<T>, ValidateUnsigned},This template pallet does not have any genesis configuration.
You can view the reference docs for this pallet by running:
cargo doc --open