mirror of
https://github.com/corda/corda.git
synced 2024-12-23 06:42:33 +00:00
291 lines
12 KiB
HTML
291 lines
12 KiB
HTML
|
|
||
|
|
||
|
<!DOCTYPE html>
|
||
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
|
||
|
<title>Client RPC API — R3 Corda latest documentation</title>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<link rel="top" title="R3 Corda latest documentation" href="index.html"/>
|
||
|
<link rel="next" title="Protocol state machines" href="protocol-state-machines.html"/>
|
||
|
<link rel="prev" title="Writing a contract test" href="tutorial-test-dsl.html"/>
|
||
|
|
||
|
|
||
|
<script src="_static/js/modernizr.min.js"></script>
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body class="wy-body-for-nav" role="document">
|
||
|
|
||
|
<div class="wy-grid-for-nav">
|
||
|
|
||
|
|
||
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||
|
<div class="wy-side-scroll">
|
||
|
<div class="wy-side-nav-search">
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<a href="index.html" class="icon icon-home"> R3 Corda
|
||
|
|
||
|
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="version">
|
||
|
latest
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div role="search">
|
||
|
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
|
||
|
<input type="text" name="q" placeholder="Search docs" />
|
||
|
<input type="hidden" name="check_keywords" value="yes" />
|
||
|
<input type="hidden" name="area" value="default" />
|
||
|
</form>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<br>
|
||
|
<a href="api/index.html">API reference</a>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||
|
|
||
|
|
||
|
|
||
|
<p class="caption"><span class="caption-text">Overview</span></p>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="inthebox.html">What’s included?</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="getting-set-up.html">Getting set up</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="data-model.html">Data model</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="transaction-data-types.html">Data types</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="merkle-trees.html">Transaction Tear-offs</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="consensus.html">Consensus model</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="messaging.html">Networking and messaging</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="persistence.html">Persistence</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="creating-a-cordapp.html">Creating a Cordapp</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="creating-a-cordapp.html#gradle-plugins-for-cordapps">Gradle Plugins for Cordapps</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="running-the-demos.html">Running the demos</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="node-administration.html">Node administration</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="corda-configuration-files.html">The Corda Configuration File</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="corda-configuration-files.html#rpc-users-file">RPC Users File</a></li>
|
||
|
</ul>
|
||
|
<p class="caption"><span class="caption-text">Tutorials</span></p>
|
||
|
<ul class="current">
|
||
|
<li class="toctree-l1"><a class="reference internal" href="where-to-start.html">Where to start</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="tutorial-contract.html">Writing a contract</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="tutorial-contract-clauses.html">Writing a contract using clauses</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="tutorial-test-dsl.html">Writing a contract test</a></li>
|
||
|
<li class="toctree-l1 current"><a class="current reference internal" href="#">Client RPC API</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="protocol-state-machines.html">Protocol state machines</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="oracles.html">Writing oracle services</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="tutorial-attachments.html">Using attachments</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="event-scheduling.html">Event scheduling</a></li>
|
||
|
</ul>
|
||
|
<p class="caption"><span class="caption-text">Contracts</span></p>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="contract-catalogue.html">Contract catalogue</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="contract-irs.html">Interest Rate Swaps</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="initialmarginagreement.html">Initial Margin Agreements</a></li>
|
||
|
</ul>
|
||
|
<p class="caption"><span class="caption-text">Node API</span></p>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="clientrpc.html">Client RPC</a></li>
|
||
|
</ul>
|
||
|
<p class="caption"><span class="caption-text">Appendix</span></p>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="secure-coding-guidelines.html">Secure coding guidelines</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="release-process.html">Release process</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="release-process.html#steps-to-cut-a-release">Steps to cut a release</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="release-notes.html">Release notes</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="network-simulator.html">Network Simulator</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="node-explorer.html">Node Explorer</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="codestyle.html">Code style guide</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="building-the-docs.html">Building the documentation</a></li>
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
</nav>
|
||
|
|
||
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||
|
|
||
|
|
||
|
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||
|
<a href="index.html">R3 Corda</a>
|
||
|
</nav>
|
||
|
|
||
|
|
||
|
|
||
|
<div class="wy-nav-content">
|
||
|
<div class="rst-content">
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
||
|
<ul class="wy-breadcrumbs">
|
||
|
<li><a href="index.html">Docs</a> »</li>
|
||
|
|
||
|
<li>Client RPC API</li>
|
||
|
<li class="wy-breadcrumbs-aside">
|
||
|
|
||
|
|
||
|
<a href="_sources/tutorial-clientrpc-api.txt" rel="nofollow"> View page source</a>
|
||
|
|
||
|
|
||
|
</li>
|
||
|
</ul>
|
||
|
<hr/>
|
||
|
</div>
|
||
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
|
<div itemprop="articleBody">
|
||
|
|
||
|
<div class="section" id="client-rpc-api">
|
||
|
<h1>Client RPC API<a class="headerlink" href="#client-rpc-api" title="Permalink to this headline">¶</a></h1>
|
||
|
<p>In this tutorial we will build a simple command line utility that connects to a node and dumps the transaction graph to
|
||
|
the standard output. We will then put some simple visualisation on top. For an explanation on how the RPC works see
|
||
|
<a class="reference internal" href="clientrpc.html"><span class="doc">Client RPC</span></a>.</p>
|
||
|
<p>We start off by connecting to the node itself. For the purposes of the tutorial we will run the Trader demo on some
|
||
|
local port and connect to the Buyer side. We will pass in the address as a command line argument. To connect to the node
|
||
|
we also need to access the certificates of the node, we will access the node’s <code class="docutils literal"><span class="pre">certificates</span></code> directory directly.</p>
|
||
|
<p>Now we can connect to the node itself using a valid RPC login. By default the user <cite>user1</cite> is available with password <cite>test</cite>.</p>
|
||
|
<p><code class="docutils literal"><span class="pre">proxy</span></code> now exposes the full RPC interface of the node:</p>
|
||
|
<p>The one we need in order to dump the transaction graph is <code class="docutils literal"><span class="pre">verifiedTransactions</span></code>. The type signature tells us that the
|
||
|
RPC will return a list of transactions and an Observable stream. This is a general pattern, we query some data and the
|
||
|
node will return the current snapshot and future updates done to it.</p>
|
||
|
<p>The graph will be defined by nodes and edges between them. Each node represents a transaction and edges represent
|
||
|
output-input relations. For now let’s just print <code class="docutils literal"><span class="pre">NODE</span> <span class="pre"><txhash></span></code> for the former and <code class="docutils literal"><span class="pre">EDGE</span> <span class="pre"><txhash></span> <span class="pre"><txhash></span></code> for the
|
||
|
latter.</p>
|
||
|
<p>Now we can start the trader demo as per described in <a class="reference internal" href="running-the-demos.html"><span class="doc">Running the demos</span></a>:</p>
|
||
|
<div class="highlight-kotlin"><div class="highlight"><pre><span></span># Build the demo
|
||
|
./gradlew installDist
|
||
|
# Start the buyer
|
||
|
./build/install/r3prototyping/bin/trader-demo --role=BUYER
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>In another terminal we can connect to it with our client:</p>
|
||
|
<div class="highlight-kotlin"><div class="highlight"><pre><span></span># Connect to localhost:31337
|
||
|
./docs/source/example-code/build/install/docs/source/example-code/bin/client-rpc-tutorial localhost:31337 Print
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>We should see some <code class="docutils literal"><span class="pre">NODE</span></code>-s printed. This is because the buyer self-issues some cash for the demo.
|
||
|
Unless we ran the seller before we shouldn’t see any <code class="docutils literal"><span class="pre">EDGE</span></code>-s because the cash hasn’t been spent yet.</p>
|
||
|
<p>In another terminal we can now start the seller:</p>
|
||
|
<div class="highlight-kotlin"><div class="highlight"><pre><span></span># Start sellers in a loop
|
||
|
for i in {0..9} ; do ./build/install/r3prototyping/bin/trader-demo --role=SELLER ; done
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>We should start seeing new <code class="docutils literal"><span class="pre">NODE</span></code>-s and <code class="docutils literal"><span class="pre">EDGE</span></code>-s appearing.</p>
|
||
|
<p>Now let’s try to visualise the transaction graph. We will use a graph drawing library called <a class="reference external" href="http://graphstream-project.org/">graphstream</a></p>
|
||
|
<p>If we run the client with <code class="docutils literal"><span class="pre">Visualise</span></code> we should see a simple graph being drawn as new transactions are being created
|
||
|
by the seller runs.</p>
|
||
|
<p>That’s it! We saw how to connect to the node and stream data from it.</p>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<footer>
|
||
|
|
||
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||
|
|
||
|
<a href="protocol-state-machines.html" class="btn btn-neutral float-right" title="Protocol state machines" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||
|
|
||
|
|
||
|
<a href="tutorial-test-dsl.html" class="btn btn-neutral" title="Writing a contract test" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<hr/>
|
||
|
|
||
|
<div role="contentinfo">
|
||
|
<p>
|
||
|
© Copyright 2016, Distributed Ledger Group, LLC.
|
||
|
|
||
|
</p>
|
||
|
</div>
|
||
|
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||
|
|
||
|
</footer>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</section>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
var DOCUMENTATION_OPTIONS = {
|
||
|
URL_ROOT:'./',
|
||
|
VERSION:'latest',
|
||
|
COLLAPSE_INDEX:false,
|
||
|
FILE_SUFFIX:'.html',
|
||
|
HAS_SOURCE: true
|
||
|
};
|
||
|
</script>
|
||
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
||
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
||
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<script type="text/javascript" src="_static/js/theme.js"></script>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
jQuery(function () {
|
||
|
SphinxRtdTheme.StickyNav.enable();
|
||
|
});
|
||
|
</script>
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|