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:
id
as the Shipment ID, an arbitrary numeric or alpha-numeric code that uniquely identifies the shipment.owner
as the Substrate Account representing the person (or function within an organization) responsible for the shipping process of the given shipment.products
which is a series of product IDs associated with the given shipment.
When a shipment has been registered, shippting events occuring during the shipment's lifecycle can be recorded on-chain by sending a productTracking.trackShipment
extrinsic with the following argmuments:
id
is the Shipment ID which identifies which shipment is being tracked.operation
as the business operation that took place during the shipping process:Pickup
,Scan
orDeliver
.timestamp
as time (represented as UNIX time) at which the event was captured by an external system or sensor.location
is an optionalReadPoint
which contains the geographic position (latitude
andlongitude
) where the event was captured.readings
which is an optional series ofReading
that represent data captured by various sensors (humidity, Temperature, vibration, etc). AReading
includes adevice_id
(unique idenfitier of the device), areading_type
(type of sensor / measurement, seeReadingType
enum), atimestamp
(time at which the reading was recorded), and avalue
as the actual measurement recorded by the sensor.
This pallet depends on on the [FRAME EnsureOrigin System trait]
frame_support::traits::EnsureOrigin;
This pallet depends on on the FRAME Timestamp & Product registry pallets.
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
package = 'pallet-product-tracking'
version = '2.0.0'
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;
type CreateRoleOrigin = Origin;
}
and include it in your construct_runtime!
macro:
ProductTracking: product_tracking::{Module, Call, Storage, Event<T>},
This template pallet does not have any genesis configuration.
You can view the reference docs for this pallet by running:
cargo doc --open