51 lines
28 KiB
HTML
51 lines
28 KiB
HTML
|
<html><head><title>Abstract Provider</title><link rel="stylesheet" type="text/css" href="/static/style.css"></head><body><div class="sidebar"><div class="header"><div class="logo"><a href="/"><div class="image"></div><div class="name">ethers.js</div><div class="version">v5.0</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="/getting-started/">Getting Started</a></div><div class="hide link depth-2"><a href="/getting-started/#installing">Installing</a></div><div class="hide link depth-2"><a href="/getting-started/#importing">Importing</a></div><div class="base show link depth-1"><a href="/concepts/">Concepts</a></div><div class="hide link depth-2"><a href="/concepts/events/">Events</a></div><div class="hide link depth-2"><a href="/concepts/gas/">Gas</a></div><div class="hide link depth-3"><a href="/concepts/gas/#gas-price">Gas Price</a></div><div class="hide link depth-3"><a href="/concepts/gas/#gas-limit">Gas Limit</a></div><div class="base ancestor show link depth-1"><a href="/api/">Application Programming Interface</a></div><div class="show link depth-2"><a href="/api/contract/">Contracts</a></div><div class="hide link depth-3"><a href="/api/contract/#buckets">Buckets</a></div><div class="show link depth-2"><a href="/api/signer/">Signers</a></div><div class="hide link depth-3"><a href="/api/signer/#signer">Signer</a></div><div class="hide link depth-3"><a href="/api/signer/#wallet-inherits-signer">Wallet inherits Signer</a></div><div class="ancestor show link depth-2"><a href="/api/providers/">Providers</a></div><div class="myself ancestor ancestor show link depth-3"><a href="/api/providers/provider/">Provider</a></div><div class="child link depth-4"><a href="/api/providers/provider/#accounts-methods">Accounts Methods</a></div><div class="child link depth-4"><a href="/api/providers/provider/#blocks-methods">Blocks Methods</a></div><div class="child link depth-4"><a href="/api/providers/provider/#ethereum-naming-service-(ens)-methods">Ethereum Naming Service (ENS) Methods</a></div><div class="child link depth-4"><a href="/api/providers/provider/#logs-methods">Logs Methods</a></div><div class="child link depth-4"><a href="/api/providers/provider/#network-status-methods">Network Status Methods</a></div><div class="child link depth-4"><a href="/api/providers/provider/#transactions-methods">Transactions Methods</a></div><div class="child link depth-4"><a href="/api/providers/provider/#event-emitter-methods">Event Emitter Methods</a></div><div class="child link depth-4"><a href="/api/providers/provider/#inspection-methods">Inspection Methods</a></div><div class="show link depth-3"><a href="/api/providers/jsonrpc-provider/">JSON-RPC Provider</a></div><div class="hide link depth-4"><a href="/api/providers/jsonrpc-provider/#jsonrpcprovider">JsonRpcProvider</a></div><div class="hide link depth-4"><a href="/api/providers/jsonrpc-provider/#jsonrpcsigner">JsonRpcSigner</a></div><div class="hide link depth-4"><a href="/api/providers/jsonrpc-provider/#jsonrpcuncheckedsigner">JsonRpcUncheckedSigner</a></div><div class="show link depth-3"><a href="/api/providers/api-providers/">API Providers</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#etherscanprovider">EtherscanProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#infuraprovider">InfuraProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#nodesmithprovider">NodesmithProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#alchemyprovider">AlchemyProvider</a></div><div class="show link depth-3"><a href="/api/providers/other/">Other Providers</a></div><div class="hide link depth-4"><a href="/api/providers/other/#fallbackprovider">FallbackProvider</a></div><div class="hide link depth-4"><a href="/api/providers/other/#ipcprovider">IpcProvider</a></div><div class="show link depth-3"><a href="/api/providers/types/">Types</a></div><div class="hide link depth-4"><a
|
||
|
<a name="provider"></a><a name="provider"></a><h1>Provider</h1>
|
||
|
<p>Explain what a provider is...</p>
|
||
|
<a name="accounts-methods"></a><h2>Accounts Methods</h2>
|
||
|
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">getBalance</span> ( <span class="param">address</span> [ , <span class="param">blockTag</span> = <span class="default-value">"</span><span class="param">latest</span>" ] ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/utils/bignumber/">BigNumber</a> ></span></div><div class="body"><p>Returns the balance of <i>address</i> as of the <i>blockTag</i> block height.</p></div></div>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">getCode</span> ( <span class="param">address</span> [ , <span class="param">blockTag</span> = <span class="default-value">"</span><span class="param">latest</span>" ] ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/utils/bytes/#hexstring">Hexstring</a> ></span></div><div class="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 <code class="inline">0x</code>.</p></div></div>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">getStorageAt</span> ( <span class="param">address</span> , <span class="param">position</span> [ , <span class="param">blockTag</span> = <span class="default-value">"</span><span class="param">latest</span>" ] ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/utils/bytes/#hexstring">Hexstring</a> ></span></div><div class="body"><p>Returns the <code class="inline">Bytes32</code> value of the <i>position</i> at <i>address</i>, as of the <i>blockTag</i>.</p></div></div>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">getTransactionCount</span> ( <span class="param">address</span> [ , <span class="param">blockTag</span> = <span class="default-value">"</span><span class="param">latest</span>" ] ) <span class="arrow">⇒</span> <span class="returns">Promise< number ></span></div><div class="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></div></div>
|
||
|
<a name="examples"></a><h3>Examples</h3>
|
||
|
|
||
|
<div class="code"><br><span class="comment">// Get the balance for an account...</span><br>provider.getBalance("ricmoo.firefly.eth");<br><span class="result ok">// { Promise: { BigNumber: "3446592266910605872" } }</span></span><br><br><span class="comment">// Get the code for a contract...</span><br>provider.getCode("registrar.firefly.eth");<br><span class="result ok">// { Promise: "0x606060405236156100885763ffffffff60e060020a60003504166369fe0e2d81146100fa578063704b6c021461010f57806379502c551461012d578063bed866f614610179578063c37067fa1461019e578063c66485b2146101ab578063d80528ae146101c9578063ddca3f43146101f7578063f2c298be14610219578063f3fef3a314610269575b6100f85b6000808052600760209081527f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df80543490810190915560408051918252517fdb7750418f9fa390aaf85d881770065aa4adbe46343bcff4ae573754c829d9af929181900390910190a25b565b005b341561010257fe5b6100f860043561028a565b005b341561011757fe5b6100f8600160a060020a03600435166102ec565b005b341561013557fe5b61013d610558565b60408051600160a060020a0396871681526020810195909552928516848401526060840191909152909216608082015290519081900360a00190f35b341561018157fe5b61018c600435610580565b60408051918252519081900360200190f35b6100f8600435610595565b005b34156101b357fe5b6100f8600160a060020a03600435166105e6565b005b34156101d157fe5b6101d9610676565b60408051938452602084019290925282820152519081900360600190f35b34156101ff57fe5b61018c61068d565b60408051918252519081900360200190f35b6100f8600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965061069495505050505050565b005b341561027157fe5b6100f8600160a060020a0360043516602435610ab2565b005b60025433600160a060020a039081169116146102a65760006000fd5b600454604080519182526020820183905280517f854231545a00e13c316c82155f2b8610d638e9ff6ebc4930676f84a5af08a49a9281900390910190a160048190555b50565b60025433600160a060020a039081169116146103085760006000fd5b60025460408051600160a060020a039283168152918316602083015280517fbadc9a52979e89f78b7c58309537410c5e51d0f63a0a455efe8d61d2b474e6989281900390910190a16002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038381169190911790915560008054604080516020908101849052815160e060020a6302571be30281527f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e26004820152915192909416936302571be39360248084019492938390030190829087803b15156103e957fe5b60325a03f115156103f657fe5b50505060405180519050600160a060020a0316631e83409a826000604051602001526040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050602060405180830381600087803b151561045f57fe5b60325a03f1151561046c57fe5b50506040805160008054600354602093840183905284517f0178b8bf00000000000000000000000000000000000000000000000000000000815260048101919091529351600160a060020a039091169450630178b8bf9360248082019493918390030190829087803b15156104dd57fe5b60325a03f115156104ea57fe5b505060408051805160035460025460e860020a62d5fa2b0284526004840191909152600160a060020a03908116602484015292519216925063d5fa2b0091604480830192600092919082900301818387803b151561054457fe5b60325a03f1151561055157fe5b5050505b50565b600054600354600254600454600154600160a060020a039485169492831692165b9091929394565b6000818152600760205260409020545b919050565b6000818152600760209081526040918290208054349081019091558251908152915183927fdb7750418f9fa390aaf85d881770065aa4adbe46343bcff4ae573754c829d9af92908290030190a25b50565b60025433600160a060020a039081169116146106025760006000fd5b60015460408051600160a060020a039283168152918316602083015280517f279875333405c968e401e3bc4e71d5f8e48728c90f4e8180ce28f74efb5669209281900390910190a16001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b600654600554600160a060020a033016315b909192565b6004545b90565b80516001820190600080808060048510806106af5750601485115b156106ba5760006000fd5b600093505b8484101561072a57855160ff16925060618310806106e05750607a8360ff16115b80156106fc575060308360ff1610806106fc575060398360ff16115b5b801561070d57508260ff16602d14155b156107185760006000fd5b6001909501945b6001909301926106bf565b60045434101561073a5760006000fd5b86604
|
||
|
|
||
|
<a name="blocks-methods"></a><h2>Blocks Methods</h2>
|
||
|
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">getBlock</span> ( <span class="param">block</span> ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/providers/types/#provider-block">Block</a> ></span></div><div class="body"><p>Get the <i>block</i> from the network, where the <code class="inline">result.transactions</code> is a list of transaction hashes.</p></div></div>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">getBlockWithTransactions</span> ( <span class="param">block</span> ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/providers/types/#provider-blocktxs">BlockWithTransactions</a> ></span></div><div class="body"><p>Get the <i>block</i> from the network, where the <code class="inline">result.transactions</code> is an Array of <a href="/api/providers/types/#provider-transactionresponse">TransactionResponse</a> objects.</p></div></div>
|
||
|
<a name="ethereum-naming-service-(ens)-methods"></a><h2>Ethereum Naming Service (ENS) Methods</h2>
|
||
|
<p>TODO: Explain ENS here...</p>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">lookupAddress</span> ( <span class="param">address</span> ) <span class="arrow">⇒</span> <span class="returns">Promise< string ></span></div><div class="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, <code class="inline">null</code> is returned.</p></div></div>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">resovleName</span> ( <span class="param">name</span> ) <span class="arrow">⇒</span> <span class="returns">Promise< string ></span></div><div class="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, <code class="inline">null</code> is returned.</p></div></div>
|
||
|
<a name="examples"></a><h3>Examples</h3>
|
||
|
|
||
|
<div class="code"><br><span class="comment">// Reverse lookup of an ENS by address...</span><br>provider.lookupAddress("0x6fC21092DA55B392b045eD78F4732bff3C580e2c");<br><span class="result ok">// { Promise: "registrar.firefly.eth" }</span></span><br><br><span class="comment">// Lookup an address of an ENS name...</span><br>provider.resolveName("ricmoo.firefly.eth");<br><span class="result ok">// { Promise: "0x8ba1f109551bD432803012645Ac136ddd64DBA72" }</span></span><br><br></div>
|
||
|
|
||
|
<a name="logs-methods"></a><h2>Logs Methods</h2>
|
||
|
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">getLogs</span> ( <span class="param">filter</span> ) <span class="arrow">⇒</span> <span class="returns">Promise< Array< <a href="/api/providers/types/#provider-log">Log</a> > ></span></div><div class="body"><p>Returns the Array of <a href="/api/providers/types/#provider-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>
|
||
|
<a name="network-status-methods"></a><h2>Network Status Methods</h2>
|
||
|
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">getNetwork</span> ( ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/providers/types/#provider-network">Network</a> ></span></div><div class="body"><p>Returns the <a href="/api/providers/types/#provider-network">Network</a> this Provider is connected to.</p></div></div>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">getBlockNumber</span> ( ) <span class="arrow">⇒</span> <span class="returns">Promise< number ></span></div><div class="body"><p>Returns the block number (or height) of the most recently mined block.</p></div></div>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">getGasPrice</span> ( ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/utils/bignumber/">BigNumber</a> ></span></div><div class="body"><p>Returns a <i>best guess</i> of the <a href="/concepts/gas/#gas-price">Gas Price</a> to use in a transaction.</p></div></div>
|
||
|
<a name="transactions-methods"></a><h2>Transactions Methods</h2>
|
||
|
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">call</span> ( <span class="param">transaction</span> [ , <span class="param">blockTag</span> = <span class="default-value">"</span><span class="param">latest</span>" ] ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/utils/bytes/#hexstring">Hexstring</a> ></span></div><div class="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>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">estimateGas</span> ( <span class="param">transaction</span> ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/utils/bignumber/">BigNumber</a> ></span></div><div class="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>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">sendTransaction</span> ( <span class="param">transaction</span> ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/providers/types/#provider-transactionresponse">TransactionResponse</a> ></span></div><div class="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>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">waitForTransaction</span> ( <span class="param">transactionHash</span> ) <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/api/providers/types/#provider-transactionreceipt">TransactionReceipt</a> ></span></div><div class="body"><p>Returns a Promise which will not resolve until <i>transactionHash</i> is mined.</p></div></div>
|
||
|
<a name="event-emitter-methods"></a><h2>Event Emitter Methods</h2>
|
||
|
<p>Explain events here...</p>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">on</span> ( <span class="param">eventName</span> , <span class="param">listener</span> ) <span class="arrow">⇒</span> <span class="returns">this</span></div><div class="body"><p>Add a <i>listener</i> to be triggered for each <i>eventName</i>.</p></div></div>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">once</span> ( <span class="param">eventName</span> , <span class="param">listener</span> ) <span class="arrow">⇒</span> <span class="returns">this</span></div><div class="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>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">emit</span> ( <span class="param">eventName</span> , ...<span class="param">args</span> ) <span class="arrow">⇒</span> <span class="returns">boolean</span></div><div class="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>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">off</span> ( <span class="param">eventName</span> [ , <span class="param">listener</span> ] ) <span class="arrow">⇒</span> <span class="returns">this</span></div><div class="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>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">removeAllListeners</span> ( [ <span class="param">eventName</span> ] ) <span class="arrow">⇒</span> <span class="returns">this</span></div><div class="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>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">listenerCount</span> ( [ <span class="param">eventName</span> ] ) <span class="arrow">⇒</span> <span class="returns">number</span></div><div class="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>
|
||
|
<div class="property"><div class="signature"><span class="path">provider</span> . <span class="method">listeners</span> ( <span class="param">eventName</span> ) <span class="arrow">⇒</span> <span class="returns">Array< Listener ></span></div><div class="body"><p>Returns the list of Listeners for <i>eventName</i>.</p></div></div>
|
||
|
<a name="inspection-methods"></a><h2>Inspection Methods</h2>
|
||
|
|
||
|
<div class="property"><div class="signature"><span class="path">Provider</span> . <span class="method">isProvider</span> ( <span class="param">object</span> ) <span class="arrow">⇒</span> <span class="returns">boolean</span></div><div class="body"><p>Returns true if and only if object is a Provider.</p></div></div><div class="footer"><div class="nav previous"><a href="/api/providers/"><span class="arrow">←</span>Providers</a></div> <div class="nav next"><a href="/api/providers/jsonrpc-provider/">JSON-RPC 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 Attribution 4.0 International License</a>.</div></div><script src="/script.js" type="text/javascript"></script></body></html><!-- ContentHash:afe22f89ad3a869a23a32424f5f4ece8ca570d0ae5971ba6120011a3fd5fee80 -->
|