Running a sample Cordapp example
To get started with corda, the development team of corda have already given a number of cordapp examples in their git repository you can access that repo there. In this blog, we are running the most common cordapps among them cordapp-example. So let’s get started.
- Install the Java 8 JDK. Corda requires at least version 8u171, but do not currently support Java 9 or higher for this version of Corda.
- Install the IntelliJ IDEA Community Edition. Corda supports IntelliJ IDEA versions 2017.x, 2018.x, 2019.x, and 2020.x ; and Kotlin plugin version 1.2.71.
- Install Git in local machine.
- If you’d prefer to install Gradle manually, install Gradle version 5.6.4. Corda requires a Gradle version between 5.1 and 5.6.4, and does not support Gradle 6.x.
- Download the cordapp-example folder from the github repo.
using terminal get into the folder.
start IntelliJ IDEA and open the cordapp-example folder. Let it download all the files and dependencies needed for building the cordapp. If you see a message saying the build completed successfully, go to the terminal and run
Unix/Mac OSX : ./gradlew deployNodes
Windows : gradlew.bat deployNodes
Check whether all the nodes deployed successfully. For reference, a folder structure of the node folder is given below.
if it’s successful and all nodes deployed successfully we can now run those nodes. To run the node we have two methods, we can do it simply by executing the runnodes as shown below
Unix/Mac OSX : ./build/nodes/runnodes
Windows : .\build\nodes\runnodes.bat
Start a Spring Boot server for each node by opening a terminal/command prompt for each node and entering the following command, replacing X with A, B and C:
Unix/Mac OSX : ./gradlew runPartyXServer
Windows : gradlew.bat runPartyXServer
Without using runnodes we can run the nodes individually, to do that open terminals for each node and follow the below-given steps,
java -jar corda.jar
Output will be like this:
If all done well now we can interact with the cordapps using the server. Try yourself and enjoy.