There are many ways to identify a blockchain use case. Let's remember some important indicators of a good use case described in Chapter 3, Explaining Blockchain Technology and Working with Hyperledger:
- Is there a business network involved?
- If yes, is there a transaction that needs validation and is auditable?
- Are transparency and data immutability important?
After determining the answers to these questions, brainstorm sessions are also a good way to detail the solution and identify the best solution platform (such as IBM Food Safety), or to start creating a custom development for the use case.
Using Hyperledger Composer Modeling Language can be an easy way to define the structure of the resource that'll be processed as a transaction and stored on the ledger.
The CTO file creates the domain model for a business network definition with three major elements:
- A single namespace that contains all resource declarations within the file
- A set of resource definitions encompassing assets, transactions, participants, and events
- Optional import declarations that import resources from other namespaces
In Chapter 7, Creating Your Blockchain and IoT Solution, we created a business network. Let's explore the code we used in more detail:
A namespace is the base definition of an asset, event, participant, and transaction, as you can see here:
// **
* Sample business network definition.
*/
namespace org.example.basic
The declaration of resources and enumerated types is shown in the following code:
asset SampleAsset identified by assetId {
o String assetId
--> SampleParticipant owner
o Double value
}
participant SampleParticipant identified by participantId {
o String participantId
o String firstName
o String lastName
}
Transaction process functions are automatically invoked by the runtime when transactions are submitted using the Business Network Connection API:
transaction SampleTransaction {
--> SampleAsset origin
--> SampleAsset target
o Double txTransferAmount
}
event SampleEvent {
--> SampleAsset origin
--> SampleAsset target
o Double txTransferAmount
}
For more information about Hyperledger Composer Modeling Language, you can visit the following links: