<h1>Creating a Cordapp<aclass="headerlink"href="#creating-a-cordapp"title="Permalink to this headline">¶</a></h1>
<p>A Cordapp is an application that runs on the Corda platform using the platform APIs and plugin system. They are self
contained in separate JARs from the node server JAR that are created and distributed.</p>
<divclass="section"id="app-plugins">
<h2>App Plugins<aclass="headerlink"href="#app-plugins"title="Permalink to this headline">¶</a></h2>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">Currently apps are only supported for JVM languages.</p>
</div>
<p>To create an app plugin you must you must extend from <aclass="reference external"href="api/net.corda.core.node/-corda-plugin-registry/index.html">CordaPluginRegistry</a>. The JavaDoc contains
specific details of the implementation, but you can extend the server in the following ways:</p>
<h2>Services<aclass="headerlink"href="#services"title="Permalink to this headline">¶</a></h2>
<p>Services are classes which are constructed after the node has started. It is provided a <aclass="reference external"href="api/net.corda.node.services.api/-service-hub-internal/index.html">ServiceHubInternal</a> which
allows a richer API than the <aclass="reference external"href="api/net.corda.node.services.api/-service-hub/index.html">ServiceHub</a> exposed to contracts. It enables adding flows, registering
<p>To use an app you must also have a node server. To create a node server run the <codeclass="docutils literal"><spanclass="pre">gradle</span><spanclass="pre">deployNodes</span></code> task.</p>
<p>This will output the node JAR to <codeclass="docutils literal"><spanclass="pre">build/libs/corda.jar</span></code> and several sample/standard
node setups to <codeclass="docutils literal"><spanclass="pre">build/nodes</span></code>. For now you can use the <codeclass="docutils literal"><spanclass="pre">build/nodes/nodea</span></code> configuration as a template.</p>
<p>Each node server by default must have a <codeclass="docutils literal"><spanclass="pre">node.conf</span></code> file in the current working directory. After first
<pclass="last">Also note that the bootstrapping process of the <codeclass="docutils literal"><spanclass="pre">corda.jar</span></code> unpacks the Corda dependencies into a
temporary folder. It is therefore suggested that the CAPSULE_CACHE_DIR environment variable be set before
starting the process to control this location.</p>
<h2>Installing Apps<aclass="headerlink"href="#installing-apps"title="Permalink to this headline">¶</a></h2>
<p>Once you have created your app JAR you can install it to a node by adding it to <codeclass="docutils literal"><spanclass="pre"><node_dir>/plugins/</span></code>. In this
case the <codeclass="docutils literal"><spanclass="pre">node_dir</span></code> is the location where your node server’s JAR and configuration file is.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">If the directory does not exist you can create it manually.</p>
</div>
</div>
<divclass="section"id="starting-your-node">
<h2>Starting your Node<aclass="headerlink"href="#starting-your-node"title="Permalink to this headline">¶</a></h2>
<p>Now you have a node server with your app installed, you can run it by navigating to <codeclass="docutils literal"><spanclass="pre"><node_dir></span></code> and running</p>
<blockquote>
<div>java -jar corda.jar</div></blockquote>
<p>The plugin should automatically be registered and the configuration file used.</p>
<divclass="admonition warning">
<pclass="first admonition-title">Warning</p>
<pclass="last">If your working directory is not <codeclass="docutils literal"><spanclass="pre"><node_dir></span></code> your plugins and configuration will not be used.</p>
</div>
<p>The configuration file and workspace paths can be overidden on the command line e.g.</p>
<p>Otherwise the workspace folder for the node is created based upon the <codeclass="docutils literal"><spanclass="pre">basedir</span></code> property in the <codeclass="docutils literal"><spanclass="pre">node.conf</span></code> file and if this is relative it is applied relative to the current working path.</p>
</div>
<divclass="section"id="debugging-your-node">
<h2>Debugging your Node<aclass="headerlink"href="#debugging-your-node"title="Permalink to this headline">¶</a></h2>
<p>To enable remote debugging of the corda process use a command line such as:</p>
<h2>Viewing persisted state of your Node<aclass="headerlink"href="#viewing-persisted-state-of-your-node"title="Permalink to this headline">¶</a></h2>
<p>To make examining the persisted contract states of your node or the internal node database tables easier, and providing you are
using the default database configuration used for demos, you should be able to connect to the internal node database over
a JDBC connection at the URL that is output to the logs at node start up. That URL will be of the form <codeclass="docutils literal"><spanclass="pre">jdbc:h2:tcp://<host>:<port>/node</span></code>.</p>
<p>The user name and password for the login are as per the node data source configuration.</p>
<p>The name and column layout of the internal node tables is in a state of flux and should not be relied upon to remain static
at the present time, and should certainly be treated as read-only.</p>
</div>
<divclass="section"id="building-against-corda">
<h2>Building Against Corda<aclass="headerlink"href="#building-against-corda"title="Permalink to this headline">¶</a></h2>
<divclass="admonition warning">
<pclass="first admonition-title">Warning</p>
<pclass="last">This feature is subject to rapid change</p>
</div>
<p>Corda now supports publishing to Maven local to build against it. To publish to Maven local run the following in the
<spanclass="n">ext</span><spanclass="o">.</span><spanclass="na">corda_version</span><spanclass="o">=</span><spanclass="s1">'<enter the corda version you build against here>'</span>
<h2>Cordformation<aclass="headerlink"href="#cordformation"title="Permalink to this headline">¶</a></h2>
<p>Cordformation is the local node deployment system for Cordapps, the nodes generated are intended to be used for
experimenting, debugging, and testing node configurations and setups but not intended for production or testnet
deployment.</p>
<p>To use this gradle plugin you must add a new task that is of the type <codeclass="docutils literal"><spanclass="pre">net.corda.plugins.Cordform</span></code> to your
build.gradle and then configure the nodes you wish to deploy with the Node and nodes configuration DSL.
This DSL is specified in the <aclass="reference external"href="api/index.html">JavaDoc</a>. An example of this is in the template-cordapp and below
at present) to run the nodes with one command (<codeclass="docutils literal"><spanclass="pre">runnodes</span></code>). On MacOS X this script will run each node in a new
terminal tab, and on Linux it will open up a new XTerm for each node. On Windows the (<codeclass="docutils literal"><spanclass="pre">runnodes.bat</span></code>) script will run
<ahref="node-services.html"class="btn btn-neutral"title="A Brief Introduction To The Node Services"accesskey="p"><spanclass="fa fa-arrow-circle-left"></span> Previous</a>
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.