2.4 KiB
The CorDapp Template
When writing a new CorDapp, you’ll generally want to base it on the Java Cordapp Template or the equivalent Kotlin Cordapp Template. The Cordapp Template allows you to quickly deploy your CorDapp onto a local test network of dummy nodes to evaluate its functionality.
Note that there's no need to download and install Corda itself. As long as you're working from a stable Milestone branch, the required libraries will be downloaded automatically from an online repository.
If you do wish to work from the latest snapshot, please follow the instructions here.
Downloading the template
Open a terminal window in the directory where you want to download the CorDapp template, and run the following commands:
# Clone the template from GitHub:
git clone https://github.com/corda/cordapp-template-java.git ; cd cordapp-template-java
*or*
git clone https://github.com/corda/cordapp-template-kotlin.git ; cd cordapp-template-kotlin
Template structure
We can write our CorDapp in either Java or Kotlin, and will be providing the code in both languages throughout. To implement our IOU CorDapp in Java, we'll need to modify three files. For Kotlin, we'll simply be modifying the App.kt
file:
// 1. The state
java
src/main/java/com/template/TemplateState.
// 2. The contract
java
src/main/java/com/template/TemplateContract.
// 3. The flow
java src/main/java/com/template/TemplateFlow.
src/main/kotlin/com/template/App.kt
To prevent build errors later on, you should delete the following file:
- Java:
src/test/java/com/template/FlowTests.java
- Kotlin:
src/test/kotlin/com/template/FlowTests.kt
Progress so far
We now have a template that we can build upon to define our IOU CorDapp.
We'll begin writing the CorDapp proper by writing the definition of the IOUState
.