How can I implement Track & Trace functionality in DAML?

Hi all, I’m trying to see if I can use DAML to implement the “Track & Trace” functionality.

For example, I have batches of raw materials tagged with batch number, and the raw materials will be used to produce some products with order numbers which will then be delivered to the customers.

The functionality I want to implement will be like this: I as the manufacturer want to keep track of all the information, which batch of raw materials is used in producing products with what order number, so that if any defect is discovered in one order/product caused by the bad raw material, I can easily(I’m dreaming of clicking just one button :slight_smile: ) extract all the information from the system and get aware of what other products are also using that batch of raw materials.

I have been thinking of how I can do it by DAML, while according to my current knowledge with DAML, it seems far from enough, so I’m looking for advices and guidances.

What tools or knowledge do I need?
As the starting point, can these information be extracted from DAML sandbox?
Or do you need to deploy DAML to HyperLedger Sawtooth/Fabric first and then extract from HyperLedger?
Is the way to extract from DAML sanbox very different from extracting from HyperLedger? Later I’m thinking about deploying this DAML model to HyperLedger, so it would be good to know this in advance.
How can I “join” the information together? Can it be done in DAML solely? Or do I need to use some other tools?

Any advice and suggestion would be really appreciated! :slight_smile:

Thanks in advance!

Best wishes.


1 Like

First, I would say that the semantics of Daml do not really change based on what platform you deploy on. So you can start developing on a local sandbox, deploy to project:DABL for easy cloud-based managed hosting, and shift to HyperLedger or another ledger if the properties of that ledger aid your application. In other words, it’s something to think about later, rather than up-front. Instead, for now, you can focus on Daml itself and how it can suit your application.

Regarding data, the key thing to think about is “Daml can’t know anything you don’t tell it”. The data that it works with is supplied either when you create a contract from scratch, in the form of the contract arguments, or when you exercise a choice, in the form of the choice arguments. It cannot make external network or other data requests on its own, because those are not validate-able. So when you are thinking about how to supply data to your smart contracts, think about how those can be supplied as contract and choice arguments.


Hi @GuisongFu, this sounds like a cool project!
I think the best way to go about this is to find a good data model that represents your problem in Daml. I think of a dependency tree, where each product has a dependency entry to list its inputs, and choices to add new dependencies. This way all the information that you need to know is contained in the Daml contracts, and you will be able to extract the information by querying any ledger API for these contracts. This is independent of the platform you will deploy to, be it the Daml Sandbox or HyperLedger Sawtooth/Fabric.

What do you exactly mean by “joining” information together? I suspect what you want can easily be done in Daml, but would have to understand better what you have in mind.

So in summary, all you need to get you started is the Daml IDE, a bit of understanding how Daml works and you can start hacking together a good data model for your project.


2 posts were split to a new topic: Can you manage and retrieve archived contracts in Daml when you need historical state?