<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="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/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><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><di
<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>
<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 simultaneously. 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>. If no <i>network</i> is provided, <b>homestead</b> (i.e. mainnet) is used.</p>
<p>The <i>network</i> may also be a URL to connect to, such as <codeclass="inline">http://localhost:8545</code> or <codeclass="inline">wss://example.com</code>.</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 <codeclass="inline">{ projectId, projectSecret }</code></td><tdclass="fix"> </td></tr><tr><tdalign="center"><i>pocket</i></td><tdalign="left"><ahref="https://pokt.network">Pocket Network</a> Application ID or <codeclass="inline">{ applicationId, applicationSecretKey }</code></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 to acquire and specify an API Key for each service.</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>
</div></div><aname="providers--networks"></a><h2class="show-anchors"><div>Networks<divclass="anchors"><aclass="self"href="/v5/api/providers/#providers--networks"></a></div></div></h2><p>There are several official common Ethereum networks as well as custom networks and other compatible projects.</p>
<p>Any API that accept a <ahref="/v5/api/providers/types/#providers-Networkish">Networkish</a> can be passed a common name (such as <codeclass="inline">"mainnet"</code> or <codeclass="inline">"ropsten"</code>) to use that network definition or may specify custom parameters.</p>
<aname="providers--networks--custom-ens-contract"></a><h3class="show-anchors"><div>Custom ENS Contract<divclass="anchors"><aclass="self"href="/v5/api/providers/#providers--networks--custom-ens-contract"></a></div></div></h3><p>One common reason to specify custom properties for a <ahref="/v5/api/providers/types/#providers-Network">Network</a> is to override the address of the root ENS registry, either on a common network to intercept the <ahref="/v5/api/providers/provider/#Provider--ens-methods">ENS Methods</a> or to specify the ENS registry on a dev network (on most dev networks you must deploy the ENS contracts manually).</p>
<divclass="code-title"><div>Example: Override the ENS registry</div></div><divclass="code">const network = {
<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>