5.7.1 Java  Script Types loader.mjs Account Handles Contract Handles Network Utilities Provider Selection Utilities ask.mjs
On this page:
get  Network  Time
wait  Until  Time
get  Network  Secs
wait  Until  Secs
set  Query  Lower  Bound
set  Valid  Query  Window Network Utilities

These functions interact with the consensus network itself.

getNetworkTime() => Promise<time>

Returns a Promise for the current consensus network time, represented as a BigNumber.

waitUntilTime(time, onProgress?) => Promise<time>

Returns a Promise that will only be resolved after the specified consensus network time. In isolated testing modes, this will also force time to pass on the network, usually by sending trivial transactions. An isolated testing mode is a REACH_CONNECTOR_MODE that matches $NET-devnet for all valid $NET, or when REACH_ISOLATED_NETWORK is set.

You may provide an optional onProgress callback, used for reporting progress, which may be called many times up until the specified network time. It will receive an object with keys current and target,

getNetworkSecs() => Promise<secs>

Like getNetworkTime, but returns a network seconds Promise.

waitUntilSecs(secs, onProgress?) => Promise<secs>

Like waitUntilSecs, but waits for a certain network seconds deadline.

wait(timedelta, onProgress?) => Promise<networkTime>

Returns a Promise that will only be resolved after the specified time delta has elapsed. The expression await wait(delta, onProgress) is the same as await waitUntilTime(add(await getNetworkTime(), delta), onProgress). As with waitUntilTime, the onProgress callback is optional.

connector : Connector 

Represents the Connector the stdlib uses.

setQueryLowerBound(networkTime) => void

Sets the lower bound on querying the network for events. The argument to this function is a network time. By default, Reach will query for events from time 0. This default is usually fine, but on certain networks like Conflux, it can be very slow. You can use this function to tell Reach to only query from a given network time onwards, which can speed up event log querying significantly on Conflux. If you use the reach stdlib to deploy or attach to a contract, the specified lower bound must be no later than the time at which the contract was deployed.

setValidQueryWindow(width: number|true) => void

Sets the maximum width of the query windows used to query the network for event logs. The value true indicates that no window size should be used, and queries may span arbitrarily large window sizes. While each connector has a default value that works for most common cases, tweaking this setting may be useful when dealing with layer two networks or custom endpoints that are more restrictive than normal nodes on the network.