[CI Skip] 0.31.1

This commit is contained in:
Travis CI
2018-10-10 08:05:35 +00:00
parent 4344f33de8
commit af10c69d2b
211 changed files with 7990 additions and 2245 deletions
+72
View File
@@ -0,0 +1,72 @@
[![polkadotjs](https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square)](https://polkadot.js.org) ![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square) [![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard) [![npm](https://img.shields.io/npm/v/@polkadot/api.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/api) [![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api) [![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability) [![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master) [![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=package/rpc-core)](https://david-dm.org/polkadot-js/api?path=package/rpc-core) [![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=package/rpc-core)](https://david-dm.org/polkadot-js/api?path=package/rpc-core#info=devDependencies)
@polkadot/api
=============
This library provides a clean wrapper around all the methods exposed by a Polkadot network client.
Usage
-----
Installation -
```
npm install --save @polkadot/rpc-core
```
Initialisation -
```js
import Api from '@polkadot/rpc-core';
import WsProvider from '@polkadot/rpc-provider/ws';
const provider = new WsProvider('http://127.0.0.1:9944');
const api = new Api(provider);
```
Making calls -
```js
api.chain
.getHeader('0x1234567890')
.then((header) => console.log(header))
.catch((error) => console.error(error));
```
Retrieving the best block (once-off) -
```js
api.chain
.getHead()
.then((headerHash) => {
return api.chain.getHeader(headerHash);
})
.then((header) => {
console.log(`best #${header.number.toString()}`);
})
.catch((error) => {
console.error('error:', error);
});
```
Retrieving best header via subscription -
```js
api.chain
.newHead((error, header) => {
if (error) {
console.error('error:', error);
}
console.log(`best #${header.number.toString()}`);
})
.then((subscriptionId) => {
// id for the subscription, can unsubscribe via
// api.chain.newHead.unsubscribe(subscriptionId)
})
.catch((error) => {
console.error('error subscribing:', error);
});
```
+4
View File
@@ -0,0 +1,4 @@
* ["index"](modules/_index_.md)
* [Rpc](classes/_index_.rpc.md)
* ["types.d"](modules/_types_d_.md)
* [RpcInterface$Section$Method](interfaces/_types_d_.rpcinterface_section_method.md)
+543
View File
@@ -0,0 +1,543 @@
<!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-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-provider/" />
<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="../">
<a href="../">
rpc-core
</a>
<ul class="articles">
<li class="chapter active" data-level="1.2.1" data-path="_index_.rpc.html">
<a href="_index_.rpc.html">
Rpc
</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="../../rpc-rx/">
<a href="../../rpc-rx/">
rpc-rx
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="../../rpc-rx/classes/_index_.rxapi.md">
<span>
RpcRx
</a>
</li>
</ul>
</li>
<li class="header">Examples</li>
<li class="chapter " data-level="2.1" data-path="../../examples/">
<a href="../../examples/">
Overview
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../../examples/01_simple_connect/">
<a href="../../examples/01_simple_connect/">
Simple connect
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../../examples/02_listen_to_blocks/">
<a href="../../examples/02_listen_to_blocks/">
Listen to blocks
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../../examples/03_listen_to_balance_change/">
<a href="../../examples/03_listen_to_balance_change/">
Listen to balance change
</a>
</li>
<li class="chapter " data-level="2.5" data-path="../../examples/04_generate_account/">
<a href="../../examples/04_generate_account/">
Generate Accounts
</a>
</li>
<li class="chapter " data-level="2.6" data-path="../../examples/05_read_storage/">
<a href="../../examples/05_read_storage/">
Read Storage
</a>
</li>
<li class="chapter " data-level="2.7" data-path="../../examples/06_craft_extrinsic/">
<a href="../../examples/06_craft_extrinsic/">
Craft Extrinsic
</a>
</li>
<li class="chapter " data-level="2.8" data-path="../../examples/07_transfer_dots/">
<a href="../../examples/07_transfer_dots/">
Transfer DOTs
</a>
</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.</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>&#xA0;<span class="sunlight-ident">Api</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/rpc-core&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">WsProvider</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/rpc-provider/ws&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">provider</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;ws://127.0.0.1:9944&apos;</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">api</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<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>object</code></li>
</ul>
<h1 id="constructors">Constructors</h1>
<p><a id="constructor"></a></p>
<h2 id="constructor">constructor</h2>
<p>&#x2295; <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/4344f33/packages/rpc-core/src/index.ts#L37" target="_blank">index.ts:37</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>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>provider</td>
<td><code>ProviderInterface</code></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="author"></a></p>
<h2 id="author">author</h2>
<p><strong>&#x25CF; author</strong>: <em><a href="../modules/_types_d_.md#rpcinterface_section">RpcInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/index.ts#L34" target="_blank">index.ts:34</a></em></p>
<hr>
<p><a id="chain"></a></p>
<h2 id="chain">chain</h2>
<p><strong>&#x25CF; chain</strong>: <em><a href="../modules/_types_d_.md#rpcinterface_section">RpcInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/index.ts#L35" target="_blank">index.ts:35</a></em></p>
<hr>
<p><a id="state"></a></p>
<h2 id="state">state</h2>
<p><strong>&#x25CF; state</strong>: <em><a href="../modules/_types_d_.md#rpcinterface_section">RpcInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/index.ts#L36" target="_blank">index.ts:36</a></em></p>
<hr>
<p><a id="system"></a></p>
<h2 id="system">system</h2>
<p><strong>&#x25CF; system</strong>: <em><a href="../modules/_types_d_.md#rpcinterface_section">RpcInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/index.ts#L37" target="_blank">index.ts:37</a></em></p>
<hr>
<h1 id="methods">Methods</h1>
<p><a id="signature"></a></p>
<h2 id="static-signature"><code>&lt;Static&gt;</code> signature</h2>
<p>&#x25B8; <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/4344f33/packages/rpc-core/src/index.ts#L72" target="_blank">index.ts:72</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>&#xA0;<span class="sunlight-ident">Api</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/rpc-core&apos;</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>&#xA0;<span class="sunlight-ident">name</span><span class="sunlight-operator">:</span>&#xA0;<span class="sunlight-string">&apos;test_method&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">params</span><span class="sunlight-operator">:</span>&#xA0;<span class="sunlight-punctuation">[</span>&#xA0;<span class="sunlight-punctuation">{</span>&#xA0;<span class="sunlight-ident">name</span><span class="sunlight-operator">:</span>&#xA0;<span class="sunlight-string">&apos;dest&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">type</span><span class="sunlight-operator">:</span>&#xA0;<span class="sunlight-string">&apos;Address&apos;</span>&#xA0;<span class="sunlight-punctuation">}</span>&#xA0;<span class="sunlight-punctuation">]</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">type</span><span class="sunlight-operator">:</span>&#xA0;<span class="sunlight-string">&apos;Address&apos;</span>&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>&#xA0;<span class="sunlight-comment">//&#xA0;=&gt;&#xA0;test_method&#xA0;(dest:&#xA0;Address):&#xA0;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-provider/" class="navigation navigation-next " aria-label="Next page: rpc-provider">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Rpc","level":"1.2.1","depth":2,"next":{"title":"rpc-provider","level":"1.3","depth":1,"path":"rpc-provider/README.md","ref":"rpc-provider/README.md","articles":[{"title":"HttpProvider","level":"1.3.1","depth":2,"path":"rpc-provider/classes/_http_index_.httpprovider.md","ref":"rpc-provider/classes/_http_index_.httpprovider.md","articles":[]},{"title":"WsProvider","level":"1.3.2","depth":2,"path":"rpc-provider/classes/_ws_index_.wsprovider.md","ref":"rpc-provider/classes/_ws_index_.wsprovider.md","articles":[]}]},"previous":{"title":"rpc-core","level":"1.2","depth":1,"path":"rpc-core/README.md","ref":"rpc-core/README.md","articles":[{"title":"Rpc","level":"1.2.1","depth":2,"path":"rpc-core/classes/_index_.rpc.md","ref":"rpc-core/classes/_index_.rpc.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["include-codeblock","-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},"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-10T08:04:17.080Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-10T08:05:29.107Z"},"basePath":"../..","book":{"language":""}});
});
</script>
</div>
<script src="../../gitbook/gitbook.js"></script>
<script src="../../gitbook/theme.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>
</body>
</html>
+119
View File
@@ -0,0 +1,119 @@
*__name__*: Rpc
*__summary__*: The API may use a HTTP or WebSockets provider.
*__description__*: It allows for querying a Polkadot Client Node.
*__example__*:
```javascript
import Api from '@polkadot/rpc-core';
import WsProvider from '@polkadot/rpc-provider/ws';
const provider = new WsProvider('ws://127.0.0.1:9944');
const api = new Api(provider);
```
# Hierarchy
**Rpc**
# Implements
* `object`
# Constructors
<a id="constructor"></a>
## constructor
⊕ **new Rpc**(provider: *`ProviderInterface`*): [Rpc](_index_.rpc.md)
*Defined in [index.ts:37](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/index.ts#L37)*
*__constructor__*: Default constructor for the Api Object
**Parameters:**
| Param | Type | Description |
| ------ | ------ | ------ |
| provider | `ProviderInterface` | An API provider using HTTP or WebSocket |
**Returns:** [Rpc](_index_.rpc.md)
___
# Properties
<a id="author"></a>
## author
**● author**: *[RpcInterface$Section](../modules/_types_d_.md#rpcinterface_section)*
*Defined in [index.ts:34](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/index.ts#L34)*
___
<a id="chain"></a>
## chain
**● chain**: *[RpcInterface$Section](../modules/_types_d_.md#rpcinterface_section)*
*Defined in [index.ts:35](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/index.ts#L35)*
___
<a id="state"></a>
## state
**● state**: *[RpcInterface$Section](../modules/_types_d_.md#rpcinterface_section)*
*Defined in [index.ts:36](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/index.ts#L36)*
___
<a id="system"></a>
## system
**● system**: *[RpcInterface$Section](../modules/_types_d_.md#rpcinterface_section)*
*Defined in [index.ts:37](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/index.ts#L37)*
___
# Methods
<a id="signature"></a>
## `<Static>` signature
▸ **signature**(__namedParameters: *`object`*): `string`
*Defined in [index.ts:72](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/index.ts#L72)*
*__name__*: signature
*__summary__*: Returns a string representation of the method with inputs and outputs.
*__description__*: Formats the name, inputs and outputs into a human-readable string. This contains the input parameter names input types and output type.
*__example__*:
```javascript
import Api from '@polkadot/rpc-core';
Api.signature({ name: 'test_method', params: [ { name: 'dest', type: 'Address' } ], type: 'Address' }); // => test_method (dest: Address): Address
```
**Parameters:**
| Param | Type |
| ------ | ------ |
| __namedParameters | `object` |
**Returns:** `string`
___
+500
View File
@@ -0,0 +1,500 @@
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>rpc-core · 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-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="classes/_index_.rpc.html" />
<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 active" data-level="1.2" data-path="./">
<a href="./">
rpc-core
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="classes/_index_.rpc.html">
<a href="classes/_index_.rpc.html">
Rpc
</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="../rpc-rx/">
<a href="../rpc-rx/">
rpc-rx
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="../rpc-rx/classes/_index_.rxapi.md">
<span>
RpcRx
</a>
</li>
</ul>
</li>
<li class="header">Examples</li>
<li class="chapter " data-level="2.1" data-path="../examples/">
<a href="../examples/">
Overview
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../examples/01_simple_connect/">
<a href="../examples/01_simple_connect/">
Simple connect
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../examples/02_listen_to_blocks/">
<a href="../examples/02_listen_to_blocks/">
Listen to blocks
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../examples/03_listen_to_balance_change/">
<a href="../examples/03_listen_to_balance_change/">
Listen to balance change
</a>
</li>
<li class="chapter " data-level="2.5" data-path="../examples/04_generate_account/">
<a href="../examples/04_generate_account/">
Generate Accounts
</a>
</li>
<li class="chapter " data-level="2.6" data-path="../examples/05_read_storage/">
<a href="../examples/05_read_storage/">
Read Storage
</a>
</li>
<li class="chapter " data-level="2.7" data-path="../examples/06_craft_extrinsic/">
<a href="../examples/06_craft_extrinsic/">
Craft Extrinsic
</a>
</li>
<li class="chapter " data-level="2.8" data-path="../examples/07_transfer_dots/">
<a href="../examples/07_transfer_dots/">
Transfer DOTs
</a>
</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-core</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><a href="https://polkadot.js.org" target="_blank"><img src="https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square" alt="polkadotjs"></a> <img src="https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square" alt="isc"> <a href="https://github.com/Flet/semistandard" target="_blank"><img src="https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square" alt="style"></a> <a href="https://www.npmjs.com/package/@polkadot/api" target="_blank"><img src="https://img.shields.io/npm/v/@polkadot/api.svg?style=flat-square" alt="npm"></a> <a href="https://travis-ci.org/polkadot-js/api" target="_blank"><img src="https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square" alt="travis"></a> <a href="https://codeclimate.com/github/polkadot-js/api/maintainability" target="_blank"><img src="https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square" alt="maintainability"></a> <a href="https://coveralls.io/github/polkadot-js/api?branch=master" target="_blank"><img src="https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square" alt="coverage"></a> <a href="https://david-dm.org/polkadot-js/api?path=package/rpc-core" target="_blank"><img src="https://david-dm.org/polkadot-js/api.svg?style=flat-square&amp;path=package/rpc-core" alt="dependency"></a> <a href="https://david-dm.org/polkadot-js/api?path=package/rpc-core#info=devDependencies" target="_blank"><img src="https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&amp;path=package/rpc-core" alt="devDependency"></a></p>
<h1 id="polkadotapi">@polkadot/api</h1>
<p>This library provides a clean wrapper around all the methods exposed by a Polkadot network client.</p>
<h2 id="usage">Usage</h2>
<p>Installation -</p>
<pre><code>npm install --save @polkadot/rpc-core
</code></pre><p>Initialisation -</p>
<pre><code class="lang-js"><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>&#xA0;<span class="sunlight-ident">Api</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/rpc-core&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">WsProvider</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/rpc-provider/ws&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">provider</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;http://127.0.0.1:9944&apos;</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">api</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<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>
<p>Making calls -</p>
<pre><code class="lang-js"><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-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">chain</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">getHeader</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;0x1234567890&apos;</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">then</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-keyword">catch</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p>Retrieving the best block (once-off) -</p>
<pre><code class="lang-js"><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-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">chain</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">getHead</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">then</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">headerHash</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-keyword">return</span>&#xA0;<span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">chain</span><span class="sunlight-operator">.</span><span class="sunlight-ident">getHeader</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">headerHash</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">then</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">`</span><span class="sunlight-ident">best</span>&#xA0;<span class="sunlight-punctuation">#</span><span class="sunlight-ident">$</span><span class="sunlight-punctuation">{</span><span class="sunlight-ident">header</span><span class="sunlight-operator">.</span><span class="sunlight-ident">number</span><span class="sunlight-operator">.</span><span class="sunlight-ident">toString</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">`</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-keyword">catch</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;error:&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p>Retrieving best header via subscription -</p>
<pre><code class="lang-js"><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-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">chain</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">newHead</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-keyword">if</span>&#xA0;<span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;error:&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-punctuation">}</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">`</span><span class="sunlight-ident">best</span>&#xA0;<span class="sunlight-punctuation">#</span><span class="sunlight-ident">$</span><span class="sunlight-punctuation">{</span><span class="sunlight-ident">header</span><span class="sunlight-operator">.</span><span class="sunlight-ident">number</span><span class="sunlight-operator">.</span><span class="sunlight-ident">toString</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">`</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">then</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">subscriptionId</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-comment">//&#xA0;id&#xA0;for&#xA0;the&#xA0;subscription,&#xA0;can&#xA0;unsubscribe&#xA0;via</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-comment">//&#xA0;api.chain.newHead.unsubscribe(subscriptionId)</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-keyword">catch</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;error&#xA0;subscribing:&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
</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: Introduction">
<i class="fa fa-angle-left"></i>
</a>
<a href="classes/_index_.rpc.html" class="navigation navigation-next " aria-label="Next page: Rpc">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"rpc-core","level":"1.2","depth":1,"next":{"title":"Rpc","level":"1.2.1","depth":2,"path":"rpc-core/classes/_index_.rpc.md","ref":"rpc-core/classes/_index_.rpc.md","articles":[]},"previous":{"title":"Introduction","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["include-codeblock","-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},"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/README.md","mtime":"2018-10-10T08:04:16.944Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-10T08:05:29.107Z"},"basePath":"..","book":{"language":""}});
});
</script>
</div>
<script src="../gitbook/gitbook.js"></script>
<script src="../gitbook/theme.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>
</body>
</html>
@@ -0,0 +1,51 @@
# Hierarchy
**RpcInterface$Section$Method**
# Callable
▸ **__call**(...params: *`Array`<`any`>*): `Promise`<`any`>
*Defined in [types.d.ts:7](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/types.d.ts#L7)*
**Parameters:**
| Param | Type |
| ------ | ------ |
| `Rest` params | `Array`<`any`> |
**Returns:** `Promise`<`any`>
# Properties
<a id="subscription"></a>
## subscription
**● subscription**: *`string`*
*Defined in [types.d.ts:10](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/types.d.ts#L10)*
___
<a id="unsubscribe"></a>
## unsubscribe
**● unsubscribe**: *`function`*
*Defined in [types.d.ts:11](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/types.d.ts#L11)*
#### Type declaration
▸(id: *`number`*): `Promise`<`any`>
**Parameters:**
| Param | Type |
| ------ | ------ |
| id | `number` |
**Returns:** `Promise`<`any`>
___
+10
View File
@@ -0,0 +1,10 @@
# Index
### Classes
* [Rpc](../classes/_index_.rpc.md)
---
+29
View File
@@ -0,0 +1,29 @@
# Type aliases
<a id="rpcinterface"></a>
## RpcInterface
**Ƭ RpcInterface**: *`object`*
*Defined in [types.d.ts:18](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/types.d.ts#L18)*
#### Type declaration
___
<a id="rpcinterface_section"></a>
## RpcInterface$Section
**Ƭ RpcInterface$Section**: *`object`*
*Defined in [types.d.ts:14](https://github.com/polkadot-js/api/blob/4344f33/packages/rpc-core/src/types.d.ts#L14)*
#### Type declaration
[index: `string`]: [RpcInterface$Section$Method](../interfaces/_types_d_.rpcinterface_section_method.md)
___