Composer helps you to model business networks representing your assets and the transactions related to them using model files. Such files have a .cto file suffix and they are written using a special object-oriented modeling language (called CTO). Generally, a modeling file is composed of the following elements:
- A single namespace
- A set of resource definitions, including assets, participants, transactions, and events
- Optional imported resources and declarations from other namespaces
To give you an idea of how modeling works, let's start with a simple example, introducing the basic concepts before building the LC business network.
Open the org.example.lc.cto file generated by Yoeman and paste in the following code snippets:
namespace org.example.lc
asset SampleAsset identified by assetId { o String assetId
o String value
--> SampleParticipant owner
}
transaction TransactionExample {
--> SampleAsset asset
o String newValue
}
event AssetEvent{
-->SampleAsset asset
}
participant SampleParticipant identified by participantId {
o String participantId
}
In this simple model, we define four different types of objects, representing an asset, transaction, participant, and an event.
An asset, for example SampleAsset, is defined using the asset keyword and identified by syntax. An asset contains fields, where each field, as for other objects, is expressed in the format o Fieldtype fieldname.
Here, we also model a transaction called TransactionExample that contains a relationship to an existing instance of SampleAsset (asset), which will be changed, and a string value (newValue) used to update the asset's property (value). A relationship is a typed pointer to an instance represented in the model by an arrow, -->, pointing to the object.
Using the same syntax as for asset and transaction, we define a participant type using the participant keyword.