Project Template

Creating a complete Spring Boot/Corda project from scratch can be a time consuming task.
The Corbeans Yo! Cordap project templace can help you bootstrap a fully testable application in minutes. The project has state/contract, flow and Spring server modules, and even uses Partiture for flow composition.

Quick HowTo

> For Windows, use `gradlew.bat` instead of `./gradlew`
  1. Start by cloning the corbeans-yo-cordapp template
git clone https://github.com/manosbatsis/corbeans-yo-cordapp.git
  1. Navigate to the project directory
cd corbeans-yo-cordapp
  1. Build the project and run unit tests
./gradlew clean build 

Note that unit tests for the Spring Boot module use the node driver. You can also use the integrationTest task to execute the same tests against a Docker-based corda network:

./gradlew clean build integrationTest -x test

This will implicitly call deployNodes as well (see below) and uses Docker via Testcontainers (see also Corda Testacles).

Both approaches run the same tests by extending mypackage.server.AbstractRootTest.

  1. Deploy Corda nodes
./gradlew deployNodes
  1. Run nodes and webserver

Linux/Unix:

cordapp-workflow/build/nodes/runnodes

Windows:

call cordapp/build/nodes/runnodes.bat

You can also uncomment webPort and webserverJar in build.gradle to have runnodes launch Spring Boot as well, then browse the API:

http://localhost:8080/swagger-ui.html

Project Modules

  • cordapp-contract: States , contracts and tests with MockServices.
  • cordapp-workflow: Flows and tests with MockNetwork.
  • server: Spring Boot app with a number of approaches to integration testing.

Customisation

Pre-existing Cordapp

If you need to integrate a pre-existing cordapp you have two options. Either:

  • Move your existing contract and workflow modules to the cordapp-contract and cordapp-workflow modules within the project, or
  • Remove the cordapp-contract and cordapp-workflow modules and update the corresponding dependencies in the server module so that it points to your cordapp.

Application Properties

You can configure nodes, logging and other options for either runtime or testing by editing server/src/main/resources/application.properties
or server/src/test/resources/application.properties respectively.

Custom Package

If you refactor from mypackage to your actual base package, make sure to update main and test sources throughout project modules, along with the corbeans.cordappPackages property in both application.properties files in the server module.

Multiple Webservers

By default runnodes will only create a single webserver instance. If a webserver per node is desired, uncomment “PartyB” node’s webPort and webserverJar in cordapp-workflow/build.gradle’s Cordform task.