<ahref="getting-started.html#Getting-block-data-gas-prices-and-block-time"class="c-side-navigation__item__anchor">Getting block data, gas prices and block time</a>
<li><code>web3</code> - <code>Object</code>: a <code>web3.js</code> object.</li>
<li><code>options</code> - <code>Object</code> (optional): Options used to initialize Subspace<ul>
<li><code>dbFilename</code> - <code>String</code> (optional): Name of the database where the information will be stored (default <code>'subspace.db'</code>)</li>
<li><code>callInterval</code> - Interval of time in milliseconds to query a contract/address to determine changes in state or balance. It’s only used with HttpProviders (default: <code>undefined</code>. Obtains data every block using the average block time as an interval).</li>
<li><code>refreshLastNBlocks</code> - Ignores last N blocks (from current block), stored in the local db and refresh them via a web3 subscription. Useful for possible reorgs (default: 12),</li>
<li><code>disableSubscriptions</code> - Subspace by default will attempt to use websocket subscriptions if the current provider supports them, otherwise it will use polling because it asumes the provider is an HttpProvider. This functionality can be disabled by passing true to this option. (default: undefined)</li>
<p><strong>Returns</strong><br><code>Promise</code> that once it’s resolved, will mean that <strong>Subspace</strong> is available to use</p>
<h3id="close"><ahref="#close"class="headerlink"title="close()"></a><code>close()</code></h3><p>Dispose and perform the cleanup necessary to remove the internal subscriptions and interval timers created by <strong>Subspace</strong> during its normal execution.</p>
<h3id="contract-instance-abi-address"><ahref="#contract-instance-abi-address"class="headerlink"title="contract(instance|{abi,address})"></a><code>contract(instance|{abi,address})</code></h3><p>Adds a <code>track</code> method to the web3 contract objects. You can obtain this functionality by passing a <code>web3.eth.Contract</code> instance, or the <code>abi</code> and <code>address</code> of your contract</p>
<p><strong>Returns</strong><br><code>web3.eth.Contract</code> object enhanced with <code>.track()</code> functions for methods and events.</p>
<h2id="Contract-methods"><ahref="#Contract-methods"class="headerlink"title="Contract methods"></a>Contract methods</h2><h3id="myContract-events-MyEvent-track-options"><ahref="#myContract-events-MyEvent-track-options"class="headerlink"title="myContract.events.MyEvent.track([options])"></a><code>myContract.events.MyEvent.track([options])</code></h3><p>Track a contract event.</p>
<p><strong>Parameters</strong></p>
<ol>
<li><code>options</code> - <code>Object</code> (optional): web3 filter options object to limit the number of events based on a block number range, or indexed filters<ul>
<li><code>filter</code> - <code>Object</code> (optional): Lets you filter events by indexed parameters, e.g. <code>{filter: {myNumber: [12,13]}}</code> means all events where <code>"myNumber"</code> is <code>12</code> or <code>13</code>.</li>
<li><code>fromBlock</code> - <code>Number</code> (optional): The block number from which to get events on.</li>
<li><code>toBlock</code> - <code>Number</code> (optional): The block number to get events up to (Defaults to <code>"latest"</code>)</li>
<li><code>topics</code> - <code>Array</code> (optional): This allows you to manually set the topics for the event filter. If given the filter property and event signature, (<code>topic[0]</code>) will not be set automatically.</li>
</ul>
</li>
</ol>
<p><strong>Returns</strong><br><code>RxJS Observable</code> which will stream the event <code>returnValues</code>.</p>
<h3id="myContract-methods-myMethod-param1-track-callOptions"><ahref="#myContract-methods-myMethod-param1-track-callOptions"class="headerlink"title="myContract.methods.myMethod([param1[, ...]]).track([callOptions])"></a><code>myContract.methods.myMethod([param1[, ...]]).track([callOptions])</code></h3><p>Track a constant function / contract state variable on each block mined, or depending on the <code>callInterval</code> option used during <strong>Subspace</strong> initialization.</p>
<p><strong>Parameters</strong></p>
<ol>
<li><code>callOptions</code> - <code>Object</code> (optional): The options used for calling.<ul>
<li><code>from</code> - <code>String</code> (optional): The address the call “transaction” should be made from.</li>
<li><code>gasPrice</code> - <code>String</code> (optional): The gas price in wei to use for this call “transaction”.</li>
<li><code>gas</code> - <code>Number</code> (optional): The maximum gas provided for this call “transaction” (gas limit).</li>
</ul>
</li>
</ol>
<p><strong>Returns</strong><br><code>RxJS Observable</code> which will stream the function / variable values. Data type will depend on the contract function invoked. </p>
<h3id="myContract-trackBalance-address-tokenAddress"><ahref="#myContract-trackBalance-address-tokenAddress"class="headerlink"title="myContract.trackBalance(address [, tokenAddress])"></a><code>myContract.trackBalance(address [, tokenAddress])</code></h3><p>Track a contract’s balance changes for an address on each block mined, or depending on the <code>callInterval</code> option used during <strong>Subspace</strong> initialization.</p>
<p><strong>Parameters</strong></p>
<ol>
<li><code>address</code> - <code>String</code>: The address to get the balance of.</li>
<li><code>tokenAddress</code> - <code>String</code> (optional): If you want to track the balance for an ERC20 contract, here you can specify the token address. Otherwise, Only ETH balances will be returned.</li>
</ol>
<p><strong>Returns</strong><br><code>RxJS Observable</code> which will stream a string containing the address balance.</p>
<h2id="Blocks-gas-price-and-block-time"><ahref="#Blocks-gas-price-and-block-time"class="headerlink"title="Blocks, gas price and block time"></a>Blocks, gas price and block time</h2><h3id="trackBlock"><ahref="#trackBlock"class="headerlink"title="trackBlock()"></a><code>trackBlock()</code></h3><p>Receive the block information for any new block. It’s the reactive equivalent to <code>web3.eth.getBlock("latest")</code>.</p>
<p><strong>Returns</strong><br><code>RxJS Observable</code> which will stream a block object for the latest block received</p>
<h3id="trackBlockNumber"><ahref="#trackBlockNumber"class="headerlink"title="trackBlockNumber()"></a><code>trackBlockNumber()</code></h3><p>Returns the latest block number. It’s the reactive equivalent to <code>web3.eth.getBlockNumber</code>.</p>
<p><strong>Returns</strong><br><code>RxJS Observable</code> with the latest block number</p>
<h3id="trackGasPrice"><ahref="#trackGasPrice"class="headerlink"title="trackGasPrice()"></a><code>trackGasPrice()</code></h3><p>Returns the current gas price oracle. It’s the reactive equivalent to <code>web3.eth.getGasPrice</code>.</p>
<p><strong>Returns</strong><br><code>RxJS Observable</code> with the average gas price in wei.</p>
<h3id="trackAverageBlocktime"><ahref="#trackAverageBlocktime"class="headerlink"title="trackAverageBlocktime()"></a><code>trackAverageBlocktime()</code></h3><p>Average block time of the last 10 blocks.</p>
<p><strong>Returns</strong><br><code>RxJS Observable</code> with the moving average block time of the last 10 blocks. The time is returned in milliseconds:</p>
<h2id="Low-level-API-for-data-tracking"><ahref="#Low-level-API-for-data-tracking"class="headerlink"title="Low level API for data tracking"></a>Low level API for data tracking</h2><p>These are used in case you don’t want to decorate your web3 contract objects, or if you want to track the balance for an specific address.</p>
<h3id="trackEvent-contractObject-eventName-options"><ahref="#trackEvent-contractObject-eventName-options"class="headerlink"title="trackEvent(contractObject, eventName [, options])"></a><code>trackEvent(contractObject, eventName [, options])</code></h3><p>Track a contract event.</p>
<p><strong>Parameters</strong></p>
<ol>
<li><code>contractObject</code> - <code>web3.eth.Contract</code>: An already initialized contract object pointing to an address and containing a valid ABI.</li>
<li><code>eventName</code> - <code>String</code>: The name of the event to subscribe.</li>
<li><code>options</code> - <code>Object</code> (optional): web3 filter options object to limit the number of events based on a block number range, or indexed filters<ul>
<li><code>filter</code> - <code>Object</code> (optional): Lets you filter events by indexed parameters, e.g. <code>{filter: {myNumber: [12,13]}}</code> means all events where <code>"myNumber"</code> is <code>12</code> or <code>13</code>.</li>
<li><code>fromBlock</code> - <code>Number</code> (optional): The block number from which to get events on.</li>
<li><code>toBlock</code> - <code>Number</code> (optional): The block number to get events up to (Defaults to <code>"latest"</code>)</li>
<li><code>topics</code> - <code>Array</code> (optional): This allows you to manually set the topics for the event filter. If given the filter property and event signature, (<code>topic[0]</code>) will not be set automatically.</li>
</ul>
</li>
</ol>
<p><strong>Returns</strong><br><code>RxJS Observable</code> which will stream the event <code>returnValues</code>.</p>
<h3id="trackProperty-contractObject-functionName-functionArgs-callOptions"><ahref="#trackProperty-contractObject-functionName-functionArgs-callOptions"class="headerlink"title="trackProperty(contractObject, functionName [, functionArgs] [, callOptions])"></a><code>trackProperty(contractObject, functionName [, functionArgs] [, callOptions])</code></h3><p>Track a constant function / contract state variable on each block mined, or depending on the <code>callInterval</code> option used during <strong>Subspace</strong> initialization.</p>
<p><strong>Parameters</strong></p>
<ol>
<li><code>contractObject</code> - <code>web3.eth.Contract</code>: An already initialized contract object pointing to an address and containing a valid ABI.</li>
<li><code>functionName</code> - <code>String</code>: Name of the function or variable whose values will be tracked.</li>
<li><code>functionArgs</code> - <code>Array</code> (optional): Array of arguments that the tracked function receives</li>
<li><code>callOptions</code> - <code>Object</code> (optional): The options used for calling.<ul>
<li><code>from</code> - <code>String</code> (optional): The address the call “transaction” should be made from.</li>
<li><code>gasPrice</code> - <code>String</code> (optional): The gas price in wei to use for this call “transaction”.</li>
<li><code>gas</code> - <code>Number</code> (optional): The maximum gas provided for this call “transaction” (gas limit).</li>
</ul>
</li>
</ol>
<p><strong>Returns</strong><br><code>RxJS Observable</code> which will stream the function / variable values. Data type will depend on the contract function invoked. </p>
<h3id="trackBalance-address-tokenAddress"><ahref="#trackBalance-address-tokenAddress"class="headerlink"title="trackBalance(address [, tokenAddress])"></a><code>trackBalance(address [, tokenAddress])</code></h3><p>Track balance changes for an address on each block mined, or depending on the <code>callInterval</code> option used during <strong>Subspace</strong> initialization.</p>
<p><strong>Parameters</strong></p>
<ol>
<li><code>address</code> - <code>String</code>: The address to get the balance of.</li>
<li><code>tokenAddress</code> - <code>String</code> (optional): If you want to track the balance for an ERC20 contract, here you can specify the token address. Otherwise, Only ETH balances will be returned.</li>
</ol>
<p><strong>Returns</strong><br><code>RxJS Observable</code> which will stream a string containing the address balance.</p>
<h3id="trackLogs-options-abi"><ahref="#trackLogs-options-abi"class="headerlink"title="trackLogs(options [, abi])"></a><code>trackLogs(options [, abi])</code></h3><p>Tracks incoming logs, filtered by the given options.</p>
<p><strong>Parameters</strong></p>
<ol>
<li><code>options</code> - <code>Object</code> (optional): web3 filter options object to limit the number of logs<ul>
<li><code>address</code> - <code>String|Array</code> (optional): An address or a list of addresses to only get logs from particular account(s).</li>
<li><code>fromBlock</code> - <code>Number</code> (optional): The block number from which to get events on.</li>
<li><code>topics</code> - <code>Array</code> (optional): An array of values which must each appear in the log entries. The order is important, if you want to leave topics out use null, e.g. [null, ‘0x00…’]. You can also pass another array for each topic with options for that topic e.g. [null, [‘option1’, ‘option2’]].</li>
</ul>
</li>
<li><code>abi</code> - <code>Array</code> (optional): Array containing the ABI for the inputs of the logs received. It will automatically decode the logs using this ABI instead of returning the hexadecimal data.</li>
</ol>
<p><strong>Returns</strong><br><code>RxJS Observable</code> which will stream the logs. If the inputs ABI is included in the call, the logs will be automatically decoded.</p>