What is a CorDapp?
In this document, you will find:
- A breakdown of what a CorDapp is and what it does.
- Definitions of CorDapp components and their functions.
- An example CorDapp, so you can see how the components work together.
Summary
CorDapps are:
- Distributed applications that can be distributed on the Corda Network.
- A set of JAR files containing Java or Kotlin class definitions.
- Made up of components that work together to let nodes communicate and agree on updates to the shared ledger.
What is a CorDapp?
A Corda Distributed Application (CorDapp) solves a specific problem using the Corda framework. CorDapps are stored on Corda nodes and executed on the Corda network. This distributes the app, allowing it to run on multiple systems simultaneously—unlike traditional apps, which utilize one dedicated system to achieve an assigned task. CorDapps let nodes communicate with each other to reach agreement on updates to the ledger by defining flows that Corda node owners can invoke over RPC:
Glossary
Flows
Flows are routines for nodes to run. They can perform a variety of tasks, usually involving ledger updates. Flows
subclass FlowLogic
. For more information on flows, see Writing CorDapp Flows.
States
States define the facts that parties use to agree and transact. States implement the ContractState
interface. For more
information on states, see Writing CorDapp States.
Contracts
Contracts define the shared rules for updating the ledger. Contracts implement the Contract
interface. To learn
more about implementing contracts, see Writing CorDapp Contracts.
Services
Services provide long-lived utilities that don’t need to run on the network. Services subclass SingletonSerializationToken
.
Serialization whitelists
Serialization whitelists restrict the objects a node can deserialize when it receives messages from other nodes.
Serialization whitelists implement the SerializationWhitelist
interface.
CorDapp components
A CorDapp is a set of JAR files containing class definitions written in Java and/or Kotlin. These definitions function as a blueprint or prototype from which objects are created. It represents the set of properties or methods that are common to all objects of one type.
These class definitions usually include:
- Flows
- States
- Contracts
- Services
- Serialization whitelists
These components work together to let the CorDapp communicate with other nodes and reach an agreement. If the transactions the node processes require additional functionality, it may also include:
- APIs and static web content
- Utility classes
An example CorDapp
This example is an examination of the components of a CorDapp designed to trade bonds. This CorDapp would be deployed by all node owners wishing to establish a business network to trade bonds.
There are several components required for the minimum implementation of this CorDapp. First are the three required flows:
- An issuance flow, for example
IssueBondFlow
, to allow new bonds to be issued onto the ledger. - A bond trading flow,
TradeBondFlow
, where bonds already issued can be exchanged between parties. - An exit flow,
ExitBondFlow
where bonds can be exited from the ledger.
These three flows enable a basic lifecycle of bond creation, trading, and exiting between the transacting parties. However, we must create two more components to implement this CorDapp:
- A state to represent the bonds,
BondState
. This state is what will be issued, traded, and exited by the flows. - A contract that defines the rules for valid transactions,
BondContract
.
Each node owner installs this CorDapp onto their node. They can then issue, trade, and exit bonds with other node owners.
Next steps
Ready to get started with CorDapps?
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.