623 lines
21 KiB
HTML
623 lines
21 KiB
HTML
|
|
<!DOCTYPE HTML>
|
|
<html lang="" >
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
<title>Rpc · Polkadot API Book</title>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="description" content="">
|
|
<meta name="generator" content="GitBook 3.2.3">
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/style.css">
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-sunlight-highlighter/sunlight.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<meta name="HandheldFriendly" content="true"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
|
|
<link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
|
|
|
|
|
|
<link rel="next" href="../../rpc-rx/" />
|
|
|
|
|
|
<link rel="prev" href="../" />
|
|
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<div class="book">
|
|
<div class="book-summary">
|
|
|
|
|
|
<div id="book-search-input" role="search">
|
|
<input type="text" placeholder="Type to search" />
|
|
</div>
|
|
|
|
|
|
<nav role="navigation">
|
|
|
|
|
|
|
|
<ul class="summary">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="header">Packages</li>
|
|
|
|
|
|
|
|
<li class="chapter " data-level="1.1" data-path="../../">
|
|
|
|
<a href="../../">
|
|
|
|
|
|
Introduction
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.2" data-path="../../api/">
|
|
|
|
<a href="../../api/">
|
|
|
|
|
|
api
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.2.1" data-path="../../api/classes/_promise_index_.apipromise.html">
|
|
|
|
<a href="../../api/classes/_promise_index_.apipromise.html">
|
|
|
|
|
|
ApiPromise
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.2.2" data-path="../../api/classes/_rx_index_.apirx.html">
|
|
|
|
<a href="../../api/classes/_rx_index_.apirx.html">
|
|
|
|
|
|
ApiRx
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.3" data-path="../../rpc-provider/">
|
|
|
|
<a href="../../rpc-provider/">
|
|
|
|
|
|
rpc-provider
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.3.1" data-path="../../rpc-provider/classes/_http_index_.httpprovider.html">
|
|
|
|
<a href="../../rpc-provider/classes/_http_index_.httpprovider.html">
|
|
|
|
|
|
HttpProvider
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.3.2" data-path="../../rpc-provider/classes/_ws_index_.wsprovider.html">
|
|
|
|
<a href="../../rpc-provider/classes/_ws_index_.wsprovider.html">
|
|
|
|
|
|
WsProvider
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.4" data-path="../">
|
|
|
|
<a href="../">
|
|
|
|
|
|
rpc-core
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter active" data-level="1.4.1" data-path="_index_.rpc.html">
|
|
|
|
<a href="_index_.rpc.html">
|
|
|
|
|
|
Rpc
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.5" data-path="../../rpc-rx/">
|
|
|
|
<a href="../../rpc-rx/">
|
|
|
|
|
|
rpc-rx
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.5.1" data-path="../../rpc-rx/classes/_index_.rpcrx.html">
|
|
|
|
<a href="../../rpc-rx/classes/_index_.rpcrx.html">
|
|
|
|
|
|
RpcRx
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li class="header">Examples</li>
|
|
|
|
|
|
|
|
<li class="chapter " data-level="2.1" data-path="../../examples-rpc/">
|
|
|
|
<a href="../../examples-rpc/">
|
|
|
|
|
|
RPC
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="2.1.1" data-path="../../examples-rpc/01_simple_connect/">
|
|
|
|
<a href="../../examples-rpc/01_simple_connect/">
|
|
|
|
|
|
Simple connect
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="2.1.2" data-path="../../examples-rpc/02_listen_to_blocks/">
|
|
|
|
<a href="../../examples-rpc/02_listen_to_blocks/">
|
|
|
|
|
|
Listen to blocks
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="2.1.3" data-path="../../examples-rpc/03_listen_to_balance_change/">
|
|
|
|
<a href="../../examples-rpc/03_listen_to_balance_change/">
|
|
|
|
|
|
Listen to balance change
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="2.1.4" data-path="../../examples-rpc/04_generate_account/">
|
|
|
|
<a href="../../examples-rpc/04_generate_account/">
|
|
|
|
|
|
Generate Accounts
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="2.1.5" data-path="../../examples-rpc/05_read_storage/">
|
|
|
|
<a href="../../examples-rpc/05_read_storage/">
|
|
|
|
|
|
Read Storage
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="2.1.6" data-path="../../examples-rpc/06_craft_extrinsic/">
|
|
|
|
<a href="../../examples-rpc/06_craft_extrinsic/">
|
|
|
|
|
|
Craft Extrinsic
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="2.1.7" data-path="../../examples-rpc/07_transfer_dots/">
|
|
|
|
<a href="../../examples-rpc/07_transfer_dots/">
|
|
|
|
|
|
Transfer DOTs
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li class="divider"></li>
|
|
|
|
<li>
|
|
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
|
Published with GitBook
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="book-body">
|
|
|
|
<div class="body-inner">
|
|
|
|
|
|
|
|
<div class="book-header" role="navigation">
|
|
|
|
|
|
<!-- Title -->
|
|
<h1>
|
|
<i class="fa fa-circle-o-notch fa-spin"></i>
|
|
<a href="../.." >Rpc</a>
|
|
</h1>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="page-wrapper" tabindex="-1" role="main">
|
|
<div class="page-inner">
|
|
|
|
<div id="book-search-results">
|
|
<div class="search-noresults">
|
|
|
|
<section class="normal markdown-section">
|
|
|
|
<p><em><strong>name</strong></em>: Rpc</p>
|
|
<p><em><strong>summary</strong></em>: The API may use a HTTP or WebSockets provider.</p>
|
|
<p><em><strong>description</strong></em>: It allows for querying a Polkadot Client Node. WebSockets provider is recommended since HTTP provider only supports basic querying.</p>
|
|
<div class="mermaid">
|
|
graph LR;
|
|
A[Api] --> |WebSockets| B[WsProvider];
|
|
B --> |endpoint| C[ws://127.0.0.1:9944]
|
|
</div>
|
|
|
|
<p><em><strong>example</strong></em>: </p>
|
|
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span> <span class="sunlight-ident">Api</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/rpc-core'</span><span class="sunlight-punctuation">;</span>
|
|
<span class="sunlight-reservedWord">import</span> <span class="sunlight-ident">WsProvider</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/rpc-provider/ws'</span><span class="sunlight-punctuation">;</span>
|
|
|
|
<span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">provider</span> <span class="sunlight-operator">=</span> <span class="sunlight-keyword">new</span> <span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">'ws://127.0.0.1:9944'</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
|
|
<span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">api</span> <span class="sunlight-operator">=</span> <span class="sunlight-keyword">new</span> <span class="sunlight-ident">Api</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">provider</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
|
|
</span></pre></div></div></code></pre>
|
|
<h1 id="hierarchy">Hierarchy</h1>
|
|
<p><strong>Rpc</strong></p>
|
|
<h1 id="implements">Implements</h1>
|
|
<ul>
|
|
<li><code>RpcInterface</code></li>
|
|
</ul>
|
|
<h1 id="constructors">Constructors</h1>
|
|
<p><a id="constructor"></a></p>
|
|
<h2 id="constructor">constructor</h2>
|
|
<p>⊕ <strong>new Rpc</strong>(provider?: <em><code>ProviderInterface</code></em>): <a href="_index_.rpc.html">Rpc</a></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a4fc2c5/packages/rpc-core/src/index.ts#L47" target="_blank">index.ts:47</a></em></p>
|
|
<p><em><strong>constructor</strong></em>: Default constructor for the Api Object</p>
|
|
<p><strong>Parameters:</strong></p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Param</th>
|
|
<th>Type</th>
|
|
<th>Default value</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><code>Default value</code> provider</td>
|
|
<td><code>ProviderInterface</code></td>
|
|
<td>new WsProvider(defaults.WS_URL)</td>
|
|
<td>An API provider using HTTP or WebSocket</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p><strong>Returns:</strong> <a href="_index_.rpc.html">Rpc</a></p>
|
|
<hr>
|
|
<h1 id="properties">Properties</h1>
|
|
<p><a id="_provider"></a></p>
|
|
<h2 id="provider">_provider</h2>
|
|
<p><strong>● _provider</strong>: <em><code>ProviderInterface</code></em></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a4fc2c5/packages/rpc-core/src/index.ts#L43" target="_blank">index.ts:43</a></em></p>
|
|
<hr>
|
|
<p><a id="author"></a></p>
|
|
<h2 id="author">author</h2>
|
|
<p><strong>● author</strong>: <em><code>RpcInterface$Section</code></em></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a4fc2c5/packages/rpc-core/src/index.ts#L44" target="_blank">index.ts:44</a></em></p>
|
|
<hr>
|
|
<p><a id="chain"></a></p>
|
|
<h2 id="chain">chain</h2>
|
|
<p><strong>● chain</strong>: <em><code>RpcInterface$Section</code></em></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a4fc2c5/packages/rpc-core/src/index.ts#L45" target="_blank">index.ts:45</a></em></p>
|
|
<hr>
|
|
<p><a id="state"></a></p>
|
|
<h2 id="state">state</h2>
|
|
<p><strong>● state</strong>: <em><code>RpcInterface$Section</code></em></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a4fc2c5/packages/rpc-core/src/index.ts#L46" target="_blank">index.ts:46</a></em></p>
|
|
<hr>
|
|
<p><a id="system"></a></p>
|
|
<h2 id="system">system</h2>
|
|
<p><strong>● system</strong>: <em><code>RpcInterface$Section</code></em></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a4fc2c5/packages/rpc-core/src/index.ts#L47" target="_blank">index.ts:47</a></em></p>
|
|
<hr>
|
|
<h1 id="methods">Methods</h1>
|
|
<p><a id="signature"></a></p>
|
|
<h2 id="static-signature"><code><Static></code> signature</h2>
|
|
<p>▸ <strong>signature</strong>(__namedParameters: <em><code>object</code></em>): <code>string</code></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a4fc2c5/packages/rpc-core/src/index.ts#L80" target="_blank">index.ts:80</a></em></p>
|
|
<p><em><strong>name</strong></em>: signature</p>
|
|
<p><em><strong>summary</strong></em>: Returns a string representation of the method with inputs and outputs.</p>
|
|
<p><em><strong>description</strong></em>: Formats the name, inputs and outputs into a human-readable string. This contains the input parameter names input types and output type.</p>
|
|
<p><em><strong>example</strong></em>: </p>
|
|
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span> <span class="sunlight-ident">Api</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/rpc-core'</span><span class="sunlight-punctuation">;</span>
|
|
|
|
<span class="sunlight-ident">Api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">signature</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">{</span> <span class="sunlight-ident">name</span><span class="sunlight-operator">:</span> <span class="sunlight-string">'test_method'</span><span class="sunlight-punctuation">,</span> <span class="sunlight-ident">params</span><span class="sunlight-operator">:</span> <span class="sunlight-punctuation">[</span> <span class="sunlight-punctuation">{</span> <span class="sunlight-ident">name</span><span class="sunlight-operator">:</span> <span class="sunlight-string">'dest'</span><span class="sunlight-punctuation">,</span> <span class="sunlight-ident">type</span><span class="sunlight-operator">:</span> <span class="sunlight-string">'Address'</span> <span class="sunlight-punctuation">}</span> <span class="sunlight-punctuation">]</span><span class="sunlight-punctuation">,</span> <span class="sunlight-ident">type</span><span class="sunlight-operator">:</span> <span class="sunlight-string">'Address'</span> <span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span> <span class="sunlight-comment">// => test_method (dest: Address): Address</span>
|
|
</span></pre></div></div></code></pre>
|
|
<p><strong>Parameters:</strong></p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Param</th>
|
|
<th>Type</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>__namedParameters</td>
|
|
<td><code>object</code></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p><strong>Returns:</strong> <code>string</code></p>
|
|
<hr>
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
<div class="search-results">
|
|
<div class="has-results">
|
|
|
|
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
|
<ul class="search-results-list"></ul>
|
|
|
|
</div>
|
|
<div class="no-results">
|
|
|
|
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a href="../" class="navigation navigation-prev " aria-label="Previous page: rpc-core">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
|
|
<a href="../../rpc-rx/" class="navigation navigation-next " aria-label="Next page: rpc-rx">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<script>
|
|
var gitbook = gitbook || [];
|
|
gitbook.push(function() {
|
|
gitbook.page.hasChanged({"page":{"title":"Rpc","level":"1.4.1","depth":2,"next":{"title":"rpc-rx","level":"1.5","depth":1,"path":"rpc-rx/README.md","ref":"rpc-rx/README.md","articles":[{"title":"RpcRx","level":"1.5.1","depth":2,"path":"rpc-rx/classes/_index_.rpcrx.md","ref":"rpc-rx/classes/_index_.rpcrx.md","articles":[]}]},"previous":{"title":"rpc-core","level":"1.4","depth":1,"path":"rpc-core/README.md","ref":"rpc-core/README.md","articles":[{"title":"Rpc","level":"1.4.1","depth":2,"path":"rpc-core/classes/_index_.rpc.md","ref":"rpc-core/classes/_index_.rpc.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["include-codeblock","mermaid-gb3","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"mermaid-gb3":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"rpc-core/classes/_index_.rpc.md","mtime":"2018-10-11T13:30:18.190Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-11T13:31:41.446Z"},"basePath":"../..","book":{"language":""}});
|
|
});
|
|
</script>
|
|
</div>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook.js"></script>
|
|
<script src="../../gitbook/theme.js"></script>
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-search/search.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
|
|
|
</body>
|
|
</html>
|
|
|