0
votes

How does Corda support parent-child relationship between states ( i.e. one parent state to many child states that serve different purposes ) One-To-Many Relationship. Currently I am only doing it by adding the reference number ( linear id ) of the parent state into each child states.

Elaboration:

The parent states consist of common information shared by each child states, While the child states would consist of information that is only relevant to itself. Each child would evolve or transition to different lifecycles independently, unless if an action is taken upon the parent state, i.e cancellation, early expiration, it would cascade to all the children states linked to the parent. Likewise, if all children states have evolved to their end of lifecycle i.e SETTLED, the parent must be able to collate and transition itself to SETTLED as well.

An example scenario would be a buyer who would issue a purchase contract with a seller, which also consists of different items. So in one purchase contract, there may be different products, and each to be shipped to different locations. But once all items have been shipped and accounted for (SETTLED), the purchase contract is only then SETTLED.

1
By "one parent contract to many child contracts that serve different purposes", do you mean "one parent state to many child states that serve different purposes"? - Joel
Yes, parent states. will edit the question* - Rickky13
Thanks. What are you aiming to achieve by linking child and parent states? Knowing more about the use-case will help guide the response. - Joel
Added elaboration in the question - Rickky13

1 Answers

2
votes

Just reference the child states in the parent state by their linearId, or vice-versa.

You can then impose rules in the contract - for example, you can require that a transaction marking a purchase contract as Settled is also transferring all the items from the seller to the buyer.

Let me know if the use-case evolves and this model is no longer appropriate.