When you clone the corda or cordapp-template repos, they will default to the master branch. The master branch is being continuously developed upon, and its features may not align with the state of Corda as described in the docs. Additionally, the master branch of the CorDapp Template may break in response to changes in the main corda repo.
When you clone the corda or cordapp-template repos, they will default to the master branch. The master branch is being continuously developed upon, and its features may not align with the state of Corda as described in the docs. Additionally, the master branch of the CorDapp template may break in response to changes in the main corda repo.
When developing on Corda, you should always check out the latest milestone (i.e. stable) branch instead. For example, to check out milestone 7, you'd run ``git checkout release-M7``.
When developing on Corda, you should always check out the latest milestone (i.e. stable) branch instead. For example, to check out milestone 7, you'd run ``git checkout release-M7``.
@ -19,10 +19,8 @@ Corda is designed so that developers can easily extend its functionality by writ
sure you follow the instructions in :doc:`getting-set-up`, then go to
sure you follow the instructions in :doc:`getting-set-up`, then go to
:doc:`running-the-demos`.
:doc:`running-the-demos`.
If, after running the demos, you're interested in writing your own CorDapps, a template CorDapp is available on
If, after running the demos, you're interested in writing your own CorDapps, you can use the
`Github<https://github.com/corda/cordapp-template>`_. To get it running, follow the instructions in the
`CorDapp template<https://github.com/corda/cordapp-template>`_ as a base. A simple example CorDapp built upon the template is available `here <https://github.com/corda/cordapp-tutorial>`_, and a video primer on basic CorDapp structure is available `here <https://vimeo.com/192797322/aab499b152>`_.
`readme <https://github.com/corda/cordapp-template/blob/master/README.md>`_, or watch the
This guide covers how to get started with the `cordapp-template`. Please note there are two Corda repositories:
..note:: The example CorDapp was previously hosted in the `cordapp-template<https://github.com/corda/cordapp-template>`_ repository. It has now been
moved into a new `cordapp-tutorial <https://github.com/corda/cordapp-tutorial>`_ repository. Going forward, the cordapp-template repo will contain an
actual CorDapp template, which should be used as the basis for your CorDapps going forward.
*``corda`` which contains the core platform code and sample CorDapps.
This guide covers how to get started with the example CorDapp. Please note there are several Corda repositories:
*``cordapp-template`` which contains a template CorDapp you can use to bootstrap your own CorDapps. It is the subject
of this tutorial and should help you understand the basics of building a CorDapp.
*`corda <https://github.com/corda/corda>`_ which contains the core platform code and sample CorDapps.
*`cordapp-tutorial <https://github.com/corda/cordapp-tutorial>`_ which contains an example CorDapp you can use to bootstrap your own CorDapps. It is the subject of this tutorial and should help you understand the basics of building a CorDapp.
*`cordapp-template <https://github.com/corda/cordapp-template>`_ which contains a bare-bones template on which to build your own CorDapps.
We recommend you read the non-technical white paper and technical white paper before you get started with Corda:
We recommend you read the non-technical white paper and technical white paper before you get started with Corda:
@ -25,30 +29,29 @@ We recommend you read the non-technical white paper and technical white paper be
Background
Background
----------
----------
The Example CorDapp implements a basic scenario where a buyer wishes to submit purchase orders to a seller. The scenario
The Example CorDapp implements a basic scenario where one party wishes to send an IOU to another party. The scenario
defines four nodes:
defines four nodes:
***Controller** which hosts the network map service and validating notary service.
***Controller**, which hosts the network map service and validating notary service
***NodeA** who is the buyer.
***NodeA**
***NodeB** who is the seller.
***NodeB**
***NodeC** an unrelated third party.
***NodeC**
NodeA can generate purchase orders for lists and quantities of items and associated metadata such as delivery address
The nodes can generate IOUs and send them to other nodes. The flows used to facilitate the agreement process always results in
and delivery date. The flows used to facilitate the agreement process always results in an agreement with the seller as
an agreement with the recipient as long as the IOU meets the contract constraints which are defined in ``IOUContract.kt``.
long as the purchase order meets the contract constraints which are defined in ``PurchaseOrderContract.kt``.
All agreed purchase orders between NodeA and NodeB become "shared facts" between NodeA and NodeB. But note that NodeC
All agreed IOUs between NodeA and NodeB become "shared facts" between NodeA and NodeB. But note that NodeC
won't see any of these transactions or have copies of any of the resulting ``PurchaseOrderState`` objects. This is
won't see any of these transactions or have copies of any of the resulting ``IOUState`` objects. This is
because data is only propagated on a need-to-know basis.
because data is only propagated on a need-to-know basis.
Getting started
Getting started
---------------
---------------
There are two ways to get started with the CorDapp template. You can either work from a milestone release of Corda or a
There are two ways to get started with the example CorDapp. You can either work from a milestone release of Corda or a
SNAPSHOT release of Corda.
SNAPSHOT release of Corda.
**Using a monthly Corda milestone release.** If you wish to develop your CorDapp using the most recent milestone release
**Using a monthly Corda milestone release.** If you wish to develop your CorDapp using the most recent milestone release
then you can get started simply by cloning the ``cordapp-template`` repository. Gradle will grab all the required dependencies
then you can get started simply by cloning the ``cordapp-tutorial`` repository. Gradle will grab all the required dependencies
for you from our `public Maven repository <https://bintray.com/r3/corda>`_.
for you from our `public Maven repository <https://bintray.com/r3/corda>`_.
**Using a Corda SNAPSHOT build.** Alternatively, if you wish to work from the master branch of the Corda repo which contains
**Using a Corda SNAPSHOT build.** Alternatively, if you wish to work from the master branch of the Corda repo which contains
@ -69,21 +72,21 @@ The process for developing your CorDapp from a milestone release is the most sim
approach.
approach.
We publish all our milestone releases to a public Maven repository on a monthly basis. As such, Gradle will automatically
We publish all our milestone releases to a public Maven repository on a monthly basis. As such, Gradle will automatically
grab the appropriately versioned (specified in the ``cordapp-template``'s ``build.gradle`` file) dependencies for you from Maven.
grab the appropriately versioned (specified in the ``cordapp-tutorial``'s ``build.gradle`` file) dependencies for you from Maven.
All you have to do is check out the release tag of the template version you wish to use.
All you have to do is check out the release tag of the tutorial version you wish to use.
By default, the ``master`` branch of the ``cordapp-template`` points to a SNAPSHOT release of Corda, this is because it is
By default, the ``master`` branch of the ``cordapp-tutorial`` points to a SNAPSHOT release of Corda, this is because it is
being constantly updated to reflect the changes in the master branch of the `corda` repository.
being constantly updated to reflect the changes in the master branch of the `corda` repository.
..note:: If you wish to use a SNAPSHOT release then follow the instructions below: `Using a SNAPSHOT release`_.
..note:: If you wish to use a SNAPSHOT release then follow the instructions below: `Using a SNAPSHOT release`_.
To clone the ``cordapp-template`` repository, use the following command:
To clone the ``cordapp-tutorial`` repository, use the following command:
The CorDapp template has the following directory structure:
The example CorDapp has the following directory structure:
..sourcecode::none
..sourcecode::none
. cordapp-template
. cordapp-tutorial
├── README.md
├── README.md
├── LICENSE
├── LICENSE
├── build.gradle
├── build.gradle
@ -624,7 +625,7 @@ The CorDapp template has the following directory structure:
├── lib
├── lib
│ ├── ...
│ ├── ...
├── settings.gradle
├── settings.gradle
├── kotlin
├── kotlin-source
│ └── src
│ └── src
│ ├── main
│ ├── main
│ │ ├── kotlin
│ │ ├── kotlin
@ -636,10 +637,10 @@ The CorDapp template has the following directory structure:
│ │ │ ├── client
│ │ │ ├── client
│ │ │ │ └── ExampleClientRPC.kt
│ │ │ │ └── ExampleClientRPC.kt
│ │ │ ├── contract
│ │ │ ├── contract
│ │ │ │ ├── PurchaseOrderContract.kt
│ │ │ │ ├── IOUContract.kt
│ │ │ │ └── PurchaseOrderState.kt
│ │ │ │ └── IOUState.kt
│ │ │ ├── model
│ │ │ ├── model
│ │ │ │ └── PurchaseOrder.kt
│ │ │ │ └── IOU.kt
│ │ │ ├── plugin
│ │ │ ├── plugin
│ │ │ │ └── ExamplePlugin.kt
│ │ │ │ └── ExamplePlugin.kt
│ │ │ └── flow
│ │ │ └── flow
@ -666,7 +667,7 @@ The CorDapp template has the following directory structure:
│ │ └── example
│ │ └── example
│ │ └── ExampleTest.kt
│ │ └── ExampleTest.kt
│ └── resources
│ └── resources
└── java
└── java-source
└── src
└── src
├── main
├── main
│ ├── java
│ ├── java
@ -678,10 +679,10 @@ The CorDapp template has the following directory structure:
│ │ ├── client
│ │ ├── client
│ │ │ └── ExampleClientRPC.java
│ │ │ └── ExampleClientRPC.java
│ │ ├── contract
│ │ ├── contract
│ │ │ ├── PurchaseOrderContract.java
│ │ │ ├── IOUContract.java
│ │ │ └── PurchaseOrderState.java
│ │ │ └── IOUState.java
│ │ ├── model
│ │ ├── model
│ │ │ └── PurchaseOrder.java
│ │ │ └── IOU.java
│ │ ├── plugin
│ │ ├── plugin
│ │ │ └── ExamplePlugin.java
│ │ │ └── ExamplePlugin.java
│ │ └── flow
│ │ └── flow
@ -740,8 +741,8 @@ things.
If you are working from a Corda SNAPSHOT release which you have publish to Maven local then ensure that
If you are working from a Corda SNAPSHOT release which you have publish to Maven local then ensure that
``corda_version`` is the same as the version of the Corda core modules you published to Maven local. If not then change the
``corda_version`` is the same as the version of the Corda core modules you published to Maven local. If not then change the
``kotlin_version`` property. Also, if you are working from a previous milestone release, then be sure to ``git checkout``
``kotlin_version`` property. Also, if you are working from a previous cordapp-tutorial milestone release, then be sure to ``git checkout``
the correct version of the CorDapp template from the ``cordapp-template`` repo.
the correct version of the example CorDapp from the ``cordapp-tutorial`` repo.
..sourcecode::groovy
..sourcecode::groovy
@ -824,7 +825,7 @@ like to deploy for testing. See further details below:
You can add any number of nodes, with any number of services / CorDapps by editing the templates in ``deployNodes``. The
You can add any number of nodes, with any number of services / CorDapps by editing the templates in ``deployNodes``. The
only requirement is that you must specify a node to run as the network map service and one as the notary service.
only requirement is that you must specify a node to run as the network map service and one as the notary service.
..note:: CorDapps in the current cordapp-template project are automatically registered with all nodes defined in
..note:: CorDapps in the current cordapp-tutorial project are automatically registered with all nodes defined in
``deployNodes``, although we expect this to change in the near future.
``deployNodes``, although we expect this to change in the near future.
..warning:: Make sure that there are no port clashes!
..warning:: Make sure that there are no port clashes!
@ -834,7 +835,7 @@ When you are finished editing your *CordFormation* the changes will be reflected
Service Provider Configuration File
Service Provider Configuration File
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you are building a CorDapp from scratch or adding a new CorDapp to the CorDapp-template project then you must provide
If you are building a CorDapp from scratch or adding a new CorDapp to the cordapp-tutorial project then you must provide
a reference to your sub-class of ``CordaPluginRegistry`` in the provider-configuration file in located in the ``resources/META-INF/services`` directory.
a reference to your sub-class of ``CordaPluginRegistry`` in the provider-configuration file in located in the ``resources/META-INF/services`` directory.
Re-Deploying Your Nodes Locally
Re-Deploying Your Nodes Locally
@ -881,8 +882,8 @@ controller node is running and to its legal name (e.g. `networkMapService.addres
`networkMapService.legalName=controller`) (please note that the controller will not have the `networkMapService` config)
`networkMapService.legalName=controller`) (please note that the controller will not have the `networkMapService` config)
Each machine should now run its nodes using `runnodes` or `runnodes.bat`
Each machine should now run its nodes using `runnodes` or `runnodes.bat`
files. Once they are up and running, the nodes should be able to place
files. Once they are up and running, the nodes should be able to create
purchase orders among themselves in the same way as when they were running on
IOUs among themselves in the same way as when they were running on
the same machine.
the same machine.
Debugging your CorDapp
Debugging your CorDapp
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.