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
Before you start building your first CorDapp:
The story
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:
Farmer Bob creates and issues a voucher to Peter for the apples he wishes to buy.
Farmer Bob prepares the amount of apples Peter requested.
Peter goes to the orchard to pick up his apples and redeems his voucher.
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.
How will it work on Corda?
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.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.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.The
BasketofApples
state is transferred to Peter when theAppleStamp
state is consumed and Farmer Bob gives Peter his apples.
All of these transactions are initiated by flows.
Next steps
Follow these tutorials in sequential order to build your CorDapp:
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.