Building your first basic CorDapp

Follow this learning path to build your first CorDapp with a step-by-step guide. This set of tutorials teaches you how to implement the functionality and features you will need to get any CorDapp up and running. It reinforces best practices for building CorDapps.

The solution for this CorDapp is available in Java and Kotlin. This tutorial walks you through the Java version of the Apple Stamp CorDapp.

Before you start building your first CorDapp:

The story heading-link-icon

This example showcases a delivery versus payment (DvP) scenario. You are building a CorDapp for an apple orchard that wants to offer a way for customers to purchase a voucher that they will later redeem for a bushel of apples.

There are two parties involved in this transaction:

  • The owner of the orchard - Farmer Bob.
  • A customer - let’s call him Peter.

Your CorDapp must follow this process:

  1. Farmer Bob creates and issues a voucher to Peter for the apples he wishes to buy.

  2. Farmer Bob prepares the amount of apples Peter requested.

  3. Peter goes to the orchard to pick up his apples and redeems his voucher.

  4. The voucher is marked as spent and Farmer Bob gives Peter his apples.

An important feature of this CorDapp is that the voucher cannot be used more than once. It must be considered invalid after it is redeemed.

  1. Farmer Bob issues a voucher to Peter via a ledger transaction. In your CorDapp this voucher is called AppleStamp and is a state on the ledger. One transaction has been performed so far.

  2. When Farmer Bob prepares the apples Peter requested, he self-issues a bushel of apples via a self-issue transaction. This is another state on the ledger - BasketofApples. Two transactions have been performed so far.

  3. Next, Peter goes to the orchard to pick up his apples and redeems his voucher, triggering a transaction on the ledger that consumes the AppleStamp state. Three transactions have been performed so far.

  4. The BasketofApples state is transferred to Peter when the AppleStamp state is consumed and Farmer Bob gives Peter his apples.

All of these transactions are initiated by flows.

Follow these tutorials in sequential order to build your CorDapp:

  1. Write states

  2. Write contracts

  3. Write flows

  4. Write unit tests

  5. Run your CorDapp

  6. Conduct integration testing

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.