ethers.js/docs/build/html/api-providers.html
2017-05-21 20:37:29 -04:00

800 lines
62 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>Providers API &mdash; ethers.js 2.1.0 documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/css/ethers.css" type="text/css" />
<link rel="stylesheet" href="_static/css/ethers.css" type="text/css" />
<link rel="top" title="ethers.js 2.1.0 documentation" href="index.html"/>
<link rel="up" title="Application Programming Interface (API)" href="api.html"/>
<link rel="next" title="Contracts" href="api-contract.html"/>
<link rel="prev" title="Wallets" href="api-wallet.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"> ethers.js
</a>
<div class="version">
2.1.0
</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>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Developer Documentation</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="getting-started.html">Getting Started</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="api.html">Application Programming Interface (API)</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="api-wallet.html">Wallets</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Providers API</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#connecting-to-ethereum">Connecting to Ethereum</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#examples"><em>Examples</em></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#prototype">Prototype</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#provider">Provider</a></li>
<li class="toctree-l4"><a class="reference internal" href="#fallbackprovider-inherits-from-provider">FallbackProvider <sup>( inherits from Provider )</sup></a></li>
<li class="toctree-l4"><a class="reference internal" href="#jsonrpcprovider-inherits-from-provider">JsonRpcProvider <sup>( inherits from Provider )</sup></a></li>
<li class="toctree-l4"><a class="reference internal" href="#etherscanprovider-inherits-from-provider">EtherscanProvider <sup>( inherits from Provider )</sup></a></li>
<li class="toctree-l4"><a class="reference internal" href="#infuraprovider-inherits-from-jsonrpcprovider">InfuraProvider <sup>( inherits from JsonRpcProvider )</sup></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#account-actions">Account Actions</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id3"><em>Examples</em></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#blockchain-status">Blockchain Status</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id4"><em>Examples</em></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#contract-execution">Contract Execution</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id6"><em>Examples</em></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#contract-state">Contract State</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id8"><em>Examples</em></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#events">Events</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#event-types">Event Types</a></li>
<li class="toctree-l4"><a class="reference internal" href="#waitfortransaction">Waiting for Transactions</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id10"><em>Examples</em></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#objects">Objects</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#block-tag">Block Tag</a></li>
<li class="toctree-l4"><a class="reference internal" href="#blockresponse">Block Responses</a></li>
<li class="toctree-l4"><a class="reference internal" href="#transactionrequest">Transaction Requests</a></li>
<li class="toctree-l4"><a class="reference internal" href="#transactionresult">Transaction Results</a></li>
<li class="toctree-l4"><a class="reference internal" href="#transactionreceipt">Transaction Receipts</a></li>
<li class="toctree-l4"><a class="reference internal" href="#filter">Filters</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#provider-specific-extra-api-calls">Provider Specific Extra API Calls</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id16"><em>Examples</em></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="api-contract.html">Contracts</a></li>
<li class="toctree-l2"><a class="reference internal" href="api-utils.html">Utilities</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="api-advanced.html">Low-Level API</a></li>
<li class="toctree-l1"><a class="reference internal" href="cookbook.html">Cookbook</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes.html">Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing</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">ethers.js</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> &raquo;</li>
<li><a href="api.html">Application Programming Interface (API)</a> &raquo;</li>
<li>Providers API</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/api-providers.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="providers-api">
<span id="api-provider"></span><h1>Providers API<a class="headerlink" href="#providers-api" title="Permalink to this headline"></a></h1>
<p>A Provider abstracts a connection to the Ethereum blockchain, for issuing queries
and sending state changing transactions.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="n">providers</span> <span class="o">=</span> <span class="n">ethers</span><span class="o">.</span><span class="n">providers</span><span class="p">;</span>
</pre></div>
</div>
<hr class="docutils" />
<div class="section" id="connecting-to-ethereum">
<h2>Connecting to Ethereum<a class="headerlink" href="#connecting-to-ethereum" title="Permalink to this headline"></a></h2>
<p>There are several ways to connect to the Ethereum blockchain:</p>
<dl class="docutils">
<dt>new <sup>providers</sup> . EtherscanProvider( [ testnet ] [ , apiToken ] )</dt>
<dd><p class="first">Connect to the <a class="reference external" href="https://etherscan.io/apis">Etherscan</a> blockchain <a class="reference external" href="etherscan-api">web service API</a>.</p>
<p class="last"><strong>default:</strong> <em>testnet</em>=false, <em>apiToken</em>=null</p>
</dd>
<dt>new <sup>providers</sup> . JsonRpcProvider( [ url ] [ , testnet ] [, chainId ] )</dt>
<dd><p class="first">Connect to the <a class="reference external" href="https://github.com/ethereum/wiki/wiki/JSON-RPC">JSON-RPC API</a> <em>url</em> of an Ethereum node, such as <a class="reference external" href="https://ethcore.io/parity.html">Parity</a> or <a class="reference external" href="https://geth.ethereum.org">Geth</a>.</p>
<p class="last"><strong>default:</strong> <em>url</em>=&#8221;<a class="reference external" href="http://localhost:8545/">http://localhost:8545/</a>&#8221;, <em>testnet</em>=false, <em>chainId</em>=network default</p>
</dd>
<dt>new <sup>providers</sup> . InfuraProvider( [ testnet ] [ , apiAccessToken ] )</dt>
<dd><p class="first">Connect to the <a class="reference external" href="https://infura.io">INFURA</a> hosted network of Ethereum nodes.</p>
<p class="last"><strong>default:</strong> <em>testnet</em>=false, <em>apiAccessToken</em>=null</p>
</dd>
<dt>new <sup>providers</sup> . FallbackProvider( providers )</dt>
<dd>Improves reliability by attempting each provider in turn, falling back to the
next in the list if an error was encountered.</dd>
<dt><sup>providers</sup> . getDefaultProvider( [ testnet ] )</dt>
<dd><p class="first">This automatically creates a FallbackProvider backed by INFURA and Etherscan; recommended</p>
<p class="last"><strong>default:</strong> <em>testnet</em>=false</p>
</dd>
</dl>
<div class="section" id="examples">
<h3><em>Examples</em><a class="headerlink" href="#examples" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="n">providers</span> <span class="o">=</span> <span class="n">require</span><span class="p">(</span><span class="s1">&#39;ethers&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">providers</span><span class="p">;</span>
<span class="o">//</span> <span class="n">Connect</span> <span class="n">to</span> <span class="n">Ropsten</span> <span class="p">(</span><span class="n">the</span> <span class="n">test</span> <span class="n">network</span><span class="p">)</span>
<span class="n">var</span> <span class="n">testnet</span> <span class="o">=</span> <span class="n">true</span><span class="p">;</span>
<span class="o">//</span> <span class="n">Connect</span> <span class="n">to</span> <span class="n">INFUA</span>
<span class="n">var</span> <span class="n">infuraProvider</span> <span class="o">=</span> <span class="n">new</span> <span class="n">providers</span><span class="o">.</span><span class="n">InfuraProvider</span><span class="p">(</span><span class="n">testnet</span><span class="p">);</span>
<span class="o">//</span> <span class="n">Connect</span> <span class="n">to</span> <span class="n">Etherscan</span>
<span class="n">var</span> <span class="n">etherscanProvider</span> <span class="o">=</span> <span class="n">new</span> <span class="n">providersInfuraProvider</span><span class="p">(</span><span class="n">testnet</span><span class="p">);</span>
<span class="o">//</span> <span class="n">Creating</span> <span class="n">a</span> <span class="n">provider</span> <span class="n">to</span> <span class="n">automatically</span> <span class="n">fallback</span> <span class="n">onto</span> <span class="n">Etherscan</span>
<span class="o">//</span> <span class="k">if</span> <span class="n">INFURA</span> <span class="ow">is</span> <span class="n">down</span>
<span class="n">var</span> <span class="n">fallbackProvider</span> <span class="o">=</span> <span class="n">new</span> <span class="n">providers</span><span class="o">.</span><span class="n">FallbackProvider</span><span class="p">([</span>
<span class="n">infuraProvider</span><span class="p">,</span>
<span class="n">etherscanProvider</span>
<span class="p">]);</span>
<span class="o">//</span> <span class="n">This</span> <span class="ow">is</span> <span class="n">equivalent</span> <span class="n">to</span> <span class="n">using</span> <span class="n">the</span> <span class="n">getDefaultProvider</span>
<span class="n">var</span> <span class="n">provider</span> <span class="o">=</span> <span class="n">providers</span><span class="o">.</span><span class="n">getDefaultProvider</span><span class="p">(</span><span class="n">testnet</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Connect</span> <span class="n">to</span> <span class="n">a</span> <span class="n">local</span> <span class="n">Parity</span> <span class="n">instance</span>
<span class="n">var</span> <span class="n">provider</span> <span class="o">=</span> <span class="n">new</span> <span class="n">providers</span><span class="o">.</span><span class="n">JsonRpcProvider</span><span class="p">(</span><span class="s1">&#39;http://localhost:8545&#39;</span><span class="p">,</span> <span class="n">testnet</span><span class="p">);</span>
</pre></div>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="prototype">
<h2>Prototype<a class="headerlink" href="#prototype" title="Permalink to this headline"></a></h2>
<p>All properties are immutable, and reflect their default value if not specified, or if
indirectly populated by child Objects.</p>
<div class="section" id="provider">
<span id="id1"></span><h3>Provider<a class="headerlink" href="#provider" title="Permalink to this headline"></a></h3>
<dl class="docutils">
<dt><sup>prototype</sup> . testnet</dt>
<dd>Whether the provider is on the testnet (Ropsten)</dd>
<dt><sup>prototype</sup> . chainId</dt>
<dd>The chain ID (or network ID) this provider is connected as; this is used by
signers to prevent <a class="reference external" href="replay-attack">replay attacks</a> across compatible networks</dd>
</dl>
</div>
<div class="section" id="fallbackprovider-inherits-from-provider">
<h3>FallbackProvider <sup>( inherits from Provider )</sup><a class="headerlink" href="#fallbackprovider-inherits-from-provider" title="Permalink to this headline"></a></h3>
<dl class="docutils">
<dt><sup>prototype</sup> . providers</dt>
<dd>A <strong>copy</strong> of the array of providers (modifying this variable will not affect
the providers attached)</dd>
</dl>
</div>
<div class="section" id="jsonrpcprovider-inherits-from-provider">
<h3>JsonRpcProvider <sup>( inherits from Provider )</sup><a class="headerlink" href="#jsonrpcprovider-inherits-from-provider" title="Permalink to this headline"></a></h3>
<dl class="docutils">
<dt><sup>prototype</sup> . url</dt>
<dd>The JSON-RPC URL the provider is connected to</dd>
<dt><sup>prototype</sup> . send ( method , params )</dt>
<dd>Send the JSON-RPC <em>method</em> with <em>params</em>. This is useful for calling
non-standard or less common JSON-RPC methods. A <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> is
returned which will resolve to the parsed JSON result.</dd>
</dl>
</div>
<div class="section" id="etherscanprovider-inherits-from-provider">
<h3>EtherscanProvider <sup>( inherits from Provider )</sup><a class="headerlink" href="#etherscanprovider-inherits-from-provider" title="Permalink to this headline"></a></h3>
<dl class="docutils">
<dt><sup>prototype</sup> . apiToken</dt>
<dd>The Etherscan API Token (or null if not specified)</dd>
</dl>
</div>
<div class="section" id="infuraprovider-inherits-from-jsonrpcprovider">
<h3>InfuraProvider <sup>( inherits from JsonRpcProvider )</sup><a class="headerlink" href="#infuraprovider-inherits-from-jsonrpcprovider" title="Permalink to this headline"></a></h3>
<dl class="docutils">
<dt><sup>prototype</sup> . apiAccessToken</dt>
<dd>The INFURA API Access Token (or null if not specified)</dd>
</dl>
</div>
</div>
<hr class="docutils" />
<div class="section" id="account-actions">
<h2>Account Actions<a class="headerlink" href="#account-actions" title="Permalink to this headline"></a></h2>
<dl class="docutils">
<dt><sup>prototype</sup> . getBalance ( addressOrName [ , blockTag ] )</dt>
<dd><p class="first">Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the balance (as a <a class="reference internal" href="api-utils.html#bignumber"><span class="std std-ref">BigNumber</span></a>) of
<em>addressOrName</em> at <em>blockTag</em>. (See: <a class="reference external" href="blocktag">Block Tags</a>)</p>
<p class="last"><strong>default:</strong> <em>blockTag</em>=&#8221;latest&#8221;</p>
</dd>
<dt><sup>prototype</sup> . getTransactionCount ( addressOrName [ , blockTag ] )</dt>
<dd><p class="first">Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the number of sent transactions (as a Number) from
<em>addressOrName</em> at <em>blockTag</em>. This is also the nonce required to send a new
transaction. (See: <a class="reference external" href="blocktag">Block Tags</a>)</p>
<p class="last"><strong>default:</strong> <em>blockTag</em>=&#8221;latest&#8221;</p>
</dd>
<dt><sup>prototype</sup> . resolveName ( ensName )</dt>
<dd>Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the address (or null) of that the <em>ensName</em> resolves
to.</dd>
</dl>
<div class="section" id="id3">
<h3><em>Examples</em><a class="headerlink" href="#id3" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="n">provider</span> <span class="o">=</span> <span class="n">providers</span><span class="o">.</span><span class="n">getDefaultProvider</span><span class="p">();</span>
<span class="n">var</span> <span class="n">address</span> <span class="o">=</span> <span class="s2">&quot;0x02F024e0882B310c6734703AB9066EdD3a10C6e0&quot;</span><span class="p">;</span>
<span class="n">provider</span><span class="o">.</span><span class="n">getBalance</span><span class="p">(</span><span class="n">address</span><span class="p">)</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">balance</span><span class="p">)</span> <span class="p">{</span>
<span class="o">//</span> <span class="n">balance</span> <span class="ow">is</span> <span class="n">a</span> <span class="n">BigNumber</span> <span class="p">(</span><span class="ow">in</span> <span class="n">wei</span><span class="p">);</span> <span class="nb">format</span> <span class="ow">is</span> <span class="k">as</span> <span class="n">a</span> <span class="n">sting</span> <span class="p">(</span><span class="ow">in</span> <span class="n">ether</span><span class="p">)</span>
<span class="n">var</span> <span class="n">etherString</span> <span class="o">=</span> <span class="n">ethers</span><span class="o">.</span><span class="n">utils</span><span class="o">.</span><span class="n">formatEther</span><span class="p">(</span><span class="n">balance</span><span class="p">);</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s2">&quot;Balance: &quot;</span> <span class="o">+</span> <span class="n">etherString</span><span class="p">);</span>
<span class="p">});</span>
<span class="n">provider</span><span class="o">.</span><span class="n">getTransactionCount</span><span class="p">(</span><span class="n">address</span><span class="p">)</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">transactionCount</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s2">&quot;Total Transactions Ever Send: &quot;</span> <span class="o">+</span> <span class="n">transactionCount</span><span class="p">);</span>
<span class="p">});</span>
<span class="n">provider</span><span class="o">.</span><span class="n">resolveName</span><span class="p">(</span><span class="s2">&quot;test.ricmoose.eth&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">address</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s2">&quot;Address: &quot;</span> <span class="o">+</span> <span class="n">address</span><span class="p">);</span>
<span class="p">});</span>
</pre></div>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="blockchain-status">
<h2>Blockchain Status<a class="headerlink" href="#blockchain-status" title="Permalink to this headline"></a></h2>
<dl class="docutils">
<dt><sup>prototype</sup> . getBlockNumber ( )</dt>
<dd>Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the latest block number (as a Number).</dd>
<dt><sup>prototype</sup> . getGasPrice ( )</dt>
<dd>Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the current gas price (as a <a class="reference internal" href="api-utils.html#bignumber"><span class="std std-ref">BigNumber</span></a>).</dd>
<dt><sup>prototype</sup> . getBlock ( blockHashOrBlockNumber )</dt>
<dd>Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the block at <em>blockHashorBlockNumber</em>. (See: <a class="reference external" href="blockresponse">Block Responses</a>)</dd>
<dt><sup>prototype</sup> . getTransaction ( transactionHash )</dt>
<dd>Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the transaction with <em>transactionHash</em>. (See: <a class="reference external" href="transactionresult">Transaction Results</a>)</dd>
<dt><sup>prototype</sup> . getTransactionReceipt ( transactionHash )</dt>
<dd>Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the transaction receipt with <em>transactionHash</em>.
(See: <a class="reference external" href="transactionReceipts">Transaction Receipts</a>)</dd>
</dl>
<div class="section" id="id4">
<h3><em>Examples</em><a class="headerlink" href="#id4" title="Permalink to this headline"></a></h3>
<p><strong>Current State</strong></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="n">provider</span> <span class="o">=</span> <span class="n">providers</span><span class="o">.</span><span class="n">getDefaultProvider</span><span class="p">();</span>
<span class="n">provider</span><span class="o">.</span><span class="n">getBlockNumber</span><span class="p">()</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">blockNumber</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s2">&quot;Current block number: &quot;</span> <span class="o">+</span> <span class="n">blockNumber</span><span class="p">);</span>
<span class="p">});</span>
<span class="n">provider</span><span class="o">.</span><span class="n">getGasPrice</span><span class="p">()</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">gasPrice</span><span class="p">)</span> <span class="p">{</span>
<span class="o">//</span> <span class="n">gasPrice</span> <span class="ow">is</span> <span class="n">a</span> <span class="n">BigNumber</span><span class="p">;</span> <span class="n">convert</span> <span class="n">it</span> <span class="n">to</span> <span class="n">a</span> <span class="n">decimal</span> <span class="n">string</span>
<span class="n">gasPriceString</span> <span class="o">=</span> <span class="n">gasPrice</span><span class="o">.</span><span class="n">toString</span><span class="p">();</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s2">&quot;Current gas price: &quot;</span> <span class="o">+</span> <span class="n">gasPriceString</span><span class="p">);</span>
<span class="p">});</span>
</pre></div>
</div>
<p><strong>Blocks</strong></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="n">provider</span> <span class="o">=</span> <span class="n">providers</span><span class="o">.</span><span class="n">getDefaultProvider</span><span class="p">();</span>
<span class="o">//</span> <span class="n">Block</span> <span class="n">Number</span>
<span class="n">provider</span><span class="o">.</span><span class="n">getBlock</span><span class="p">(</span><span class="mi">3346773</span><span class="p">)</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">block</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">block</span><span class="p">);</span>
<span class="p">});</span>
<span class="o">//</span> <span class="n">Block</span> <span class="n">Hash</span>
<span class="n">var</span> <span class="n">blockHash</span> <span class="o">=</span> <span class="s2">&quot;0x7a1d0b010393c8d850200d0ec1e27c0c8a295366247b1bd6124d496cf59182ad&quot;</span><span class="p">;</span>
<span class="n">provider</span><span class="o">.</span><span class="n">getBlock</span><span class="p">(</span><span class="n">blockHash</span><span class="p">)</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">block</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">block</span><span class="p">);</span>
<span class="p">});</span>
</pre></div>
</div>
<p><strong>Transactions</strong></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="n">provider</span> <span class="o">=</span> <span class="n">providers</span><span class="o">.</span><span class="n">getDefaultProvider</span><span class="p">();</span>
<span class="n">var</span> <span class="n">transactionHash</span> <span class="o">=</span> <span class="s2">&quot;0x7baea23e7d77bff455d94f0c81916f938c398252fb62fce2cdb43643134ce4ed&quot;</span><span class="p">;</span>
<span class="n">provider</span><span class="o">.</span><span class="n">getTransaction</span><span class="p">(</span><span class="n">transactionHash</span><span class="p">)</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">transaction</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">transaction</span><span class="p">);</span>
<span class="p">});</span>
<span class="n">provider</span><span class="o">.</span><span class="n">getTransactionReceipt</span><span class="p">(</span><span class="n">transactionHash</span><span class="p">)</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">transactionReceipt</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">transactionReceipt</span><span class="p">);</span>
<span class="p">});</span>
</pre></div>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="contract-execution">
<h2>Contract Execution<a class="headerlink" href="#contract-execution" title="Permalink to this headline"></a></h2>
<p>These are relatively low-level calls. The <a class="reference internal" href="api-contract.html#api-contract"><span class="std std-ref">Contracts API</span></a> should
usually be used instead.</p>
<dl class="docutils">
<dt><sup>prototype</sup> . call ( transaction )</dt>
<dd><p class="first">Send the <strong>read-only</strong> (constant) <em>transaction</em> to a single Ethereum node and
return a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the result (as a <a class="reference internal" href="api-utils.html#hexstring"><span class="std std-ref">hex string</span></a>) of executing it.
(See <a class="reference external" href="transactionrequest">Transaction Requests</a>)</p>
<p class="last">This is free, since it does not change any state on the blockchain.</p>
</dd>
<dt><sup>prototype</sup> . estimateGas ( transaction )</dt>
<dd><p class="first">Send a <em>transaction</em> to a single Ethereum node and return a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the
estimated amount of gas required (as a <a class="reference internal" href="api-utils.html#bignumber"><span class="std std-ref">BigNumber</span></a>) to send it.
(See <a class="reference external" href="transactionrequest">Transaction Requests</a>)</p>
<p class="last">This is free, but only an estimate. Providing too little gas will result in a
transaction being rejected (while still consuming all provided gas).</p>
</dd>
<dt><sup>prototype</sup> . sendTransaction ( signedTransaction )</dt>
<dd><p class="first">Send the <em>signedTransaction</em> to the <strong>entire</strong> Ethereum network and returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a>
with the transaction hash.</p>
<p class="last"><strong>This will consume gas</strong> from the account that signed the transaction.</p>
</dd>
</dl>
<div class="section" id="id6">
<h3><em>Examples</em><a class="headerlink" href="#id6" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="nd">@TODO</span>
</pre></div>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="contract-state">
<h2>Contract State<a class="headerlink" href="#contract-state" title="Permalink to this headline"></a></h2>
<dl class="docutils">
<dt><sup>prototype</sup> . getCode ( addressOrName )</dt>
<dd>Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the bytecode (as a <a class="reference internal" href="api-utils.html#hexstring"><span class="std std-ref">hex string</span></a>)
at <em>addressOrName</em>.</dd>
<dt><sup>prototype</sup> . getStorageAt ( addressOrName, position [ , blockTag ] )</dt>
<dd><p class="first">Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the value (as a <a class="reference internal" href="api-utils.html#hexstring"><span class="std std-ref">hex string</span></a>) at
<em>addressOrName</em> in <em>position</em> at <em>blockTag</em>. (See <a class="reference external" href="blocktag">Block Tags</a>)</p>
<p class="last">default: <em>blockTag</em>= &#8220;latest&#8221;</p>
</dd>
<dt><sup>prototype</sup> . getLogs ( filter )</dt>
<dd>Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with an array (possibly empty) of the logs that
match the <em>filter</em>. (See <a class="reference external" href="filter">Filters</a>)</dd>
</dl>
<div class="section" id="id8">
<h3><em>Examples</em><a class="headerlink" href="#id8" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="nd">@TODO</span>
</pre></div>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="events">
<h2>Events<a class="headerlink" href="#events" title="Permalink to this headline"></a></h2>
<p>These methods allow management of callbacks on certain events on the blockchain
and contracts. They are largely based on the <a class="reference external" href="events">EventEmitter API</a>.</p>
<dl class="docutils">
<dt><sup>prototype</sup> . on ( eventType, callback )</dt>
<dd>Register a callback for any future <em>eventType</em>; see below for callback parameters</dd>
<dt><sup>prototype</sup> . once ( eventType, callback)</dt>
<dd>Register a callback for the next (and only next) <em>eventType</em>; see below for callback parameters</dd>
<dt><sup>prototype</sup> . removeListener ( eventType, callback )</dt>
<dd>Unregister the <em>callback</em> for <em>eventType</em>; if the same callback is registered
more than once, only the first registered instance is removed</dd>
<dt><sup>prototype</sup> . removeAllListeners ( eventType )</dt>
<dd>Unregister all callbacks for <em>eventType</em></dd>
<dt><sup>prototype</sup> . listenerCount ( [ eventType ] )</dt>
<dd>Return the number of callbacks registered for <em>eventType</em>, or if ommitted, the
total number of callbacks registered</dd>
</dl>
<div class="section" id="event-types">
<h3>Event Types<a class="headerlink" href="#event-types" title="Permalink to this headline"></a></h3>
<dl class="docutils">
<dt>&#8220;block&#8221;</dt>
<dd><p class="first">Whenever a new block is mined</p>
<p class="last"><code class="docutils literal"><span class="pre">callback(</span> <span class="pre">blockNumber</span> <span class="pre">)</span></code></p>
</dd>
<dt>any address</dt>
<dd><p class="first">When the balance of the coresposding address changes.</p>
<blockquote class="last">
<div><code class="docutils literal"><span class="pre">callback(</span> <span class="pre">balance</span> <span class="pre">)</span></code></div></blockquote>
</dd>
<dt>any transaction hash</dt>
<dd><p class="first">When the coresponding transaction is mined; also see
<a class="reference external" href="waitForTransaction">Waiting for Transactions</a></p>
<p class="last"><code class="docutils literal"><span class="pre">callback(</span> <span class="pre">transaction</span> <span class="pre">)</span></code></p>
</dd>
<dt>an array of topics</dt>
<dd><p class="first">When any of the topics are triggered in a block&#8217;s logs; when using the
<a class="reference internal" href="api-contract.html#api-contract"><span class="std std-ref">Contract API</span></a>, this is automatically handled;</p>
<p class="last"><code class="docutils literal"><span class="pre">callback(</span> <span class="pre">log</span> <span class="pre">)</span></code></p>
</dd>
</dl>
</div>
<div class="section" id="waitfortransaction">
<span id="id9"></span><h3>Waiting for Transactions<a class="headerlink" href="#waitfortransaction" title="Permalink to this headline"></a></h3>
<dl class="docutils">
<dt><sup>prototype</sup> . waitForTransaction ( transachtionHash [ , timeout ] )</dt>
<dd>Return a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> which returns the transaction once <em>transactionHash</em> is
mined, with an optional <em>timeout</em> (in milliseconds)</dd>
</dl>
</div>
<div class="section" id="id10">
<h3><em>Examples</em><a class="headerlink" href="#id10" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">Get</span> <span class="n">notified</span> <span class="n">on</span> <span class="n">every</span> <span class="n">new</span> <span class="n">block</span>
<span class="n">provider</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="s1">&#39;block&#39;</span><span class="p">,</span> <span class="n">function</span><span class="p">(</span><span class="n">blockNumber</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s1">&#39;New Block: &#39;</span> <span class="o">+</span> <span class="n">blockNumber</span><span class="p">);</span>
<span class="p">});</span>
<span class="o">//</span> <span class="n">Get</span> <span class="n">notified</span> <span class="n">on</span> <span class="n">account</span> <span class="n">balance</span> <span class="n">change</span>
<span class="n">provider</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="s1">&#39;0x46Fa84b9355dB0708b6A57cd6ac222950478Be1d&#39;</span><span class="p">,</span> <span class="n">function</span><span class="p">(</span><span class="n">blockNumber</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s1">&#39;New Block: &#39;</span> <span class="o">+</span> <span class="n">blockNumber</span><span class="p">);</span>
<span class="p">});</span>
<span class="o">//</span> <span class="n">Get</span> <span class="n">notified</span> <span class="n">when</span> <span class="n">a</span> <span class="n">transaction</span> <span class="ow">is</span> <span class="n">mined</span>
<span class="n">provider</span><span class="o">.</span><span class="n">once</span><span class="p">(</span><span class="n">transactionHash</span><span class="p">,</span> <span class="n">function</span><span class="p">(</span><span class="n">transction</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s1">&#39;Transaction Minded: &#39;</span> <span class="o">+</span> <span class="n">transaction</span><span class="o">.</span><span class="n">hash</span><span class="p">);</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">transaction</span><span class="p">);</span>
<span class="p">);</span>
<span class="o">//</span> <span class="n">OR</span> <span class="n">equivalently</span> <span class="n">the</span> <span class="n">waitForTransaction</span><span class="p">()</span> <span class="n">returns</span> <span class="n">a</span> <span class="n">Promise</span>
<span class="n">provider</span><span class="o">.</span><span class="n">waitForTransaction</span><span class="p">(</span><span class="n">transactionHash</span><span class="p">)</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">transaction</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s1">&#39;Transaction Minded: &#39;</span> <span class="o">+</span> <span class="n">transaction</span><span class="o">.</span><span class="n">hash</span><span class="p">);</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">transaction</span><span class="p">);</span>
<span class="p">});</span>
<span class="o">//</span> <span class="n">Get</span> <span class="n">notified</span> <span class="n">when</span> <span class="n">a</span> <span class="n">contract</span> <span class="n">event</span> <span class="ow">is</span> <span class="n">logged</span>
<span class="n">provider</span><span class="o">.</span><span class="n">on</span><span class="p">([</span> <span class="n">eventTopic</span> <span class="p">],</span> <span class="n">function</span><span class="p">(</span><span class="n">log</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s1">&#39;Event Log&#39;</span><span class="p">);</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">log</span><span class="p">);</span>
<span class="p">});</span>
</pre></div>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="objects">
<h2>Objects<a class="headerlink" href="#objects" title="Permalink to this headline"></a></h2>
<div class="section" id="block-tag">
<span id="blocktag"></span><h3>Block Tag<a class="headerlink" href="#block-tag" title="Permalink to this headline"></a></h3>
<p>A block tag is used to uniquely identify a block&#8217;s position in th blockchain:</p>
<dl class="docutils">
<dt>a Number or <a class="reference internal" href="api-utils.html#hexstring"><span class="std std-ref">hex string</span></a>:</dt>
<dd>Each block has a block number (eg. <code class="docutils literal"><span class="pre">42</span></code> or <code class="docutils literal"><span class="pre">&quot;0x2a</span></code>.</dd>
<dt>&#8220;latest&#8221;:</dt>
<dd>The most recently mined block.</dd>
<dt>&#8220;pending&#8221;:</dt>
<dd>The block that is currently being mined.</dd>
</dl>
</div>
<div class="section" id="blockresponse">
<span id="id11"></span><h3>Block Responses<a class="headerlink" href="#blockresponse" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="n">parentHash</span><span class="p">:</span> <span class="s2">&quot;0x3d8182d27303d92a2c9efd294a36dac878e1a9f7cb0964fa0f789fa96b5d0667&quot;</span><span class="p">,</span>
<span class="nb">hash</span><span class="p">:</span> <span class="s2">&quot;0x7f20ef60e9f91896b7ebb0962a18b8defb5e9074e62e1b6cde992648fe78794b&quot;</span><span class="p">,</span>
<span class="n">number</span><span class="p">:</span> <span class="mi">3346463</span><span class="p">,</span>
<span class="n">difficulty</span><span class="p">:</span> <span class="mi">183765779077962</span><span class="p">,</span>
<span class="n">timestamp</span><span class="p">:</span> <span class="mi">1489440489</span><span class="p">,</span>
<span class="n">nonce</span><span class="p">:</span> <span class="s2">&quot;0x17060cb000d2c714&quot;</span><span class="p">,</span>
<span class="n">extraData</span><span class="p">:</span> <span class="s2">&quot;0x65746865726d696e65202d20555331&quot;</span><span class="p">,</span>
<span class="n">gasLimit</span><span class="p">:</span> <span class="n">utils</span><span class="o">.</span><span class="n">bigNumberify</span><span class="p">(</span><span class="s2">&quot;3993225&quot;</span><span class="p">),</span>
<span class="n">gasUsed</span><span class="p">:</span> <span class="n">utils</span><span class="o">.</span><span class="n">bigNuberify</span><span class="p">(</span><span class="s2">&quot;3254236&quot;</span><span class="p">),</span>
<span class="n">miner</span><span class="p">:</span> <span class="s2">&quot;0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8&quot;</span><span class="p">,</span>
<span class="n">transactions</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">&quot;0x125d2b846de85c4c74eafb6f1b49fdb2326e22400ae223d96a8a0b26ccb2a513&quot;</span><span class="p">,</span>
<span class="s2">&quot;0x948d6e8f6f8a4d30c0bd527becbe24d15b1aba796f9a9a09a758b622145fd963&quot;</span><span class="p">,</span>
<span class="o">...</span> <span class="p">[</span> <span class="mi">49</span> <span class="n">more</span> <span class="n">transaction</span> <span class="n">hashes</span> <span class="p">]</span> <span class="o">...</span>
<span class="s2">&quot;0xbd141969b164ed70388f95d780864210e045e7db83e71f171ab851b2fba6b730&quot;</span>
<span class="p">]</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="transactionrequest">
<span id="id12"></span><h3>Transaction Requests<a class="headerlink" href="#transactionrequest" title="Permalink to this headline"></a></h3>
<p>Any property which accepts a number may also be specified as a <a class="reference internal" href="api-utils.html#bignumber"><span class="std std-ref">BigNumber</span></a>
or <a class="reference internal" href="api-utils.html#hexstring"><span class="std std-ref">hex string</span></a>.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">Example</span><span class="p">:</span>
<span class="p">{</span>
<span class="o">//</span> <span class="n">Required</span> <span class="n">unless</span> <span class="n">deploying</span> <span class="n">a</span> <span class="n">contract</span> <span class="p">(</span><span class="ow">in</span> <span class="n">which</span> <span class="n">case</span> <span class="n">omit</span><span class="p">)</span>
<span class="n">to</span><span class="p">:</span> <span class="n">addressOrName</span><span class="p">,</span> <span class="o">//</span> <span class="n">the</span> <span class="n">target</span> <span class="n">address</span> <span class="ow">or</span> <span class="n">ENS</span> <span class="n">name</span>
<span class="o">//</span> <span class="n">These</span> <span class="n">are</span> <span class="n">optional</span><span class="o">/</span><span class="n">meaningless</span> <span class="k">for</span> <span class="n">call</span> <span class="ow">and</span> <span class="n">estimateGas</span>
<span class="n">nonce</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="o">//</span> <span class="n">the</span> <span class="n">transaction</span> <span class="n">nonce</span>
<span class="n">gasLimit</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="o">//</span> <span class="n">the</span> <span class="n">maximum</span> <span class="n">gas</span> <span class="n">this</span> <span class="n">transaction</span> <span class="n">may</span> <span class="n">spend</span>
<span class="n">gasPrice</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="o">//</span> <span class="n">the</span> <span class="n">price</span> <span class="p">(</span><span class="ow">in</span> <span class="n">wei</span><span class="p">)</span> <span class="n">per</span> <span class="n">unit</span> <span class="n">of</span> <span class="n">gas</span>
<span class="o">//</span> <span class="n">These</span> <span class="n">are</span> <span class="n">always</span> <span class="n">optional</span> <span class="p">(</span><span class="n">but</span> <span class="k">for</span> <span class="n">call</span><span class="p">,</span> <span class="n">data</span> <span class="ow">is</span> <span class="n">usually</span> <span class="n">specified</span><span class="p">)</span>
<span class="n">data</span><span class="p">:</span> <span class="s2">&quot;0x&quot;</span><span class="p">,</span> <span class="o">//</span> <span class="n">extra</span> <span class="n">data</span> <span class="k">for</span> <span class="n">the</span> <span class="n">transaction</span><span class="p">,</span> <span class="ow">or</span> <span class="nb">input</span> <span class="k">for</span> <span class="n">call</span>
<span class="n">value</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="o">//</span> <span class="n">the</span> <span class="n">amount</span> <span class="p">(</span><span class="ow">in</span> <span class="n">wei</span><span class="p">)</span> <span class="n">this</span> <span class="n">transaction</span> <span class="ow">is</span> <span class="n">sending</span>
<span class="n">chainId</span><span class="p">:</span> <span class="mi">3</span> <span class="o">//</span> <span class="n">the</span> <span class="n">network</span> <span class="n">ID</span><span class="p">;</span> <span class="n">usually</span> <span class="n">added</span> <span class="n">by</span> <span class="n">a</span> <span class="n">signer</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="transactionresult">
<span id="id13"></span><h3>Transaction Results<a class="headerlink" href="#transactionresult" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">Example</span><span class="p">:</span>
<span class="p">{</span>
<span class="o">//</span> <span class="n">Only</span> <span class="n">available</span> <span class="k">for</span> <span class="n">mined</span> <span class="n">transactions</span>
<span class="n">blockHash</span><span class="p">:</span> <span class="s2">&quot;0x7f20ef60e9f91896b7ebb0962a18b8defb5e9074e62e1b6cde992648fe78794b&quot;</span><span class="p">,</span>
<span class="n">blockNumber</span><span class="p">:</span> <span class="mi">3346463</span><span class="p">,</span>
<span class="n">transactionIndex</span><span class="p">:</span> <span class="mi">51</span><span class="p">,</span>
<span class="o">//</span> <span class="n">Exactly</span> <span class="n">one</span> <span class="n">of</span> <span class="n">these</span> <span class="n">will</span> <span class="n">be</span> <span class="n">present</span> <span class="p">(</span><span class="n">send</span> <span class="n">vs</span><span class="o">.</span> <span class="n">deploy</span> <span class="n">contract</span><span class="p">)</span>
<span class="n">creates</span><span class="p">:</span> <span class="n">null</span><span class="p">,</span>
<span class="n">to</span><span class="p">:</span> <span class="s2">&quot;0xc149Be1bcDFa69a94384b46A1F91350E5f81c1AB&quot;</span><span class="p">,</span>
<span class="o">//</span> <span class="n">The</span> <span class="n">transaction</span> <span class="nb">hash</span>
<span class="nb">hash</span><span class="p">:</span> <span class="s2">&quot;0xf517872f3c466c2e1520e35ad943d833fdca5a6739cfea9e686c4c1b3ab1022e&quot;</span><span class="p">,</span>
<span class="o">//</span> <span class="n">See</span> <span class="n">above</span> <span class="p">(</span><span class="n">Transaction</span> <span class="n">Requests</span><span class="p">)</span> <span class="k">for</span> <span class="n">these</span> <span class="n">explained</span>
<span class="n">data</span><span class="p">:</span> <span class="s2">&quot;0x&quot;</span><span class="p">,</span>
<span class="n">from</span><span class="p">:</span> <span class="s2">&quot;0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8&quot;</span><span class="p">,</span>
<span class="n">gasLimit</span><span class="p">:</span> <span class="n">utils</span><span class="o">.</span><span class="n">bigNumberify</span><span class="p">(</span><span class="s2">&quot;90000&quot;</span><span class="p">),</span>
<span class="n">gasPrice</span><span class="p">:</span> <span class="n">utils</span><span class="o">.</span><span class="n">bigNumberify</span><span class="p">(</span><span class="s2">&quot;21488430592&quot;</span><span class="p">),</span>
<span class="n">nonce</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="n">value</span><span class="p">:</span> <span class="n">utils</span><span class="o">.</span><span class="n">parseEther</span><span class="p">(</span><span class="mf">1.0017071732629267</span><span class="p">),</span>
<span class="o">//</span> <span class="n">The</span> <span class="n">network</span> <span class="n">ID</span> <span class="p">(</span><span class="ow">or</span> <span class="n">chain</span> <span class="n">ID</span><span class="p">);</span> <span class="mi">0</span> <span class="n">indicates</span> <span class="n">replay</span><span class="o">-</span><span class="n">attack</span> <span class="n">vulnerable</span>
<span class="o">//</span> <span class="p">(</span><span class="n">eg</span><span class="o">.</span> <span class="mi">1</span> <span class="o">=</span> <span class="n">Homestead</span> <span class="n">mainnet</span><span class="p">,</span> <span class="mi">3</span> <span class="o">=</span> <span class="n">Ropsten</span> <span class="n">testnet</span><span class="p">)</span>
<span class="n">networkId</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="o">//</span> <span class="n">The</span> <span class="n">signature</span> <span class="n">of</span> <span class="n">the</span> <span class="n">transaction</span>
<span class="n">r</span><span class="p">:</span> <span class="s2">&quot;0x5b13ef45ce3faf69d1f40f9d15b0070cc9e2c92f3df79ad46d5b3226d7f3d1e8&quot;</span><span class="p">,</span>
<span class="n">s</span><span class="p">:</span> <span class="s2">&quot;0x535236e497c59e3fba93b78e124305c7c9b20db0f8531b015066725e4bb31de6&quot;</span><span class="p">,</span>
<span class="n">v</span><span class="p">:</span> <span class="mi">37</span><span class="p">,</span>
<span class="o">//</span> <span class="n">The</span> <span class="n">raw</span> <span class="n">transaction</span>
<span class="n">raw</span><span class="p">:</span> <span class="s2">&quot;0xf87083154262850500cf6e0083015f9094c149be1bcdfa69a94384b46a1f913&quot;</span> <span class="o">+</span>
<span class="s2">&quot;50e5f81c1ab880de6c75de74c236c8025a05b13ef45ce3faf69d1f40f9d15b0&quot;</span> <span class="o">+</span>
<span class="s2">&quot;070cc9e2c92f3df79ad46d5b3226d7f3d1e8a0535236e497c59e3fba93b78e1&quot;</span> <span class="o">+</span>
<span class="s2">&quot;24305c7c9b20db0f8531b015066725e4bb31de6&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="transactionreceipt">
<span id="id14"></span><h3>Transaction Receipts<a class="headerlink" href="#transactionreceipt" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">Example</span>
<span class="p">{</span>
<span class="n">transactionHash</span><span class="p">:</span> <span class="s2">&quot;0x7dec07531aae8178e9d0b0abbd317ac3bb6e8e0fd37c2733b4e0d382ba34c5d2&quot;</span><span class="p">,</span>
<span class="o">//</span> <span class="n">The</span> <span class="n">block</span> <span class="n">this</span> <span class="n">transaction</span> <span class="n">was</span> <span class="n">mined</span> <span class="n">into</span>
<span class="n">blockHash</span><span class="p">:</span> <span class="s2">&quot;0xca1d4d9c4ac0b903a64cf3ae3be55cc31f25f81bf29933dd23c13e51c3711840&quot;</span><span class="p">,</span>
<span class="n">blockNumber</span><span class="p">:</span> <span class="mi">3346629</span><span class="p">,</span>
<span class="o">//</span> <span class="n">The</span> <span class="n">index</span> <span class="n">into</span> <span class="n">this</span> <span class="n">block</span> <span class="n">of</span> <span class="n">the</span> <span class="n">transaction</span>
<span class="n">transactionIndex</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="o">//</span> <span class="n">The</span> <span class="n">address</span> <span class="n">of</span> <span class="n">the</span> <span class="n">contract</span> <span class="p">(</span><span class="k">if</span> <span class="n">one</span> <span class="n">was</span> <span class="n">created</span><span class="p">)</span>
<span class="n">contractAddress</span><span class="p">:</span> <span class="n">null</span><span class="p">,</span>
<span class="o">//</span> <span class="n">Gas</span>
<span class="n">cumulativeGasUsed</span><span class="p">:</span> <span class="n">utils</span><span class="o">.</span><span class="n">bigNumberify</span><span class="p">(</span><span class="s2">&quot;42000&quot;</span><span class="p">),</span>
<span class="n">gasUsed</span><span class="p">:</span> <span class="n">utils</span><span class="o">.</span><span class="n">bigNumberify</span><span class="p">(</span><span class="s2">&quot;21000&quot;</span><span class="p">),</span>
<span class="o">//</span> <span class="n">Logs</span>
<span class="n">log</span><span class="p">:</span> <span class="p">[</span> <span class="p">],</span>
<span class="n">logsBloom</span><span class="p">:</span> <span class="s2">&quot;0x00&quot;</span> <span class="o">...</span> <span class="p">[</span> <span class="mi">256</span> <span class="nb">bytes</span> <span class="n">of</span> <span class="mi">0</span> <span class="p">]</span> <span class="o">...</span> <span class="s2">&quot;00&quot;</span><span class="p">,</span>
<span class="o">//</span> <span class="n">State</span> <span class="n">root</span>
<span class="n">root</span><span class="p">:</span> <span class="s2">&quot;0x8a27e1f7d3e92ae1a01db5cce3e4718e04954a34e9b17c1942011a5f3a942bf4&quot;</span><span class="p">,</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="filter">
<span id="id15"></span><h3>Filters<a class="headerlink" href="#filter" title="Permalink to this headline"></a></h3>
<p>Filtering on topics supports a <a class="reference external" href="api-topics">somewhat complicated</a> specification, however,
for the vast majority of filters, a single topic is usually sufficient (see the example below).</p>
<p>The <em>EtherscanProvider</em> only supports a single topic.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">Example</span>
<span class="p">{</span>
<span class="o">//</span> <span class="n">Optional</span><span class="p">;</span> <span class="n">The</span> <span class="nb">range</span> <span class="n">of</span> <span class="n">blocks</span> <span class="n">to</span> <span class="n">limit</span> <span class="n">querying</span> <span class="p">(</span><span class="n">See</span><span class="p">:</span> <span class="n">Block</span> <span class="n">Tags</span> <span class="n">above</span><span class="p">)</span>
<span class="n">fromBlock</span><span class="p">:</span> <span class="s2">&quot;latest&quot;</span><span class="p">,</span>
<span class="n">toBlock</span><span class="p">:</span> <span class="s2">&quot;latest&quot;</span><span class="p">,</span>
<span class="o">//</span> <span class="n">Optional</span><span class="p">;</span> <span class="n">An</span> <span class="n">address</span> <span class="p">(</span><span class="ow">or</span> <span class="n">ENS</span> <span class="n">name</span><span class="p">)</span> <span class="n">to</span> <span class="nb">filter</span> <span class="n">by</span>
<span class="n">address</span><span class="p">:</span> <span class="n">addressOrName</span><span class="p">,</span>
<span class="o">//</span> <span class="n">Optional</span><span class="p">;</span> <span class="n">A</span> <span class="p">(</span><span class="n">possibly</span> <span class="n">nested</span><span class="p">)</span> <span class="nb">list</span> <span class="n">of</span> <span class="n">topics</span>
<span class="n">topics</span><span class="p">:</span> <span class="p">[</span> <span class="n">topic1</span> <span class="p">]</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="provider-specific-extra-api-calls">
<h2>Provider Specific Extra API Calls<a class="headerlink" href="#provider-specific-extra-api-calls" title="Permalink to this headline"></a></h2>
<dl class="docutils">
<dt><sup>EtherscanProvider</sup> . getEtherPrice()</dt>
<dd>Returns a <a class="reference internal" href="notes.html#promise"><span class="std std-ref">Promise</span></a> with the price of ether in USD.</dd>
</dl>
<div class="section" id="id16">
<h3><em>Examples</em><a class="headerlink" href="#id16" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">provider</span><span class="o">.</span><span class="n">EtherscanProvider</span><span class="o">.</span><span class="n">getEtherPrice</span><span class="p">()</span><span class="o">.</span><span class="n">then</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">price</span><span class="p">)</span> <span class="p">{</span>
<span class="n">console</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s2">&quot;Ether price in USD: &quot;</span> <span class="o">+</span> <span class="n">price</span><span class="p">);</span>
<span class="p">});</span>
</pre></div>
</div>
<hr class="docutils" />
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="api-contract.html" class="btn btn-neutral float-right" title="Contracts" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="api-wallet.html" class="btn btn-neutral" title="Wallets" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016, Richard Moore &lt;me@ricmoo.com&gt;.
</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:'2.1.0',
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>