613 lines
19 KiB
HTML
613 lines
19 KiB
HTML
|
|
<!DOCTYPE HTML>
|
|
<html lang="" >
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
<title>HttpProvider · 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-highlight/website.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="_ws_index_.wsprovider.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 " 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/_index_.api.html">
|
|
|
|
<a href="../../api/classes/_index_.api.html">
|
|
|
|
|
|
Api
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.3" data-path="../">
|
|
|
|
<a href="../">
|
|
|
|
|
|
api-provider
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter active" data-level="1.3.1" data-path="_http_index_.httpprovider.html">
|
|
|
|
<a href="_http_index_.httpprovider.html">
|
|
|
|
|
|
HttpProvider
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.3.2" data-path="_ws_index_.wsprovider.html">
|
|
|
|
<a href="_ws_index_.wsprovider.html">
|
|
|
|
|
|
WsProvider
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.4" data-path="../../api-rx/">
|
|
|
|
<a href="../../api-rx/">
|
|
|
|
|
|
api-rx
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.4.1" data-path="../../api-rx/classes/_index_.rxapi.html">
|
|
|
|
<a href="../../api-rx/classes/_index_.rxapi.html">
|
|
|
|
|
|
ApiRx
|
|
|
|
</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="../.." >HttpProvider</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>The HTTP Provider allows sending requests using HTTP. it does not support subscriptions so you won´t be able to listen to events such as new blocks or balance changes. It is usually preferrable using the <a href="_ws_index_.wsprovider.html">WsProvider</a>.
|
|
<em><strong>example</strong></em>: import createApi from '@polkadot/api'; import WsProvider from '@polkadot/api-provider/ws';</p>
|
|
<p>const provider = new WsProvider('<a href="http://127.0.0.1:9933'" target="_blank">http://127.0.0.1:9933')</a>); const api = createApi(provider);</p>
|
|
<p><em><strong>see</strong></em>: <a href="_ws_index_.wsprovider.html">WsProvider</a></p>
|
|
<h1 id="hierarchy">Hierarchy</h1>
|
|
<p><strong>HttpProvider</strong></p>
|
|
<h1 id="implements">Implements</h1>
|
|
<ul>
|
|
<li><a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a></li>
|
|
</ul>
|
|
<h1 id="constructors">Constructors</h1>
|
|
<p><a id="constructor"></a></p>
|
|
<h2 id="constructor">constructor</h2>
|
|
<p>⊕ <strong>new HttpProvider</strong>(endpoint: <em><code>string</code></em>): <a href="_http_index_.httpprovider.html">HttpProvider</a></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/e9030fa/packages/api-provider/src/http/index.ts#L35" target="_blank">http/index.ts:35</a></em></p>
|
|
<p><strong>Parameters:</strong></p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Param</th>
|
|
<th>Type</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>endpoint</td>
|
|
<td><code>string</code></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p><strong>Returns:</strong> <a href="_http_index_.httpprovider.html">HttpProvider</a></p>
|
|
<hr>
|
|
<h1 id="methods">Methods</h1>
|
|
<p><a id="isconnected"></a></p>
|
|
<h2 id="isconnected">isConnected</h2>
|
|
<p>▸ <strong>isConnected</strong>(): <code>boolean</code></p>
|
|
<p><em>Implementation of <a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a>.<a href="../interfaces/_types_d_.providerinterface.md#isconnected">isConnected</a></em></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/e9030fa/packages/api-provider/src/http/index.ts#L49" target="_blank">http/index.ts:49</a></em></p>
|
|
<p>Whether the node is connected or not.</p>
|
|
<p><strong>Returns:</strong> <code>boolean</code>
|
|
true if connected</p>
|
|
<hr>
|
|
<p><a id="on"></a></p>
|
|
<h2 id="on">on</h2>
|
|
<p>▸ <strong>on</strong>(type: <em><a href="../modules/_types_d_.md#providerinterface_emitted">ProviderInterface$Emitted</a></em>, sub: <em><a href="../modules/_types_d_.md#providerinterface_emitcb">ProviderInterface$EmitCb</a></em>): <code>void</code></p>
|
|
<p><em>Implementation of <a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a>.<a href="../interfaces/_types_d_.providerinterface.md#on">on</a></em></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/e9030fa/packages/api-provider/src/http/index.ts#L56" target="_blank">http/index.ts:56</a></em></p>
|
|
<p>Events are not supported with the HttpProvider, see <a href="_ws_index_.wsprovider.html">WsProvider</a>.</p>
|
|
<p><strong>Parameters:</strong></p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Param</th>
|
|
<th>Type</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>type</td>
|
|
<td><a href="../modules/_types_d_.md#providerinterface_emitted">ProviderInterface$Emitted</a></td>
|
|
</tr>
|
|
<tr>
|
|
<td>sub</td>
|
|
<td><a href="../modules/_types_d_.md#providerinterface_emitcb">ProviderInterface$EmitCb</a></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p><strong>Returns:</strong> <code>void</code></p>
|
|
<hr>
|
|
<p><a id="send"></a></p>
|
|
<h2 id="send">send</h2>
|
|
<p>▸ <strong>send</strong>(method: <em><code>string</code></em>, params: <em><code>Array</code><<code>any</code>></em>): <code>Promise</code><<code>any</code>></p>
|
|
<p><em>Implementation of <a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a>.<a href="../interfaces/_types_d_.providerinterface.md#send">send</a></em></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/e9030fa/packages/api-provider/src/http/index.ts#L60" target="_blank">http/index.ts:60</a></em></p>
|
|
<p><strong>Parameters:</strong></p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Param</th>
|
|
<th>Type</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>method</td>
|
|
<td><code>string</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>params</td>
|
|
<td><code>Array</code><<code>any</code>></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p><strong>Returns:</strong> <code>Promise</code><<code>any</code>></p>
|
|
<hr>
|
|
<p><a id="subscribe"></a></p>
|
|
<h2 id="subscribe">subscribe</h2>
|
|
<p>▸ <strong>subscribe</strong>(types: <em><code>string</code></em>, method: <em><code>string</code></em>, params: <em><code>Array</code><<code>any</code>></em>, cb: <em><a href="../modules/_types_d_.md#providerinterface_callback">ProviderInterface$Callback</a></em>): <code>Promise</code><<code>number</code>></p>
|
|
<p><em>Implementation of <a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a>.<a href="../interfaces/_types_d_.providerinterface.md#subscribe">subscribe</a></em></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/e9030fa/packages/api-provider/src/http/index.ts#L82" target="_blank">http/index.ts:82</a></em></p>
|
|
<p>Subscriptions are not supported with the HttpProvider, see <a href="_ws_index_.wsprovider.html">WsProvider</a>.</p>
|
|
<p><strong>Parameters:</strong></p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Param</th>
|
|
<th>Type</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>types</td>
|
|
<td><code>string</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>method</td>
|
|
<td><code>string</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>params</td>
|
|
<td><code>Array</code><<code>any</code>></td>
|
|
</tr>
|
|
<tr>
|
|
<td>cb</td>
|
|
<td><a href="../modules/_types_d_.md#providerinterface_callback">ProviderInterface$Callback</a></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p><strong>Returns:</strong> <code>Promise</code><<code>number</code>></p>
|
|
<hr>
|
|
<p><a id="unsubscribe"></a></p>
|
|
<h2 id="unsubscribe">unsubscribe</h2>
|
|
<p>▸ <strong>unsubscribe</strong>(type: <em><code>string</code></em>, method: <em><code>string</code></em>, id: <em><code>number</code></em>): <code>Promise</code><<code>boolean</code>></p>
|
|
<p><em>Implementation of <a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a>.<a href="../interfaces/_types_d_.providerinterface.md#unsubscribe">unsubscribe</a></em></p>
|
|
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/e9030fa/packages/api-provider/src/http/index.ts#L91" target="_blank">http/index.ts:91</a></em></p>
|
|
<p>Subscriptions are not supported with the HttpProvider, see <a href="_ws_index_.wsprovider.html">WsProvider</a>.</p>
|
|
<p><strong>Parameters:</strong></p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Param</th>
|
|
<th>Type</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>type</td>
|
|
<td><code>string</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>method</td>
|
|
<td><code>string</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>id</td>
|
|
<td><code>number</code></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p><strong>Returns:</strong> <code>Promise</code><<code>boolean</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: api-provider">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
|
|
<a href="_ws_index_.wsprovider.html" class="navigation navigation-next " aria-label="Next page: WsProvider">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<script>
|
|
var gitbook = gitbook || [];
|
|
gitbook.push(function() {
|
|
gitbook.page.hasChanged({"page":{"title":"HttpProvider","level":"1.3.1","depth":2,"next":{"title":"WsProvider","level":"1.3.2","depth":2,"path":"api-provider/classes/_ws_index_.wsprovider.md","ref":"api-provider/classes/_ws_index_.wsprovider.md","articles":[]},"previous":{"title":"api-provider","level":"1.3","depth":1,"path":"api-provider/README.md","ref":"api-provider/README.md","articles":[{"title":"HttpProvider","level":"1.3.1","depth":2,"path":"api-provider/classes/_http_index_.httpprovider.md","ref":"api-provider/classes/_http_index_.httpprovider.md","articles":[]},{"title":"WsProvider","level":"1.3.2","depth":2,"path":"api-provider/classes/_ws_index_.wsprovider.md","ref":"api-provider/classes/_ws_index_.wsprovider.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["include-codeblock"],"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":{"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"highlight":{},"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":"api-provider/classes/_http_index_.httpprovider.md","mtime":"2018-10-03T16:49:52.384Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-03T16:50:40.697Z"},"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>
|
|
|