2
votes

In Corda, I understand that any CorDapp JAR that includes a class implementing the contract interface will be automatically uploaded to the node as an attachment and propagated to other nodes as part of contract verification so that they have a copy of the contract.

How can I structure my CorDapp so that the JAR only includes definitions of shared resources, such as contracts and states, and nothing that includes proprietary logic, such as flows?

1

1 Answers

1
votes

Any production CorDapp should follow the structure defined here: https://docs.corda.net/writing-a-cordapp.html#structure.

This means that your CorDapp should actually be made up of 2+ modules, each of which will be compiled down into its own CorDapp. One module should define all the shared resources, such as contracts and states. The other modules should then depend on this shared module, as documented here: https://docs.corda.net/cordapp-build-systems.html#dependencies-on-other-cordapps.

The CorDapp templates (e.g. https://github.com/corda/cordapp-template-kotlin) display this pattern:

  • Contracts and states are defined in the cordapp-contracts-states module
  • The remaining classes are defined in the cordapp module, which has a dependency on the cordapp-contracts-states module