<divclass="link title"><ahref="/v5/">Documentation</a></div><divclass="base show link depth-1"><ahref="/v5/getting-started/">Getting Started</a></div><divclass="base show link depth-1"><ahref="/v5/concepts/">Ethereum Basics</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/events/">Events</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/gas/">Gas</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/security/">Security</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/best-practices/">Best Practices</a></div><divclass="base show link depth-1"><ahref="/v5/api-keys/">Provider API Keys</a></div><divclass="base ancestor show link depth-1"><ahref="/v5/api/">Application Programming Interface</a></div><divclass="ancestor show link depth-2"><ahref="/v5/api/providers/">Providers</a></div><divclass="show link depth-3"><ahref="/v5/api/providers/provider/">Provider</a></div><divclass="myself ancestor ancestor show link depth-3"><ahref="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><divclass="link show child depth-4"><ahref="#JsonRpcSigner">JsonRpcSigner</a></div><divclass="link show child depth-4"><ahref="#UncheckedJsonRpcSigner">JsonRpcUncheckedSigner</a></div><divclass="link show child depth-4"><ahref="#JsonRpcProvider--other">Node-Specific Methods</a></div><divclass="show link depth-3"><ahref="/v5/api/providers/api-providers/">API Providers</a></div><divclass="show link depth-3"><ahref="/v5/api/providers/other/">Other Providers</a></div><divclass="show link depth-3"><ahref="/v5/api/providers/types/">Types</a></div><divclass="show link depth-2"><ahref="/v5/api/signer/">Signers</a></div><divclass="show link depth-2"><ahref="/v5/api/contract/">Contract Interaction</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/contract/">Contract</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/contract-factory/">ContractFactory</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/example/">Example: ERC-20 Contract</a></div><divclass="show link depth-2"><ahref="/v5/api/utils/">Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/abi/">Application Binary Interface</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/coder/">AbiCoder</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/formats/">ABI Formats</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/fragments/">Fragments</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/interface/">Interface</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/address/">Addresses</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/bignumber/">BigNumber</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/bytes/">Byte Manipulation</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/constants/">Constants</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/display-logic/">Display Logic and Input</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/encoding/">Encoding Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/hashing/">Hashing Algorithms</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/hdnode/">HD Wallet</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/logger/">Logging</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/properties/">Property Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/signing-key/">Signing Key</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/strings/">Strings</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/transactions/">Transactions</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/web/">Web Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/wordlists/">Wordlists</a></div><divclass="show link depth-2"><ahref="/v5/api/other/">Other Libraries</a></div><divc
<aname="JsonRpcProvider"></a><aname="JsonRpcProvider"></a><h1class="show-anchors"><div>JsonRpcProvider<spanclass="inherits"> inherits <ahref="/v5/api/providers/provider/">Provider</a></span><divclass="anchors"><aclass="self"href="/v5/api/providers/jsonrpc-provider/#JsonRpcProvider"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L270">source</a></div></div></h1><p>The <ahref="https://github.com/ethereum/wiki/wiki/JSON-RPC">JSON-RPC API</a> is a popular method for interacting with Ethereum and is available in all major Ethereum node implementations (e.g. <ahref="https://geth.ethereum.org">Geth</a> and <ahref="https://www.parity.io">Parity</a>) as well as many third-party web services (e.g. <ahref="https://infura.io">INFURA</a>)</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="modifier">new </span><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">providers</span><spanclass="symbol">.</span><spanclass="method">JsonRpcProvider</span><spanclass="symbol">(</span><spanclass="symbol">[</span><spanclass="param">urlOrConnectionInfo</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">networkish</span><spanclass="symbol">]</span><spanclass="symbol">]</span><spanclass="symbol">)</span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L276">source</a></div></div><divclass="body"><p>Connect to a JSON-RPC HTTP API using the URL or <ahref="/v5/api/utils/web/#ConnectionInfo">ConnectionInfo</a><i>urlOrConnectionInfo</i> connected to the <i>networkish</i> network.</p>
<p>If <i>urlOrConnectionInfo</i> is not specified, the default (i.e. <codeclass="inline">http://localhost:8545</code>) is used and if no network is specified, it will be determined automatically by querying the node using <codeclass="inline">eth_chaindId</code> and falling back on <codeclass="inline">eth_networkId</code>.</p>
</div></div><divclass="definition container-box note"><divclass="term">Note: Connecting to a Local Node</div><divclass="body"><p>Each node implementation is slightly different and may require specific command-line flags, configuration or settings in their UI to enable JSON-RPC, unlock accounts or expose specific APIs. Please consult their documentation.</p>
</div></div><aname="JsonRpcProvider-getSigner"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">jsonRpcProvider</span><spanclass="symbol">.</span><spanclass="method">getSigner</span><spanclass="symbol">(</span><spanclass="symbol">[</span><spanclass="param">addressOrIndex</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/providers/jsonrpc-provider/#JsonRpcSigner">JsonRpcSigner</a></span><divclass="anchors"><aclass="self"href="/v5/api/providers/jsonrpc-provider/#JsonRpcProvider-getSigner"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L344">source</a></div></div><divclass="body"><p>Returns a <ahref="/v5/api/providers/jsonrpc-provider/#JsonRpcSigner">JsonRpcSigner</a> which is managed by this Ethereum node, at <i>addressOrIndex</i>. If no <i>addressOrIndex</i> is provided, the first account (account #0) is used.</p>
</div></div><aname="JsonRpcProvider-listAccounts"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">jsonRpcProvider</span><spanclass="symbol">.</span><spanclass="method">listAccounts</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Array< string ></span><divclass="anchors"><aclass="self"href="/v5/api/providers/jsonrpc-provider/#JsonRpcProvider-listAccounts"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L352">source</a></div></div><divclass="body"><p>Returns a list of all account addresses managed by this provider.</p>
</div></div><aname="JsonRpcProvider-send"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">jsonRpcProvider</span><spanclass="symbol">.</span><spanclass="method">send</span><spanclass="symbol">(</span><spanclass="param">method</span><spanclass="symbol">,</span><spanclass="param">params</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< any ></span><divclass="anchors"><aclass="self"href="/v5/api/providers/jsonrpc-provider/#JsonRpcProvider-send"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L358">source</a></div></div><divclass="body"><p>Allows sending raw messages to the provider.</p>
</div></div><aname="JsonRpcSigner"></a><aname="JsonRpcProvider--JsonRpcSigner"></a><h2class="show-anchors"><div>JsonRpcSigner<spanclass="inherits"> inherits <ahref="/v5/api/signer/#Signer">Signer</a></span><divclass="anchors"><aclass="self"href="/v5/api/providers/jsonrpc-provider/#JsonRpcSigner"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L101">source</a></div></div></h2><p>A <b>JsonRpcSigner</b> is a simple Signer which is backed by a connected <ahref="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a>.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">provider</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></span><divclass="anchors"></div></div><divclass="body"><p>The provider this signer was established from.</p>
</div></div><aname="JsonRpcSigner-connectUnchecked"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">connectUnchecked</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/providers/jsonrpc-provider/#UncheckedJsonRpcSigner">JsonRpcUncheckedSigner</a></span><divclass="anchors"><aclass="self"href="/v5/api/providers/jsonrpc-provider/#JsonRpcSigner-connectUnchecked"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L138">source</a></div></div><divclass="body"><p>Returns a new Signer object which does not perform additional checks when sending a transaction. See <ahref="/v5/api/providers/jsonrpc-provider/#JsonRpcProvider-getUncheckedSigner">getUncheckedSigner</a> for more details.</p>
</div></div><aname="JsonRpcSigner-sendUncheckedTransaction"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">sendUncheckedTransaction</span><spanclass="symbol">(</span><spanclass="param">transaction</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>< 32 >>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/jsonrpc-provider/#JsonRpcSigner-sendUncheckedTransaction"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L157">source</a></div></div><divclass="body"><p>Sends the <i>transaction</i> and returns a Promise which resolves to the opaque transaction hash.</p>
</div></div><aname="JsonRpcSigner-unlock"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">unlock</span><spanclass="symbol">(</span><spanclass="param">password</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< boolean ></span><divclass="anchors"><aclass="self"href="/v5/api/providers/jsonrpc-provider/#JsonRpcSigner-unlock"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L238">source</a></div></div><divclass="body"><p>Request the node unlock the account (if locked) using <i>password</i>.</p>
</div></div><aname="UncheckedJsonRpcSigner"></a><aname="JsonRpcProvider--UncheckedJsonRpcSigner"></a><h2class="show-anchors"><div>JsonRpcUncheckedSigner<spanclass="inherits"> inherits <ahref="/v5/api/signer/#Signer">Signer</a></span><divclass="anchors"><aclass="self"href="/v5/api/providers/jsonrpc-provider/#UncheckedJsonRpcSigner"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L247">source</a></div></div></h2><p>The JSON-RPC API only provides a transaction hash as the response when a transaction is sent, but the ethers Provider requires populating all details of a transaction before returning it. For example, the gas price and gas limit may be adjusted by the node or the nonce automatically included, in which case the opaque transaction hash has discarded this.</p>
<p>To remedy this, the <ahref="/v5/api/providers/jsonrpc-provider/#JsonRpcSigner">JsonRpcSigner</a> immediately queries the provider for the details using the returned transaction hash to populate the <ahref="/v5/api/providers/types/#providers-TransactionResponse">TransactionResponse</a> object.</p>
<p>Some backends do not respond immediately and instead defer releasing the details of a transaction it was responsible for signing until it is mined.</p>
<p>The <b>UncheckedSigner</b> does not populate any additional information and will immediately return the result as a mock <ahref="/v5/api/providers/types/#providers-TransactionResponse">TransactionResponse</a>-like object, with most of the properties set to null, but allows access to the transaction hash quickly, if that is all that is required.</p>
<aname="JsonRpcProvider--other"></a><aname="JsonRpcProvider--JsonRpcProvider--other"></a><h2class="show-anchors"><div>Node-Specific Methods<divclass="anchors"><aclass="self"href="/v5/api/providers/jsonrpc-provider/#JsonRpcProvider--other"></a></div></div></h2><p>Many methods are less common or specific to certain Ethereum Node implementations (e.g. <ahref="https://www.parity.io">Parity</a> vs <ahref="https://geth.ethereum.org">Geth</a>. These include account and admin management, debugging, deeper block and transaction exploration and other services (such as Swarm and Whisper).</p>
<p>The <ahref="/v5/api/providers/jsonrpc-provider/#JsonRpcProvider-send">jsonRpcProvider.send</a> method can be used to access these.</p>
<p><ul><li><ahref="https://github.com/ethereum/wiki/wiki/JSON-RPC">All JSON-RPC methods</a> (including the less common methods) which most Ethereum Nodes support. </li><li><ahref="https://openethereum.github.io/wiki/JSONRPC-trace-module">Parity's Trace Module</a> can be used to trace and debug EVM execution of a transaction (requires custom configuration) </li><li><ahref="https://github.com/ethereum/go-ethereum/wiki/Management-APIs#debug">Geth's Debug Module</a> can be used to debug transactions and internal cache state, etc. </li><li><ahref="https://github.com/ethereum/go-ethereum/wiki/Management-APIs">Additional Geth Methods</a></li><li><ahref="https://openethereum.github.io/wiki/JSONRPC">Additional Parity Methods</a></li></ul></p>
<divclass="copyright">The content of this site is licensed under the <ahref="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on February 8, 2021, 3:25pm.</div>