ethers.js/docs/v5/api/contract/example/index.html

135 lines
27 KiB
HTML
Raw Permalink Normal View History

2020-06-09 23:56:58 -04:00
<!DOCTYPE html>
<html class="paged">
<head>
<title>Example: ERC-20 Contract</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>
2020-06-12 03:38:55 -04:00
<div class="link title"><a href="/v5/">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="ancestor show link depth-2"><a href="/v5/api/contract/">Contract Interaction</a></div><div class="show link depth-3"><a href="/v5/api/contract/contract/">Contract</a></div><div class="show link depth-3"><a href="/v5/api/contract/contract-factory/">ContractFactory</a></div><div class="myself ancestor ancestor show 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="show link depth-2"><a href="/v5/api/providers/">Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/provider/">Provider</a></div><div class="hide link depth-3"><a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><div class="hide link depth-3"><a href="/v5/api/providers/api-providers/">API Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/other/">Other Providers</a></div><div class="hide 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/coder/">AbiCoder</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/formats/">ABI Formats</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/fragments/">Fragments</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/interface/">Interface</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="sho
2020-06-09 23:56:58 -04:00
</div></div>
</div>
<div class="content">
<div class="breadcrumbs"><a href="/v5/">Documentation</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<a href="/v5/api/">API</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<a href="/v5/api/contract/">Contract Interaction</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<span class="current">Example: ERC-20 Contract</span></div>
<a name="example-erc-20-contract"></a><h1 class="show-anchors"><div>Example: ERC-20 Contract<div class="anchors"><a class="self" href="/v5/api/contract/example/#example-erc-20-contract"></a></div></div></h1>
<a name="example-erc-20-contract--connecting-to-a-contract"></a><h2 class="show-anchors"><div>Connecting to a Contract<div class="anchors"><a class="self" href="/v5/api/contract/example/#example-erc-20-contract--connecting-to-a-contract"></a></div></div></h2>
2020-06-12 19:21:37 -04:00
<div class="code-title"><div>A simple ERC-20 contract</div></div><div class="code"><span class="comment">// A Human-Readable ABI; any supported ABI format could be used
</span>const abi = [
<span class="comment"> // Read-Only Functions
</span> "function balanceOf(address owner) view returns (uint256)",
2020-06-09 23:56:58 -04:00
"function decimals() view returns (uint8)",
"function symbol() view returns (string)",
2020-06-12 19:21:37 -04:00
<span class="comment"> // Authenticated Functions
</span> "function transfer(address to, uint amount) returns (boolean)",
2020-06-09 23:56:58 -04:00
2020-06-12 19:21:37 -04:00
<span class="comment"> // Events
</span> "event Transfer(address indexed from, address indexed to, uint amount)"
2020-06-09 23:56:58 -04:00
];
2020-06-12 19:21:37 -04:00
<span class="comment">// This can be an address or an ENS name
</span>const address = "dai.tokens.ethers.eth";
2020-06-09 23:56:58 -04:00
2020-06-12 19:21:37 -04:00
<span class="comment">// An example Provider
</span>const provider = ethers.getDefaultProvider();
2020-06-09 23:56:58 -04:00
2020-06-12 19:21:37 -04:00
<span class="comment">// An example Signer
</span>const signer = ethers.Wallet.createRandom().connect(provider);
2020-06-09 23:56:58 -04:00
2020-06-12 19:21:37 -04:00
<span class="comment">// Read-Only; By connecting to a Provider, allows:
</span><span class="comment">// - Any constant function
</span><span class="comment">// - Querying Filters
</span><span class="comment">// - Populating Unsigned Transactions for non-constant methods
</span><span class="comment">// - Estimating Gas for non-constant (as an anonymous sender)
</span><span class="comment">// - Static Calling non-constant methods (as anonymous sender)
</span>const erc20 = new ethers.Contract(address, abi, provider);
2020-06-09 23:56:58 -04:00
2020-06-12 19:21:37 -04:00
<span class="comment">// Read-Write; By connecting to a Signer, allows:
</span><span class="comment">// - Everything from Read-Only (except as Signer, not anonymous)
</span><span class="comment">// - Sending transactions for non-constant functions
</span>const erc20_rw = new ethers.Contract(address, abi, signer)
</div><a name="example-erc-20-contract--connecting-to-a-contract--erc20contract"></a><h3 class="show-anchors"><div>ERC20Contract<span class="inherits"> inherits <a href="/v5/api/contract/contract/">Contract</a></span><div class="anchors"><a class="self" href="/v5/api/contract/example/#example-erc-20-contract--connecting-to-a-contract--erc20contract"></a></div></div></h3>
2020-06-09 23:56:58 -04:00
<div class="property show-anchors"><div class="signature"><span class="modifier">new </span><span class="path">ethers</span><span class="symbol">.</span><span class="method">Contract</span><span class="symbol">(</span> <span class="param">address</span> <span class="symbol">,</span> <span class="param">abi</span> <span class="symbol">,</span> <span class="param">providerOrSigner</span> <span class="symbol">)</span><div class="anchors"></div></div><div class="body"><p>See the above code example for creating an Instance which will (in addition to the Contact methods and properties) automatically add the additional properties defined in <i>abi</i> to a <b>Contract</b> connected to <i>address</i> using the <i>providerOrSigner</i>.</p>
</div></div><a name="example-erc-20-contract--properties"></a><h2 class="show-anchors"><div>Properties<span class="inherits">(inheritted from <a href="/v5/api/contract/contract/">Contract</a>)</span><div class="anchors"><a class="self" href="/v5/api/contract/example/#example-erc-20-contract--properties"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">address</span> <span class="arrow">&rArr;</span> <span class="returns">string&lt; <a href="/v5/api/utils/address/#address">Address</a> &gt;</span><div class="anchors"></div></div><div class="body"><p>This is the address (or ENS name) the contract was constructed with.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">resolvedAddress</span> <span class="arrow">&rArr;</span> <span class="returns">string&lt; <a href="/v5/api/utils/address/#address">Address</a> &gt;</span><div class="anchors"></div></div><div class="body"><p>This is a promise that will resolve to the address the <b>Contract</b> object is attached to. If an <a href="/v5/api/utils/address/#address">Address</a> was provided to the constructor, it will be equal to this; if an ENS name was provided, this will be the resolved address.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">deployTransaction</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/v5/api/providers/types/#providers-TransactionResponse">TransactionResponse</a></span><div class="anchors"></div></div><div class="body"><p>If the <b>Contract</b> object is the result of a ContractFactory deployment, this is the transaction which was used to deploy the contract.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">interface</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/v5/api/utils/abi/interface/">Interface</a></span><div class="anchors"></div></div><div class="body"><p>This is the ABI as an <a href="/v5/api/utils/abi/interface/">Interface</a>.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">provider</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/v5/api/providers/provider/">Provider</a></span><div class="anchors"></div></div><div class="body"><p>If a provider was provided to the constructor, this is that provider. If a signer was provided that had a <a href="/v5/api/providers/provider/">Provider</a>, this is that provider.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">signer</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/v5/api/signer/#Signer">Signer</a></span><div class="anchors"></div></div><div class="body"><p>If a signer was provided to the constructor, this is that signer.</p>
</div></div><a name="example-erc-20-contract--methods"></a><h2 class="show-anchors"><div>Methods<span class="inherits">(inheritted from <a href="/v5/api/contract/contract/">Contract</a>)</span><div class="anchors"><a class="self" href="/v5/api/contract/example/#example-erc-20-contract--methods"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">attach</span><span class="symbol">(</span> <span class="param">addressOrName</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/v5/api/contract/contract/">Contract</a></span><div class="anchors"></div></div><div class="body"><p>Returns a new instance of the <b>Contract</b> attached to a new address. This is useful if there are multiple similar or identical copies of a Contract on the network and you wish to interact with each of them.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">connect</span><span class="symbol">(</span> <span class="param">providerOrSigner</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/v5/api/contract/contract/">Contract</a></span><div class="anchors"></div></div><div class="body"><p>Returns a new instance of the Contract, but connected to <i>providerOrSigner</i>.</p>
<p>By passing in a <a href="/v5/api/providers/provider/">Provider</a>, this will return a downgraded <b>Contract</b> which only has read-only access (i.e. constant calls).</p>
<p>By passing in a <a href="/v5/api/signer/#Signer">Signer</a>. the will return a <b>Contract</b> which will act on behalf of that signer.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">deployed</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Promise&lt; Contract &gt;</span><div class="anchors"></div></div><div class="body">
</div></div><div class="property show-anchors"><div class="signature"><span class="path">Contract</span><span class="symbol">.</span><span class="method">isIndexed</span><span class="symbol">(</span> <span class="param">value</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">boolean</span><div class="anchors"></div></div><div class="body">
</div></div><a name="erc20-events"></a><a name="example-erc-20-contract--erc20-events"></a><h2 class="show-anchors"><div>Events<span class="inherits">(inheritted from <a href="/v5/api/contract/contract/">Contract</a>)</span><div class="anchors"><a class="self" href="/v5/api/contract/example/#erc20-events"></a></div></div></h2>
<a name="erc20-queryfilter"></a><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">queryFilter</span><span class="symbol">(</span> <span class="param">event</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">fromBlockOrBlockHash</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">toBlock</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Promise&lt; Array&lt; Event &gt; &gt;</span><div class="anchors"><a class="self" href="/v5/api/contract/example/#erc20-queryfilter"></a></div></div><div class="body"><p>Return Events that match the <i>event</i>.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">listenerCount</span><span class="symbol">(</span> <span class="symbol">[</span> <span class="param">event</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">number</span><div class="anchors"></div></div><div class="body"><p>Return the number of listeners that are subscribed to <i>event</i>. If no event is provided, returns the total count of all events.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">listeners</span><span class="symbol">(</span> <span class="param">event</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Array&lt; Listener &gt;</span><div class="anchors"></div></div><div class="body"><p>Return a list of listeners that are subscribed to <i>event</i>.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">off</span><span class="symbol">(</span> <span class="param">event</span> <span class="symbol">,</span> <span class="param">listener</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">this</span><div class="anchors"></div></div><div class="body"><p>Unsubscribe <i>listener</i> to <i>event</i>.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">on</span><span class="symbol">(</span> <span class="param">event</span> <span class="symbol">,</span> <span class="param">listener</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">this</span><div class="anchors"></div></div><div class="body"><p>Subscribe to <i>event</i> calling <i>listener</i> when the event occurs.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">once</span><span class="symbol">(</span> <span class="param">event</span> <span class="symbol">,</span> <span class="param">listener</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">this</span><div class="anchors"></div></div><div class="body"><p>Subscribe once to <i>event</i> calling <i>listener</i> when the event occurs.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">removeAllListeners</span><span class="symbol">(</span> <span class="symbol">[</span> <span class="param">event</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">this</span><div class="anchors"></div></div><div class="body"><p>Unsubscribe all listeners for <i>event</i>. If no event is provided, all events are unsubscribed.</p>
</div></div><a name="example-erc-20-contract--meta-class-methods"></a><h2 class="show-anchors"><div>Meta-Class Methods<span class="inherits">(added at Runtime)</span><div class="anchors"><a class="self" href="/v5/api/contract/example/#example-erc-20-contract--meta-class-methods"></a></div></div></h2><p>Since the Contract is a Meta-Class, the methods available here depend on the ABI which was passed into the <b>Contract</b>.</p>
<div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">decimals</span><span class="symbol">(</span> <span class="symbol">[</span> <span class="param">overrides</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Promise&lt; number &gt;</span><div class="anchors"></div></div><div class="body"><p>Returns the number of decimal places used by this ERC-20 token. This can be used with <a href="/v5/api/utils/display-logic/#utils-parseUnits">parseUnits</a> when taking input from the user or [formatUnits](utils-formatunits] when displaying the token amounts in the UI.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">getBalance</span><span class="symbol">(</span> <span class="param">owner</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">overrides</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Promise&lt; <a href="/v5/api/utils/bignumber/">BigNumber</a> &gt;</span><div class="anchors"></div></div><div class="body"><p>Returns the balance of <i>owner</i> for this ERC-20 token.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="method">symbol</span><span class="symbol">(</span> <span class="symbol">[</span> <span class="param">overrides</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Promise&lt; string &gt;</span><div class="anchors"></div></div><div class="body"><p>Returns the symbol of the token.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20_rw</span><span class="symbol">.</span><span class="method">transfer</span><span class="symbol">(</span> <span class="param">target</span> <span class="symbol">,</span> <span class="param">amount</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">overrides</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Promise&lt; <a href="/v5/api/providers/types/#providers-TransactionResponse">TransactionResponse</a> &gt;</span><div class="anchors"></div></div><div class="body"><p>Transfers <i>amount</i> tokens to <i>target</i> from the current signer. The return value (a boolean) is inaccessible during a write operation using a transaction. Other techniques (such as events) are required if this value is required. On-chain contracts calling the <code class="inline">transfer</code> function have access to this result, which is why it is possible.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="path">callStatic</span><span class="symbol">.</span><span class="method">transfer</span><span class="symbol">(</span> <span class="param">target</span> <span class="symbol">,</span> <span class="param">amount</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">overrides</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Promise&lt; boolean &gt;</span><div class="anchors"></div></div><div class="body"><p>Performs a dry-run of transferring <i>amount</i> tokens to <i>target</i> from the current signer, without actually signing or sending a transaction.</p>
<p>This can be used to preflight check that a transaction will be successful.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="path">estimateGas</span><span class="symbol">.</span><span class="method">transfer</span><span class="symbol">(</span> <span class="param">target</span> <span class="symbol">,</span> <span class="param">amount</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">overrides</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Promise&lt; <a href="/v5/api/utils/bignumber/">BigNumber</a> &gt;</span><div class="anchors"></div></div><div class="body"><p>Returns an estimate for how many units of gas would be required to transfer <i>amount</i> tokens to <i>target</i>.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="path">populateTransaction</span><span class="symbol">.</span><span class="method">transfer</span><span class="symbol">(</span> <span class="param">target</span> <span class="symbol">,</span> <span class="param">amount</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">overrides</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Promise&lt; <a href="/v5/api/utils/transactions/#UnsignedTransaction">UnsignedTx</a> &gt;</span><div class="anchors"></div></div><div class="body"><p>Returns an <a href="/v5/api/utils/transactions/#UnsignedTransaction">UnsignedTransaction</a> which could be signed and submitted to the network to transaction <i>amount</i> tokens to <i>target</i>.</p>
</div></div><div class="definition container-box note"><div class="term">Note on Estimating and Static Calling</div><div class="body"><p>When you perform a static call, the current state is taken into account as best as Ethereum can determine. There are many cases where this can provide false positives and false negatives. The eventually consistent model of the blockchain also means there are certain consistency modes that cannot be known until an actual transaction is attempted.</p>
</div></div><a name="example-erc-20-contract--meta-class-filters"></a><h2 class="show-anchors"><div>Meta-Class Filters<span class="inherits">(added at Runtime)</span><div class="anchors"><a class="self" href="/v5/api/contract/example/#example-erc-20-contract--meta-class-filters"></a></div></div></h2><p>Since the Contract is a Meta-Class, the methods available here depend on the ABI which was passed into the <b>Contract</b>.</p>
<div class="property show-anchors"><div class="signature"><span class="path">erc20</span><span class="symbol">.</span><span class="path">filters</span><span class="symbol">.</span><span class="method">Transafer</span><span class="symbol">(</span> <span class="symbol">[</span> <span class="param">fromAddress</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">toAddress</span> <span class="symbol">]</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Filter</span><div class="anchors"></div></div><div class="body"><p>Returns a new Filter which can be used to <a href="/v5/api/contract/example/#erc20-queryfilter">query</a> or to <a href="/v5/api/contract/example/#erc20-events">subscribe/unsubscribe to events</a>.</p>
<p>If <i>fromAddress</i> is null or not provided, then any from address matches. If <i>toAddress</i> is null or not provided, then any to address matches.</p>
</div></div>
<div class="footer">
<div class="nav previous"><a href="/v5/api/contract/contract-factory/"><span class="arrow">&larr;</span>ContractFactory</a></div>
<div class="nav next"><a href="/v5/api/signer/">Signers<span class="arrow">&rarr;</span></a></div>
</div>
2020-06-12 19:21:37 -04:00
<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>. Last modified on June 12, 2020, 7:17pm.</div>
2020-06-09 23:56:58 -04:00
</div>
<script src="/v5/static/script.js" type="text/javascript"></script>
</body>
</html>