<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="ancestor show link depth-2"><ahref="/v5/api/providers/">Providers</a></div><divclass="myself ancestor ancestor show link depth-3"><ahref="/v5/api/providers/provider/">Provider</a></div><divclass="show link depth-3"><ahref="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</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/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></div><divclass="sho
<aname="Provider"></a><aname="Provider"></a><h1class="show-anchors"><div>Provider<divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider"></a></div></div></h1><p>Explain what a provider is...</p>
<aname="Provider-getBalance"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">getBalance</span><spanclass="symbol">(</span><spanclass="param">address</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">blockTag</span> = <spanclass="param">latest</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/utils/bignumber/">BigNumber</a>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-getBalance"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L689">source</a></div></div><divclass="body"><p>Returns the balance of <i>address</i> as of the <i>blockTag</i> block height.</p>
</div></div><aname="Provider-getCode"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">getCode</span><spanclass="symbol">(</span><spanclass="param">address</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">blockTag</span> = <spanclass="param">latest</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-getCode"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L707">source</a></div></div><divclass="body"><p>Returns the contract code of <i>address</i> as of the <i>blockTag</i> block height. If there is no contract currently deployed, the result is <codeclass="inline">0x</code>.</p>
</div></div><aname="Provider-getStorageAt"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">getStorageAt</span><spanclass="symbol">(</span><spanclass="param">addr</span><spanclass="symbol">,</span><spanclass="param">pos</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">blockTag</span> = <spanclass="param">latest</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-getStorageAt"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L716">source</a></div></div><divclass="body"><p>Returns the <codeclass="inline">Bytes32</code> value of the position <i>pos</i> at address <i>addr</i>, as of the <i>blockTag</i>.</p>
</div></div><aname="Provider-getTransactionCount"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">getTransactionCount</span><spanclass="symbol">(</span><spanclass="param">address</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">blockTag</span> = <spanclass="param">latest</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< number ></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-getTransactionCount"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L698">source</a></div></div><divclass="body"><p>Returns the number of transactions <i>address</i> has ever <b>sent</b>, as of <i>blockTag</i>. This value is required to be the nonce for the next transaction from <i>address</i> sent to the network.</p>
<aname="Provider-getBlock"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">getBlock</span><spanclass="symbol">(</span><spanclass="param">block</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/providers/types/#providers-Block">Block</a>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-getBlock"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L925">source</a></div></div><divclass="body"><p>Get the <i>block</i> from the network, where the <codeclass="inline">result.transactions</code> is a list of transaction hashes.</p>
</div></div><aname="Provider-getBlockWithTransactions"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">getBlockWithTransactions</span><spanclass="symbol">(</span><spanclass="param">block</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/providers/types/#providers-BlockWithTransactions">BlockWithTransactions</a>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-getBlockWithTransactions"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L929">source</a></div></div><divclass="body"><p>Get the <i>block</i> from the network, where the <codeclass="inline">result.transactions</code> is an Array of <ahref="/v5/api/providers/types/#providers-TransactionResponse">TransactionResponse</a> objects.</p>
</span></div><aname="Provider--ens-methods"></a><aname="Provider--Provider--ens-methods"></a><h2class="show-anchors"><div>Ethereum Naming Service (ENS) Methods<divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider--ens-methods"></a></div></div></h2><p>The <ahref="https://ens.domains/">Ethereum Naming Service</a> (ENS) allows a short and easy-to-remember ENS Name to be atached to any set of keys and values.</p>
<p>One of the most common uses for this is to use a simple name to refer to an <ahref="/v5/api/utils/address/#address">Ethereum Address</a>.</p>
<p>In the ethers API, nearly anywhere that accepts an address, an ENS name may be used instead, which can simplify code and make reading and debugging much simpler.</p>
<p>The provider offers some basic operations to help resolve and work with ENS names.</p>
<aname="Provider-lookupAddress"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">lookupAddress</span><spanclass="symbol">(</span><spanclass="param">address</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string ></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-lookupAddress"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L1088">source</a></div></div><divclass="body"><p>Performs a reverse lookup of the <i>address</i> in ENS using the <i>Reverse Registrar</i>. If the name does not exist, or the forward lookup does not match, <codeclass="inline">null</code> is returned.</p>
</div></div><aname="Provider-ResolveName"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">resolveName</span><spanclass="symbol">(</span><spanclass="param">name</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/address/#address">Address</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-ResolveName"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L1060">source</a></div></div><divclass="body"><p>Looks up the address of <i>name</i>. If the name is not owned, or does not have a <i>Resolver</i> configured, or the <i>Resolver</i> does not have an address configured, <codeclass="inline">null</code> is returned.</p>
<aname="Provider-getLogs"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">getLogs</span><spanclass="symbol">(</span><spanclass="param">filter</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< Array<<ahref="/v5/api/providers/types/#providers-Log">Log</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-getLogs"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L1005">source</a></div></div><divclass="body"><p>Returns the Array of <ahref="/v5/api/providers/types/#providers-Log">Log</a> matching the <i>filter</i>.</p>
<p>Keep in mind that many backends will discard old events, and that requests which are too broad may get dropped as they require too many resources to execute the query.</p>
</div></div><aname="Provider--network-methods"></a><aname="Provider--Provider--network-methods"></a><h2class="show-anchors"><div>Network Status Methods<divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider--network-methods"></a></div></div></h2>
<aname="Provider-getNetwork"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">getNetwork</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/providers/types/#providers-Network">Network</a>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-getNetwork"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L509">source</a></div></div><divclass="body"><p>Returns the <ahref="/v5/api/providers/types/#providers-Network">Network</a> this Provider is connected to.</p>
</div></div><aname="Provider-getBlockNumber"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">getBlockNumber</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< number ></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-getBlockNumber"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L680">source</a></div></div><divclass="body"><p>Returns the block number (or height) of the most recently mined block.</p>
</div></div><aname="Provider-getGasPrice"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">getGasPrice</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/utils/bignumber/">BigNumber</a>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-getGasPrice"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L684">source</a></div></div><divclass="body"><p>Returns a <i>best guess</i> of the <ahref="/v5/concepts/gas/#gas-price">Gas Price</a> to use in a transaction.</p>
<aname="Provider-call"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">call</span><spanclass="symbol">(</span><spanclass="param">transaction</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">blockTag</span> = <spanclass="param">latest</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-call"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L825">source</a></div></div><divclass="body"><p>Returns the result of executing the <i>transaction</i>, using <i>call</i>. A call does not require any ether, but cannot change any state. This is useful for calling gettings on Contracts.</p>
</div></div><aname="Provider-estimateGas"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">estimateGas</span><spanclass="symbol">(</span><spanclass="param">transaction</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/utils/bignumber/">BigNumber</a>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-estimateGas"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L834">source</a></div></div><divclass="body"><p>Returns an estimate of the amount of gas that would be required to submit <i>transaction</i> to the network.</p>
<p>An estimate may not be accurate since there could be another transaction on the network that was not accounted for, but after being mined affected relevant state.</p>
</div></div><aname="Provider-sendTransaction"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">sendTransaction</span><spanclass="symbol">(</span><spanclass="param">transaction</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/providers/types/#providers-TransactionResponse">TransactionResponse</a>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-sendTransaction"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L766">source</a></div></div><divclass="body"><p>Submits <i>transaction</i> to the network to be mined. The <i>transaction</i><b>must</b> be signed, and be valid (i.e. the nonce is correct and the account has sufficient balance to pay for the transaction).</p>
</div></div><aname="Provider-waitForTransaction"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">waitForTransaction</span><spanclass="symbol">(</span><spanclass="param">hash</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">confirms</span> = <spanclass="param">1</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">timeout</span><spanclass="symbol">]</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/providers/types/#providers-TransactionReceipt">TxReceipt</a>></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-waitForTransaction"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L641">source</a></div></div><divclass="body"><p>Returns a Promise which will not resolve until <i>transactionHash</i> is mined.</p>
<aname="Provider-on"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">on</span><spanclass="symbol">(</span><spanclass="param">eventName</span><spanclass="symbol">,</span><spanclass="param">listener</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">this</span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-on"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L1146">source</a></div></div><divclass="body"><p>Add a <i>listener</i> to be triggered for each <i>eventName</i>.</p>
</div></div><aname="Provider-once"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">once</span><spanclass="symbol">(</span><spanclass="param">eventName</span><spanclass="symbol">,</span><spanclass="param">listener</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">this</span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-once"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L1150">source</a></div></div><divclass="body"><p>Add a <i>listener</i> to be triggered for only the next <i>eventName</i>, at which time it be removed.</p>
</div></div><aname="Provider-emit"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">emit</span><spanclass="symbol">(</span><spanclass="param">eventName</span><spanclass="symbol">,</span> ...<spanclass="param">args</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-emit"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L1155">source</a></div></div><divclass="body"><p>Notify all listeners of <i>eventName</i>, passing <i>args</i> to each listener. This is generally only used internally.</p>
</div></div><aname="Provider-off"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">off</span><spanclass="symbol">(</span><spanclass="param">eventName</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">listener</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">this</span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-off"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L1203">source</a></div></div><divclass="body"><p>Remove a <i>listener</i> for <i>eventName</i>. If no <i>listener</i> is provided, all listeners for <i>eventName</i> are removed.</p>
</div></div><aname="Provider-removeAllListeners"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">removeAllListeners</span><spanclass="symbol">(</span><spanclass="symbol">[</span><spanclass="param">eventName</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">this</span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-removeAllListeners"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L1226">source</a></div></div><divclass="body"><p>Remove all the listeners for <i>eventName</i>. If no <i>eventName</i> is provided, <b>all</b> events are removed.</p>
</div></div><aname="Provider-listenerCount"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">listenerCount</span><spanclass="symbol">(</span><spanclass="symbol">[</span><spanclass="param">eventName</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-listenerCount"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L1183">source</a></div></div><divclass="body"><p>Returns the number of listeners for <i>eventName</i>. If no <i>eventName</i> is provided, the total number of listeners is returned.</p>
</div></div><aname="Provider-listeners"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">provider</span><spanclass="symbol">.</span><spanclass="method">listeners</span><spanclass="symbol">(</span><spanclass="param">eventName</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Array< Listener ></span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-listeners"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/providers/src.ts/base-provider.ts#L1192">source</a></div></div><divclass="body"><p>Returns the list of Listeners for <i>eventName</i>.</p>
</div></div><aname="Provider--events"></a><aname="Provider--Provider--event-methods--Provider--events"></a><h3class="show-anchors"><div>Events<divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider--events"></a></div></div></h3><p>Any of the following may be used as the <i>eventName</i> in the above methods.</p>
<divclass="definition"><divclass="term"><b>Log Filter</b></div><divclass="body"><p>A filter is an object, representing a contract log Filter, which has the optional properties <codeclass="inline">address</code> (the source contract) and <codeclass="inline">topics</code> (a topic-set to match).</p>
<p>If <codeclass="inline">address</code> is unspecified, the filter matches any contract address.</p>
<p>See events for more information on how to specify topic-sets.</p>
</div></div><divclass="definition"><divclass="term"><b>Topic-Set Filter</b></div><divclass="body"><p>The value of a <b>Topic-Set Filter</b> is a array of Topic-Sets.</p>
<p>This event is identical to a <i>Log Filter</i> with the address omitted (i.e. from any contract).</p>
</div></div><divclass="definition"><divclass="term"><b>Transaction Filter</b></div><divclass="body"><p>The value of a <b>Transaction Filter</b> is any transaction hash.</p>
<p>This event is emitted on every block that is part of a chain that includes the given mined transaction. It is much more common that the <ahref="/v5/api/providers/provider/#Provider-once">once</a> method is used than the <ahref="/v5/api/providers/provider/#Provider-on">on</a> method.</p>
</div></div><p>In addition to transaction and filter events, there are several named events.</p>
<tableclass="table full"><tr><tdalign="center"width="16%"><b>Event Name</b></td><tdalign="center"colspan="2"width="28%"><b>Arguments</b></td><tdalign="center"colspan="4"width="56%"><b>Description</b></td><tdclass="fix"> </td></tr><tr><tdalign="center"width="16%"><codeclass="inline">"block"</code></td><tdalign="center"colspan="2"width="28%"><i>blockNumber</i></td><tdalign="left"colspan="4"width="56%">emitted when a new block is mined</td><tdclass="fix"> </td></tr><tr><tdalign="center"width="16%"><codeclass="inline">"error"</code></td><tdalign="center"colspan="2"width="28%"><i>error</i></td><tdalign="left"colspan="4"width="56%">emitted on any error</td><tdclass="fix"> </td></tr><tr><tdalign="center"width="16%"><codeclass="inline">"pending"</code></td><tdalign="center"colspan="2"width="28%"><i>pendingTransaction</i></td><tdalign="left"colspan="4"width="56%">emitted when a new transaction enters the memory pool; only certain providers offer this event and may require running your own node for reliable results</td><tdclass="fix"> </td></tr><tr><tdalign="center"width="16%"><codeclass="inline">"willPoll"</code></td><tdalign="center"colspan="2"width="28%"><i>pollId</i></td><tdalign="left"colspan="4"width="56%">emitted prior to a polling loop is about to begin; <i>(very rarely used by most developers)</i></td><tdclass="fix"> </td></tr><tr><tdalign="center"width="16%"><codeclass="inline">"poll"</code></td><tdalign="center"colspan="2"width="28%"><i>pollId</i>, <i>blockNumber</i></td><tdalign="left"colspan="4"width="56%">emitted during each poll cycle after `blockNumber` is updated (if changed) and before any other events (if any) are emitted during the poll loop; <i>(very rarely used by most developers)</i></td><tdclass="fix"> </td></tr><tr><tdalign="center"width="16%"><codeclass="inline">"didPoll"</code></td><tdalign="center"colspan="2"width="28%"><i>pollId</i></td><tdalign="left"colspan="4"width="56%">emitted after all events from a polling loop are emitted; <i>(very rarely used by most developers)</i></td><tdclass="fix"> </td></tr><tr><tdalign="center"width="16%"><codeclass="inline">"debug"</code></td><tdalign="center"colspan="2"width="28%">provider dependent</td><tdalign="left"colspan="4"width="56%">each Provider may use this to emit useful debugging information and the format is up to the developer; <i>(very rarely used by most developers)</i></td><tdclass="fix"> </td></tr><tr><tdclass="table-title"colspan="7">Named Provider Events</td><tdclass="fix"> </td></tr></table><divclass="code-title"><div>Events Example</div></div><divclass="code">provider.on("block", (blockNumber) => {
<spanclass="comment"> // Emitted on every block change
<aname="Provider-isProvider"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">Provider</span><spanclass="symbol">.</span><spanclass="method">isProvider</span><spanclass="symbol">(</span><spanclass="param">object</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"><aclass="self"href="/v5/api/providers/provider/#Provider-isProvider"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-provider/src.ts/index.ts#L269">source</a></div></div><divclass="body"><p>Returns true if and only if <i>object</i> is a Provider.</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>. Last modified on June 12, 2020, 7:17pm.</div>