<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="base ancestor show link depth-1"><ahref="/v5/api/">Application Programming Interface</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/signer/">Signers</a></div><divclass="myself ancestor ancestor show link depth-2"><ahref="/v5/api/providers/">Providers</a></div><divclass="child show link depth-3"><ahref="/v5/api/providers/provider/">Provider</a></div><divclass="child show link depth-3"><ahref="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><divclass="child show link depth-3"><ahref="/v5/api/providers/api-providers/">API Providers</a></div><divclass="child show link depth-3"><ahref="/v5/api/providers/other/">Other Providers</a></div><divclass="child show link depth-3"><ahref="/v5/api/providers/types/">Types</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><divclass="hide link depth-3"><ahref="/v5/api/other/assembly/">Assembly</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/api/">Utilities</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/ast/">Abstract Syntax Tree</a></div><divclass="hide link depth-3"><ahref="/v5/api/other/hardware/">Hardware Wallets</a>
<aname="providers"></a><aname="providers"></a><h1class="show-anchors"><div>Providers<divclass="anchors"><aclass="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 <ahref="/v5/api/providers/#providers-getDefaultProvider">Default Provider</a>.</p>
<aname="providers-getDefaultProvider"></a><aname="providers--providers-getDefaultProvider"></a><h2class="show-anchors"><div>Default Provider<divclass="anchors"><aclass="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 <ahref="/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>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="method">getDefaultProvider</span><spanclass="symbol">(</span><spanclass="symbol">[</span><spanclass="param">network</span><spanclass="symbol">,</span><spanclass="symbol">[</span><spanclass="param">options</span><spanclass="symbol">]</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/providers/provider/">Provider</a></span><divclass="anchors"></div></div><divclass="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><tableclass="table minimal"><tr><tdalign="center"><b>Property</b></td><tdalign="center"><b>Description</b></td><tdclass="fix"> </td></tr><tr><tdalign="center"><i>alchemy</i></td><tdalign="left"><ahref="https://alchemyapi.io">Alchemy</a> API Token</td><tdclass="fix"> </td></tr><tr><tdalign="center"><i>etherscan</i></td><tdalign="left"><ahref="https://etherscan.io">Etherscan</a> API Token</td><tdclass="fix"> </td></tr><tr><tdalign="center"><i>infura</i></td><tdalign="left"><ahref="https://infura.io">INFURA</a> Project ID or ProjectID and Project Secret</td><tdclass="fix"> </td></tr><tr><tdalign="center"><i>quorum</i></td><tdalign="left">The number of backends that must agree <i>(default: 2 for mainnet, 1 for testnets)</i></td><tdclass="fix"> </td></tr><tr><tdclass="table-title"colspan="2">Option Properties</td><tdclass="fix"> </td></tr></table><divclass="definition container-box note"><divclass="term">Note: API Keys</div><divclass="body"><p>It is highly recommended for production services that to acquire and specify an API Key for each sercice.</p>
<p>The default 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 specified. This allows tracking how many requests are being sent and which methods are being used the most.</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 July 5, 2020, 12:0am.</div>