This CorDapp shows how Corda's observable states feature works. Observable states is the ability for nodes who are not participants in a transaction to still store them if the transactions are sent to them.
In this CorDapp, we assume that when a seller creates some kind of HighlyRegulatedState, they must notify the state
and national regulators. There are two ways to use observable states:
- By piggy-backing on
FinalityFlow - By distributing the transaction manually
The two approaches are functionally identical.
In this CorDapp, the seller runs the TradeAndReport flow to create a new HighlyRegulatedState. Then we can see that the seller will:
- Distribute the state to the buyer and the
state regulatorusingFinalityFlow - Distribute the state to the
national regulatormanually using theReportManuallyflow
See https://docs.corda.net/getting-set-up.html.
Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper)
./gradlew clean deployNodes
Then type: (to run the nodes)
./build/nodes/runnodes
Go to the CRaSH shell of Seller, and create a new HighlyRegulatedState
start TradeAndReport buyer: Buyer, stateRegulator: StateRegulator, nationalRegulator: NationalRegulator
The state will be automatically reported to StateRegulator and NationalRegulator, even though they are not participants. Check this by going to the shell of either node and running:
run vaultQuery contractStateType: com.observable.states.HighlyRegulatedState
You will see the new HighlyRegulatedState in the vault of both nodes.