Applying contract constraints

Previously in the Writing a CorDapp using a template tutorial, you built a CorDapp which let you model IOUs on ledger.

Your CorDapp was made up of two elements:

  • An IOUState, representing IOUs on the blockchain.
  • An IOUFlow and IOUFlowResponder flow pair, orchestrating the process of agreeing the creation of an IOU on-ledger.

However, the CorDapp as it stands so far does not impose any constraints on the evolution of IOUs on the blockchain over time. Anyone would be free to create IOUs of any value, between any party.

To rectify this, you must next write a contract to impose rules on how an IOUState can change over time. In turn, this will require some small changes to the flow you defined earlier in Modify the flow.

Start by writing the contract - see Modify the contract.

Once that’s done, you’ll need to make the necessary updates to the flow - see Update the flow.