2017-06-05 12:37:23 +00:00
|
|
|
Writing a CorDapp
|
|
|
|
=================
|
|
|
|
|
2017-07-25 08:26:35 +00:00
|
|
|
When writing a CorDapp, you are writing a set of files in a JVM language that defines one or more of the following
|
|
|
|
Corda components:
|
2017-06-05 12:37:23 +00:00
|
|
|
|
|
|
|
* States (i.e. classes implementing ``ContractState``)
|
|
|
|
* Contracts (i.e. classes implementing ``Contract``)
|
|
|
|
* Flows (i.e. classes extending ``FlowLogic``)
|
|
|
|
* Web APIs
|
|
|
|
* Services
|
|
|
|
|
2017-07-25 08:26:35 +00:00
|
|
|
CorDapp structure
|
|
|
|
-----------------
|
|
|
|
Your CorDapp project's structure should be based on the structure of the
|
|
|
|
`Java Template CorDapp <https://github.com/corda/cordapp-template-java>`_ or the
|
|
|
|
`Kotlin Template CorDapp <https://github.com/corda/cordapp-template-kotlin>`_, depending on which language you intend
|
|
|
|
to use.
|
2017-06-05 12:37:23 +00:00
|
|
|
|
2017-07-25 08:26:35 +00:00
|
|
|
The ``src`` directory of the Template CorDapp, where we define our CorDapp's source-code, has the following structure:
|
2017-06-05 12:37:23 +00:00
|
|
|
|
|
|
|
.. parsed-literal::
|
|
|
|
|
|
|
|
src
|
|
|
|
├── main
|
|
|
|
│ ├── java
|
|
|
|
│ │ └── com
|
|
|
|
│ │ └── template
|
|
|
|
│ │ ├── Main.java
|
|
|
|
│ │ ├── api
|
|
|
|
│ │ │ └── TemplateApi.java
|
|
|
|
│ │ ├── client
|
|
|
|
│ │ │ └── TemplateClientRPC.java
|
|
|
|
│ │ ├── contract
|
|
|
|
│ │ │ └── TemplateContract.java
|
|
|
|
│ │ ├── flow
|
|
|
|
│ │ │ └── TemplateFlow.java
|
|
|
|
│ │ ├── plugin
|
|
|
|
│ │ │ └── TemplatePlugin.java
|
|
|
|
│ │ ├── service
|
|
|
|
│ │ │ └── TemplateService.java
|
|
|
|
│ │ └── state
|
|
|
|
│ │ └── TemplateState.java
|
|
|
|
│ └── resources
|
|
|
|
│ ├── META-INF
|
|
|
|
│ │ └── services
|
2017-09-29 14:45:19 +00:00
|
|
|
│ │ ├── net.corda.core.serialization.SerializationWhitelist
|
2017-06-20 14:29:35 +00:00
|
|
|
│ │ └── net.corda.webserver.services.WebServerPluginRegistry
|
2017-06-05 12:37:23 +00:00
|
|
|
│ ├── certificates
|
|
|
|
│ │ ├── sslkeystore.jks
|
|
|
|
│ │ └── truststore.jks
|
|
|
|
│ └──templateWeb
|
|
|
|
│ ├── index.html
|
|
|
|
│ └── js
|
|
|
|
│ └── template-js.js
|
|
|
|
└── test
|
|
|
|
└── java
|
|
|
|
└── com
|
|
|
|
└── template
|
|
|
|
└── contract
|
2017-09-29 14:45:19 +00:00
|
|
|
└── TemplateTests.java
|