Run your CorDapp

Learning objectives

After you have completed this tutorial, you will know how to deploy, launch, interact with, and use the Swagger API interface to test the CorDapp that you built when following the previous tutorials.

The local Corda network needed for this CorDapp includes one notary and two nodes, each representing a party in the network - Mars Express and Peter. A Corda node is an individual instance of Corda representing one party in a network.

Deploy and run the Mission Mars CorDapp on the following test nodes:

  • Notary, which runs a notary service
  • PartyA
  • PartyB

Before you start

Before you run your Mission Mars CorDapp, you may want to compare your files to the ones from R3’s missionmars solution repository. This should give you a more holistic view of the CorDapp and help to resolve any issues you might have encountered when writing it.

Deploy your CorDapp to a local Corda 5 network

  1. Compile the CorDapp’s code into the Corda package files (.cpks) by running the ./gradlew clean build command from the root of your project.

  2. Assemble your .cpk files into a single Corda package bundle (.cpb) file using the CorDapp Builder CLI:

cordapp-builder create --cpk contracts/build/libs/corda5-missionmars-contracts-1.0-SNAPSHOT-cordapp.cpk --cpk workflows/build/libs/corda5-missionmars-workflows-1.0-SNAPSHOT-cordapp.cpk -o missionMars.cpb
  1. Configure the missionmars-network:

corda-cli network config docker-compose missionmars-network

  1. In the root of your project, create a network definition mission-mars.yaml file.

The network definition .yaml file is a template for the network you want to deploy. This template allows you to configure how the nodes will be set up.

  1. Add the following parameters to the newly-created mission-mars.yaml file:
registry: engineering-docker.software.r3.com

nodes:
  PartyA:
    debug: true
    x500: "C=GB, L=London, O=Mars Express, OU=LLC"
    users:
      user1:
        password: test
      angelenos:
        password: password
        permissions: [ "ALL" ]
  PartyB:
    x500: "C=US, L=New York, O=Peter, OU=INC"
    users:
      user1:
        password: test
      londoner:
        password: password
        permissions: [ "ALL" ]
  notary:
    notary: true
  1. Deploy your network locally and start Docker.
corda-cli network deploy -n missionmars-network -f missionmars.yaml | docker-compose -f - up -d

The -f flag allows you to specify the location of the network definition file. See the Corda CLI commands documentation for more information on commands and their flags.

This step will take some time to complete.

  1. Wait for the nodes to run. You can monitor nodes starting by using the following command:

corda-cli network wait -n missionmars-network

This command inspects the logs every few seconds until all the nodes are ready.

  1. Deploy your CorDapp to all the nodes in the running network using this command:

corda-cli package install -n missionmars-network missionMars.cpb

Step result: The package install command copies the .cpb file to the nodes' CorDapps directory and restarts the nodes' containers.

  1. Monitor CorDapp deployment by using the following command:

corda-cli network wait -n missionmars-network

  1. Verify the status of the network using the corda-cli network status -n missionmars-network command.

Step result: The Deployed apps section appears in the command’s output.

  1. Optional: To terminate the network, use:

corda-cli network terminate -n missionmars-network -ry

Interact with your CorDapp

To interact with your CorDapp and to test flows, use the Swagger API interface which is a set of HTTP APIs that you can use out of the box.

Log in to the Swagger API

  1. Open a browser and go to https://localhost:<port>/api/v1/swagger

For this app, the ports are:

  • PartyA’s node: 12112
  • PartyB’s node: 12116

Step result: The URL brings you to the Swagger API interface.

  1. To be able to interact with your CorDapp, log in to the node you want to use.

For this app, the logins are:

  • PartyA - Username: angelenos, Password: password
  • PartyB - Username: londoner, Password: password
  1. Verify if you have logged in successfully:

a. Navigate to FlowStarterRPCOps > GET /flowstarter/registeredflows.

b. Click Try it out and then Execute.

Step result: A 200 success callback code appears and Response body lists all implemented flows.

Test flows

  1. Navigate to FlowStarterRPCOps > POST /flowstarter/startflow.

  2. Click Try it out.

  3. Delete the .json code from the Request body and replace it with the one that tests the CreateAndIssueMarsVoucher flow:

{
  "rpcStartFlowRequest": {
    "clientId": "launchpad-2",
    "flowName": "net.corda.missionMars.flows.CreateAndIssueMarsVoucherInitiator",
    "parameters": {
      "parametersInJson": "{\"voucherDesc\": \"Space Shuttle 323\", \"holder\": \"C=US, L=New York, O=Peter, OU=INC\"}"
    }
  }
}
  1. Click Execute.

Step result: A 200 success callback code appears and Response body lists uuid and clientId.

  1. To see the result of the flow, copy clientId from the Response body.

  2. Navigate to FlowStarterRPCOps > GET /flowstarter/flowoutcomeforclientid/{clientid}.

  3. Click Try it out and paste in the copied clientId. Click Execute.

Step result: A 200 success callback code appears and Response body shows the flow’s status as COMPLETED as well as the details of the output state. You have now completed a full cycle of running a flow.

  1. Copy and store the linearId from the output in the Response body.

You will need to provide this ID as the voucherID when testing the RedeemBoardingTicketWithVoucher flow.

  1. Repeat all of the above steps for all of your flows.

When running each flow, you must replace the .json code for each flow in step 3:

  • For the CreateBoardingTicket flow, use:
{
  "rpcStartFlowRequest": {
    "clientId": "launchpad-3",
    "flowName": "net.corda.missionMars.flows.CreateBoardingTicketInitiator",
    "parameters": {
      "parametersInJson": "{\"ticketDescription\": \"Space Shuttle 323 - Seat 16B\", \"daysTillLaunch\": \"10\"}"
    }
  }
}
  • For the RedeemBoardingTicketWithVoucher flow, use:
{
  "rpcStartFlowRequest": {
    "clientId": "launchpad-4",
    "flowName": "net.corda.missionMars.flows.RedeemBoardingTicketWithVoucherInitiator",
    "parameters": {
      "parametersInJson": "{\"voucherID\": \"356ec449-da69-4ced-93b5-91c72c55912a\", \"holder\": \"C=US, L=New York, O=Peter, OU=INC\"}"
    }
  }
}

Next steps

Follow the Write integration tests tutorial to finish this learning path.

Was this page helpful?

Thanks for your feedback!

Chat with us

Chat with us on our #docs channel on slack. You can also join a lot of other slack channels there and have access to 1-on-1 communication with members of the R3 team and the online community.

Propose documentation improvements directly

Help us to improve the docs by contributing directly. It's simple - just fork this repository and raise a PR of your own - R3's Technical Writers will review it and apply the relevant suggestions.

We're sorry this page wasn't helpful. Let us know how we can make it better!

Chat with us

Chat with us on our #docs channel on slack. You can also join a lot of other slack channels there and have access to 1-on-1 communication with members of the R3 team and the online community.

Create an issue

Create a new GitHub issue in this repository - submit technical feedback, draw attention to a potential documentation bug, or share ideas for improvement and general feedback.

Propose documentation improvements directly

Help us to improve the docs by contributing directly. It's simple - just fork this repository and raise a PR of your own - R3's Technical Writers will review it and apply the relevant suggestions.