55 lines
15 KiB
HTML
55 lines
15 KiB
HTML
<!DOCTYPE html>
|
|
<html class="paged">
|
|
<head>
|
|
<title>Providers</title>
|
|
<link rel="stylesheet" type="text/css" href="/v5/static/style.css">
|
|
</head>
|
|
<body>
|
|
<div class="sidebar">
|
|
<div class="header">
|
|
<div class="logo"><a href="/v5/"><div class="image"></div><div class="name">ethers</div><div class="version">v5.0-beta</div></a></div>
|
|
</div>
|
|
<div class="toc"><div>
|
|
<div class="link title"><a href="/">Documentation</a></div><div class="base show link depth-1"><a href="/v5/getting-started/">Getting Started</a></div><div class="base show link depth-1"><a href="/v5/concepts/">Ethereum Basics</a></div><div class="hide link depth-2"><a href="/v5/concepts/events/">Events</a></div><div class="hide link depth-2"><a href="/v5/concepts/gas/">Gas</a></div><div class="hide link depth-2"><a href="/v5/concepts/security/">Security</a></div><div class="base ancestor show link depth-1"><a href="/v5/api/">Application Programming Interface</a></div><div class="show link depth-2"><a href="/v5/api/contract/">Contract Interaction</a></div><div class="hide link depth-3"><a href="/v5/api/contract/contract/">Contract</a></div><div class="hide link depth-3"><a href="/v5/api/contract/contract-factory/">ContractFactory</a></div><div class="hide link depth-3"><a href="/v5/api/contract/example/">Example: ERC-20 Contract</a></div><div class="show link depth-2"><a href="/v5/api/signer/">Signers</a></div><div class="myself ancestor ancestor show link depth-2"><a href="/v5/api/providers/">Providers</a></div><div class="child show link depth-3"><a href="/v5/api/providers/provider/">Provider</a></div><div class="child show link depth-3"><a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><div class="child show link depth-3"><a href="/v5/api/providers/api-providers/">API Providers</a></div><div class="child show link depth-3"><a href="/v5/api/providers/other/">Other Providers</a></div><div class="child show link depth-3"><a href="/v5/api/providers/types/">Types</a></div><div class="show link depth-2"><a href="/v5/api/utils/">Utilities</a></div><div class="hide link depth-3"><a href="/v5/api/utils/abi/">Application Binary Interface</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/interface/">Interface</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/fragments/">Fragments</a></div><div class="hide link depth-3"><a href="/v5/api/utils/address/">Addresses</a></div><div class="hide link depth-3"><a href="/v5/api/utils/bignumber/">BigNumber</a></div><div class="hide link depth-3"><a href="/v5/api/utils/bytes/">Byte Manipulation</a></div><div class="hide link depth-3"><a href="/v5/api/utils/constants/">Constants</a></div><div class="hide link depth-3"><a href="/v5/api/utils/display-logic/">Display Logic and Input</a></div><div class="hide link depth-3"><a href="/v5/api/utils/encoding/">Encoding Utilities</a></div><div class="hide link depth-3"><a href="/v5/api/utils/fixednumber/">FixedNumber</a></div><div class="hide link depth-3"><a href="/v5/api/utils/hashing/">Hashing Algorithms</a></div><div class="hide link depth-3"><a href="/v5/api/utils/hdnode/">HD Wallet</a></div><div class="hide link depth-3"><a href="/v5/api/utils/logger/">Logging</a></div><div class="hide link depth-3"><a href="/v5/api/utils/properties/">Property Utilities</a></div><div class="hide link depth-3"><a href="/v5/api/utils/signing-key/">Signing Key</a></div><div class="hide link depth-3"><a href="/v5/api/utils/strings/">Strings</a></div><div class="hide link depth-3"><a href="/v5/api/utils/transactions/">Transactions</a></div><div class="hide link depth-3"><a href="/v5/api/utils/web/">Web Utilities</a></div><div class="hide link depth-3"><a href="/v5/api/utils/wordlists/">Wordlists</a></div><div class="show link depth-2"><a href="/v5/api/other/">Other Libraries</a></div><div class="hide link depth-3"><a href="/v5/api/other/assembly/">Assembly</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/api/">Utilities</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/ast/">Abstract Syntax Tree</a></div><div class="hide link depth-3"><a href="/v5/api/other/hardware/">Hardware Wallets</a></div><div class="show link depth-2"><a href="/v5/api/experimental/">Experimental</a></div><div class="base show link depth-1"><a href="/v5/cli/">Command Line Interfaces</a></div><div class="hide link depth-2"><a href="/v5/cli/ethers/">Sandbox Utility</a></div><div class="hide link depth-2"><a href="/v5/cli/asm/">Assembler</a></div><div class="hide link depth-2"><a href="/v5/cli/ens/">Ethereum Naming Service</a></div><div class="hide link depth-2"><a href="/v5/cli/typescript/">TypeScript</a></div><div class="hide link depth-2"><a href="/v5/cli/plugin/">Making Your Own</a></div><div class="base show link depth-1"><a href="/v5/cookbook/">Cookbook</a></div><div class="base show link depth-1"><a href="/v5/migration/">Migration Guide</a></div><div class="hide link depth-2"><a href="/v5/migration/web3/">Migration: From Web3.js</a></div><div class="hide link depth-2"><a href="/v5/migration/ethers-v4/">Migration: From Ethers v4</a></div><div class="base show link depth-1"><a href="/v5/testing/">Testing</a></div><div class="base show link depth-1"><a href="/v5/contributing/">Contributing and Hacking</a></div><div class="base show link depth-1"><a href="/v5/documentation/">Flatworm Docs</a></div><div class="base show link depth-1"><a href="/v5/license/">License and Copyright</a></div>
|
|
</div></div>
|
|
</div>
|
|
<div class="content">
|
|
<div class="breadcrumbs"><a href="/v5/">Documentation</a> » <a href="/v5/api/">API</a> » <span class="current">Providers</span></div>
|
|
|
|
<a name="providers"></a><a name="providers"></a><h1 class="show-anchors"><div>Providers<div class="anchors"><a class="self" href="/v5/api/providers/#providers"></a></div></div></h1><p>A <b>Provider</b> is an abstraction of a connection to the Ethereum network, providing a concise, consistent interface to standard Ethereum node functionality.</p>
|
|
|
|
<p>The ethers.js library provides several options which should cover the vast majority of use-cases, but also includes the necessary functions and classes for sub-classing if a more custom configuration is necessary.</p>
|
|
|
|
<p>Most users should be able to simply use the <a href="/v5/api/providers/#providers-getDefaultProvider">Default Provider</a>.</p>
|
|
|
|
<a name="providers-getDefaultProvider"></a><a name="providers--providers-getDefaultProvider"></a><h2 class="show-anchors"><div>Default Provider<div class="anchors"><a class="self" href="/v5/api/providers/#providers-getDefaultProvider"></a></div></div></h2><p>The default provider is the safest, easiest way to begin developing on <i>Ethereum</i>, and it is also robust enough for use in production.</p>
|
|
|
|
<p>It creates a <a href="/v5/api/providers/other/#FallbackProvider">FallbackProvider</a> connected to as many backend services as possible. When a request is made, it is sent to multiple backends simulatenously. As responses from each backend are returned, they are checked that they agree. Once a quorum has been reached (i.e. enough of the backends agree), the response is provided to your application.</p>
|
|
|
|
<p>This ensures that if a backend has become out-of-sync, or if it has been compromised that its responses are dropped in favor of responses that match the majority.</p>
|
|
|
|
<div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="method">getDefaultProvider</span><span class="symbol">(</span> <span class="symbol">[</span> <span class="param">network</span> <span class="symbol">,</span> <span class="symbol">[</span> <span class="param">options</span> <span class="symbol">]</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns"><a href="/v5/api/providers/provider/">Provider</a></span><div class="anchors"></div></div><div class="body"><p>Returns a new Provider, backed by multiple services, connected to <i>network</i>. Is no <i>network</i> is provided, <b>homestead</b> (i.e. mainnet) is used.</p>
|
|
|
|
<p>The <i>options</i> is an object, with the following properties:</p>
|
|
|
|
</div></div><table class="table minimal"><tr><td align="center"><b>Property</b></td><td align="center"><b>Description</b></td><td class="fix"> </td></tr><tr><td align="center"><i>alchemy</i></td><td align="left"><a href="https://alchemyapi.io">Alchemy</a> API Token</td><td class="fix"> </td></tr><tr><td align="center"><i>etherscan</i></td><td align="left"><a href="https://etherscan.io">Etherscan</a> API Token</td><td class="fix"> </td></tr><tr><td align="center"><i>infura</i></td><td align="left"><a href="https://infura.io">INFURA</a> Project ID or ProjectID and Project Secret</td><td class="fix"> </td></tr><tr><td align="center"><i>quorum</i></td><td align="left">The number of backends that must agree <i>(default: 2 for mainnet, 1 for testnets)</i></td><td class="fix"> </td></tr><tr><td class="table-title" colspan="2">Option Properties</td><td class="fix"> </td></tr></table><div class="definition container-box note"><div class="term">Note: API Keys</div><div class="body"><p>It is highly recommended for production services that to acquire and specify an API Key for each sercice.</p>
|
|
|
|
<p>The deafult API Keys used by ethers are shared across all users, so services may throttle all services that are using the default API Keys during periods of load without realizing it.</p>
|
|
|
|
<p>Many services also have monitoring and usage metrics, which are only available if an API Key is specifie. This allows tracking how many requests are being sent and which methods are being used the most.</p>
|
|
|
|
<p>Some services also provide additional paid features, whichare only available when specifying an API Key.</p>
|
|
|
|
</div></div><a name="providers--provider-documentation"></a><h2 class="show-anchors"><div>Provider Documentation<div class="anchors"><a class="self" href="/v5/api/providers/#providers--provider-documentation"></a></div></div></h2>
|
|
<div class="toc"><div style="padding-left: 0px"><span class="bullet">•</span><a href="/v5/api/providers/provider/">Provider</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/provider/#Provider--account-methods">Accounts Methods</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/provider/#Provider--block-methods">Blocks Methods</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/provider/#Provider--ethereum-naming-service-ens-methods">Ethereum Naming Service (ENS) Methods</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/provider/#Provider--log-methods">Logs Methods</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/provider/#Provider--network-methods">Network Status Methods</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/provider/#Provider--transaction-methods">Transactions Methods</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/provider/#Provider--event-methods">Event Emitter Methods</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/provider/#Provider--inspection-methods">Inspection Methods</a></div><div style="padding-left: 0px"><span class="bullet">•</span><a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/jsonrpc-provider/#JsonRpcSigner">JsonRpcSigner</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/jsonrpc-provider/#UncheckedJsonRpcSigner">JsonRpcUncheckedSigner</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/jsonrpc-provider/#JsonRpcProvider--other">Node-Specific Methods</a></div><div style="padding-left: 0px"><span class="bullet">•</span><a href="/v5/api/providers/api-providers/">API Providers</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/api-providers/#EtherscanProvider">EtherscanProvider</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/api-providers/#api-providers--infuraprovider">InfuraProvider</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/api-providers/#api-providers--alchemyprovider">AlchemyProvider</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/api-providers/#api-providers--cloudflareprovider">CloudflareProvider</a></div><div style="padding-left: 0px"><span class="bullet">•</span><a href="/v5/api/providers/other/">Other Providers</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/other/#FallbackProvider">FallbackProvider</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/other/#IpcProvider">IpcProvider</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/other/#UrlJsonRpcProvider">UrlJsonRpcProvider</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/other/#Web3Provider">Web3Provider</a></div><div style="padding-left: 0px"><span class="bullet">•</span><a href="/v5/api/providers/types/">Types</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/types/#providers-BlockTag">BlockTag</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/types/#providers-Network">Network</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/types/#providers-Block">Block</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/types/#types--events-and-logs">Events and Logs</a></div><div style="padding-left: 28px"><span class="bullet">•</span><a href="/v5/api/providers/types/#types--transactions">Transactions</a></div></div>
|
|
|
|
<div class="footer">
|
|
<div class="nav previous"><a href="/v5/api/signer/"><span class="arrow">←</span>Signers</a></div>
|
|
<div class="nav next"><a href="/v5/api/providers/provider/">Provider<span class="arrow">→</span></a></div>
|
|
</div>
|
|
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on June 8, 2020, 10:6pm.</div>
|
|
</div>
|
|
<script src="/v5/static/script.js" type="text/javascript"></script>
|
|
</body>
|
|
</html>
|