Getting set up for CorDapp development

Software requirements

Corda uses industry-standard tools:

Please note that OpenJDK builds usually exclude JavaFX, which our GUI tools require.

  • IntelliJ IDEA - supported versions 2017.x, 2018.x and 2019.x (with Kotlin plugin version 1.2.71)
  • Gradle - we use 5.4.1 and the gradlew script in the project / samples directories will download it for you.

Please note:

  • Applications on Corda (CorDapps) can be written in any language targeting the JVM. However, Corda itself and most of the samples are written in Kotlin. Kotlin is an official Android language, and you can read more about why Kotlin is a strong successor to Java here. If you’re unfamiliar with Kotlin, there is an official getting started guide, and a series of Kotlin Koans
  • IntelliJ IDEA is recommended due to the strength of its Kotlin integration.
  • If an HA Bridge/Float deployment is required then a Zookeeper 3.5.4-Beta cluster will be required. Refer to Hot-cold deployment and Bridge configuration for more deployment information.

Following these software recommendations will minimize the number of errors you encounter, and make it easier for others to provide support. However, if you do use other tools, we’d be interested to hear about any issues that arise.

Set-up instructions

The instructions below will allow you to set up your development environment for running Corda and writing CorDapps. If you have any issues, please reach out on Stack Overflow or via our Slack channels.

The set-up instructions are available for the following platforms:

Windows

Java

Git

  • Visit https://git-scm.com/download/win
  • Click the “64-bit Git for Windows Setup” download link.
  • Download and run the executable to install Git (use the default settings)
  • Open a new command prompt and type git --version to test that git is installed correctly

IntelliJ

Download a sample project

  • Open a command prompt
  • Clone the CorDapp example repo by running git clone https://github.com/corda/cordapp-example
  • Move into the cordapp-example folder by running cd cordapp-example
  • Checkout the corresponding branch for Corda Enterprise 3.1 by running git checkout release-enterprise-V3 in the current directory

Resolve Corda Enterprise binaries

The Corda Enterprise binaries are not available in a publicly accessible Maven repository. Instead, the Corda Enterprise binaries will be made available to your organisation as a compressed tarball (corda-3.1-developer-pack.tar.gz). This tarball contains all of the Corda dependencies as they would appear in your local Maven repository located at C:\Documents and Settings\{your-username}\.m2.

To build CorDapps on development machines the Corda Enterprise binaries will need to be discoverable by Gradle. The build.gradle file on the cordapp-example release-enterprise-V3 branch includes instructions on how to allow Gradle to discover dependencies.

  • Open cordapp-example\build.gradle
  • Do any of the following to allow Gradle to resolve Corda Enterprise binaries, for more information read the commented code in build.gradle:
  • Add Corda Enterprise binaries and dependencies to your local maven repository path (e.g., C:\Documents and Settings\{your-username}\.m2).
  • Upload Corda Enterprise binaries and dependencies to your company’s private Maven repository and register the repository with Gradle.
  • Add Corda Enterprise binaries to a local directory and register a local Maven repository pointing to this directory with Gradle.

Run from the command prompt

  • Move into the cordapp-example folder by running cd cordapp-example
  • From the cordapp-example folder, deploy the nodes by running gradlew deployNodes
  • Start the nodes by running call kotlin-source/build/nodes/runnodes.bat
  • Wait until all the terminal windows display either Webserver started up in XX.X sec or Node for "NodeC" started up and registered in XX.XX sec
  • Confirm that the CorDapp is running correctly by visiting the front end at http://localhost:10009/web/example/

Run from IntelliJ

  • Open IntelliJ Community Edition
  • On the splash screen, click Open (do not click Import Project) and select the cordapp-example folder
  • Once the project is open, click File, then Project Structure. Under Project SDK:, set the project SDK by clicking New..., clicking JDK, and navigating to C:\\Program Files\\Java\\jdk1.8.0_XXX (where XXX is the latest minor version number). Click OK
  • Again under File then Project Structure, select Modules. Click +, then Import Module, then select the cordapp-example folder and click Open. Choose to Import module from external model, select Gradle, click Next then Finish (leaving the defaults) and OK
  • Wait for the indexing to finish (a progress bar will display at the bottom-right of the IntelliJ window until indexing is complete)
  • At the top-right of the screen, to the left of the green play arrow, you should see a dropdown. In that dropdown, select Run Example Cordapp - Kotlin and click the green play arrow.
  • Wait until the run windows displays the message Webserver started up in XX.X sec
  • Confirm that the CorDapp is running correctly by visiting the front end at

http://localhost:10009/web/example/

Mac

Java

IntelliJ

Download a sample project

  • Open a terminal
  • Clone the CorDapp example repo by running git clone https://github.com/corda/cordapp-example
  • Move into the cordapp-example folder by running cd cordapp-example
  • Checkout the corresponding branch for Corda Enterprise 3.1 by running git checkout release-enterprise-V3 in the current directory

Resolve Corda Enterprise binaries

The Corda Enterprise binaries are not available in a publicly accessible Maven repository. Instead, the Corda Enterprise binaries will be made available to your organisation as a compressed tarball (corda-3.1-developer-pack.tar.gz). This tarball contains all of the Corda dependencies as they would appear in your local Maven repository located at ~/.m2/repository.

To build CorDapps on development machines the Corda Enterprise binaries will need to be discoverable by Gradle. The build.gradle file on the cordapp-example release-enterprise-V3 branch includes instructions on how to allow Gradle to discover dependencies.

  • Open cordapp-example/build.gradle
  • Do any of the following to allow Gradle to resolve Corda Enterprise binaries, for more information read the commented code in build.gradle:
  • Add Corda Enterprise binaries and dependencies to your local maven repository path e.g., ~/.m2/repository
  • Upload Corda Enterprise binaries and dependencies to your company’s private Maven repository and register the repository with Gradle.
  • Add Corda Enterprise binaries to a local directory and register a local Maven repository pointing to this directory with Gradle.

be done by firstly unpacking the corda-3.1-developer-pack.tar.gz compressed tarball:

tar -xvzf corda-3.1-developer-pack.tar.gz

Then, copy the unpacked respository folder to your local Maven repository:

rsync -av repository ~/.m2/

The extracted folder can now be deleted:

rm -rf repository

Run from the terminal

  • Move into the cordapp-example folder by running cd cordapp-example
  • From the cordapp-example folder, deploy the nodes by running ./gradlew deployNodes
  • Start the nodes by running kotlin-source/build/nodes/runnodes. Do not click while 7 additional terminal windows start up.
  • Wait until all the terminal windows display either Webserver started up in XX.X sec or Node for "NodeC" started up and registered in XX.XX sec
  • Confirm that the CorDapp is running correctly by visiting the front end at http://localhost:10009/web/example/

Run from IntelliJ

  • Open IntelliJ Community Edition
  • On the splash screen, click Open (do not click Import Project) and select the cordapp-example folder
  • Once the project is open, click File, then Project Structure. Under Project SDK:, set the project SDK by clicking New..., clicking JDK, and navigating to your JDK installation (e.g., /Library/Java/JavaVirtualMachines/jdk1.8.0_XXX.jdk, where XXX is the latest minor version number). Click OK
  • Again under File then Project Structure, select Modules. Click +, then Import Module, then select the cordapp-example folder and click Open. Choose to Import module from external model, select Gradle, click Next then Finish (leaving the defaults) and OK
  • Wait for the indexing to finish (a progress bar will display at the bottom-right of the IntelliJ window until indexing is complete)
  • At the top-right of the screen, to the left of the green play arrow, you should see a dropdown. In that dropdown, select Run Example Cordapp - Kotlin and click the green play arrow.
  • Wait until the run windows displays the message Webserver started up in XX.X sec
  • Confirm that the CorDapp is running correctly by visiting the front end at http://localhost:10009/web/example/

CorDapp Templates and samples

A CorDapp template that you can use as the basis for your own CorDapps is available in both Java and Kotlin versions:

https://github.com/corda/cordapp-template-java.git

https://github.com/corda/cordapp-template-kotlin.git

And a list of simple sample CorDapps for you to explore basic concepts is available here:

https://www.corda.net/samples/

You can clone these repos to your local machine by running the command git clone [repo URL].

Debian/Ubuntu

These instructions were tested on Ubuntu Desktop 18.04 LTS.

Java

  • Go to https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html and download jdk-8u202-linux-x64.tar.gz. You will be redirected to an Oracle login page. Login or create an account to download the JDK.
  • Extract the archive with tar -xvf jdk-8u202-linux-x64.tar.gz jdk1.8.0_202/
  • Create a directory to place the JDK e.g. sudo mkdir -p /usr/lib/jvm
  • Move the extracted archive in that folder with sudo mv ./jdk1.8.0_202 /usr/lib/jvm/
  • Add the most common java binaries to the list of alternatives to allow easy swap between Java versions in the future>
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_202/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_202/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0_202/bin/javaws" 1
  • Update permissions>
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.8.0_202
  • Set JAVA_HOME and JRE_HOME to your ~/.bash_profile and/or ~/.bashrc>
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_202
export JRE_HOME=/usr/lib/jvm/jdk1.8.0_202/jre
  • Verify that the JDK was installed correctly by running java -version

Git

  • From the terminal, Git can be installed using apt with the command sudo apt install git
  • Verify that git was installed correctly by typing git --version

IntelliJ

Jetbrains offers a pre-built snap package that allows for easy, one-step installation of IntelliJ onto Ubuntu.

  • To download the snap, navigate to https://snapcraft.io/intellij-idea-community
  • Click Install, then View in Desktop Store. Choose Ubuntu Software in the Launch Application window.
  • Ensure the Kotlin plugin in Intellij is updated to version 1.2.71 (new installs will contains this version)

Fedora

These instructions were tested on Fedora 28.

Java

Git

  • From the terminal, Git can be installed using dnf with the command sudo dnf install git
  • Verify that git was installed correctly by typing git --version

IntelliJ

You can clone these repos to your local machine by running the command git clone [repo URL].

Next steps

The best way to check that everything is working fine is by taking a deeper look at the example CorDapp.

Next, you should read through Corda Key Concepts to understand how Corda works.

By then, you’ll be ready to start writing your own CorDapps. Learn how to do this in the Hello, World tutorial. You may want to refer to the API documentation in the sidebar, the flow cookbook and the samples along the way.

If you encounter any issues, please ask on Stack Overflow or via our Slack channels.