2019-08-21 08:53:47 +03:00
|
|
|
_section: Other Providers
|
|
|
|
|
|
|
|
Others...
|
|
|
|
|
2020-02-01 11:39:21 +03:00
|
|
|
_subsection: FallbackProvider @<provider-fallback> @INHERIT<[[provider]]> @SRC<providers/fallback-provider:class.FallbackProvider>
|
2019-08-21 08:53:47 +03:00
|
|
|
|
2020-02-01 11:39:21 +03:00
|
|
|
The **FallbackProvider** is the most advanced [[provider]] available in
|
|
|
|
ethers.
|
2019-08-21 08:53:47 +03:00
|
|
|
|
2020-02-01 11:39:21 +03:00
|
|
|
It uses a quorum and connects to multiple [Providers](provider) as backends,
|
|
|
|
each configured with a //priority// and a //weight// .
|
2019-08-21 08:53:47 +03:00
|
|
|
|
2020-02-01 11:39:21 +03:00
|
|
|
When a request is made, the request is dispatched to multiple backends, randomly
|
|
|
|
choosen (higher prioirty backends are always selected first) and the results from
|
|
|
|
each are compared against the others. Only once the quorum has been reached will that
|
|
|
|
result be accepted and returned to the caller.
|
|
|
|
|
|
|
|
By default the quorum requires 50% (rounded up) of the backends to agree. The //weight//
|
|
|
|
can be used to give a backend Provider more influence.
|
|
|
|
|
|
|
|
_property: new ethers.providers.FallbackProvider(providers [ , quorum ])
|
|
|
|
Creates a new instance of a FallbackProvider connected to //providers//. If
|
|
|
|
quorum is not specified, half of the total sum of the provider weights is
|
|
|
|
used.
|
|
|
|
|
|
|
|
The //providers// can be either an array of [[provider]] or [[provider-fallback-config]].
|
|
|
|
If a [[provider]] is provided, the defaults are a priority of 1 and a weight of 1.
|
|
|
|
|
|
|
|
_property: provider.providerConfigs => Array<[[provider-fallback-config]]>
|
|
|
|
The list of Provider Configurations that describe the backends.
|
2019-08-21 08:53:47 +03:00
|
|
|
|
|
|
|
_property: provider.quorum => number
|
|
|
|
The quorum the backend responses must agree upon before a result will be
|
|
|
|
resolved. By default this is //half the sum of the weights//.
|
|
|
|
|
|
|
|
|
2020-02-01 11:39:21 +03:00
|
|
|
_heading: FallbackProviderConfig @<provider-fallback-config>
|
|
|
|
|
|
|
|
_property: fallbackProviderConfig.provider => [[provider]]
|
|
|
|
The provider for this configuration.
|
|
|
|
|
|
|
|
_property: fallbackProviderConfig.priority => number
|
|
|
|
The priority used for the provider. Higher priorities are favoured over lower
|
|
|
|
priorities. If multiple providers share the same prioirty, they are choosen
|
|
|
|
at random.
|
|
|
|
|
|
|
|
_property: fallbackProviderConfig.stallTimeout => number
|
|
|
|
The timeout (in ms) after which another [[provider]] will be attempted. This
|
|
|
|
does not affect the current Provider; if it returns a result it is counted
|
|
|
|
as part of the quorum.
|
|
|
|
|
|
|
|
Lower values will result in more network traffic, but may reduce the response
|
|
|
|
time of requests.
|
|
|
|
|
|
|
|
_property: fallbackProviderConfig.weight => number
|
|
|
|
The weight a response from this provider provides. This can be used if a given
|
|
|
|
[[provider]] is more trusted, for example.
|
|
|
|
|
|
|
|
|
|
|
|
_subsection: IpcProvider @<provider-ipc> @INHERIT<[[provider-jsonrpc]]> @SRC<providers:class.IpcProvider>
|
|
|
|
|
|
|
|
The **IpcProvider** allows the JSON-RPC API to be used over a local
|
|
|
|
filename on the file system, exposed by Geth, Parity and other nodes.
|
|
|
|
|
|
|
|
This is only available in //node.js// (as it requires file system access,
|
|
|
|
and may have additional complications due to file permissions. See any
|
|
|
|
related notes on the documentation for the actual node implementation websites.
|
|
|
|
|
|
|
|
_property: ipcProvider.path => string
|
|
|
|
The path this [[provider]] is connected to.
|
|
|
|
|
|
|
|
|
|
|
|
_subsection: UrlJsonRpcProvider @<provider-urljsonrpc> @INHERIT<[[provider-jsonrpc]]> @SRC<providers:class.UrlJsonRpcProvider>
|
|
|
|
|
|
|
|
This class is intended to be sub-classed and not used directly. It
|
|
|
|
simplifies creating a [[provider]] where a normal [[provider-jsonrpc]]
|
|
|
|
would suffice, with a little extra effort needed to generate the JSON-RPC
|
|
|
|
URL.
|
|
|
|
|
|
|
|
_property: new ethers.providers.UrlJsonRpcProvider([ network [ , apiKey ] ])
|
|
|
|
Sub-classes do not need to override this. Instead they should override the
|
|
|
|
static method ``getUrl`` and optionally ``getApiKey``.
|
|
|
|
|
|
|
|
_property: urlJsonRpcProvider.apiKey => any
|
|
|
|
The value of the apiKey that was returned from ``InheritedClass.getApiKey``.
|
2019-08-21 08:53:47 +03:00
|
|
|
|
2020-02-01 11:39:21 +03:00
|
|
|
_property: InheritingClass.getApiKey(apiKey) => any
|
|
|
|
This function should examine the //apiKey// to ensure it is valid and
|
|
|
|
return a (possible modified) value to use in ``getUrl``.
|
2019-08-21 08:53:47 +03:00
|
|
|
|
2020-02-01 11:39:21 +03:00
|
|
|
_property: InheritingClass.getUrl(network, apiKey) => string
|
|
|
|
The URL to use for the JsonRpcProvider instance.
|
2019-08-21 08:53:47 +03:00
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
|
|
|
|
|
2020-02-01 11:39:21 +03:00
|
|
|
_subsection: Web3Provider @<provider-web3> @INHERIT<[[provider-jsonrpc]]>
|
2020-01-10 09:01:00 +03:00
|
|
|
|
2020-02-02 15:58:29 +03:00
|
|
|
The Web3Provider is meant to ease moving from a [web3.js based](link-web3)
|
2020-02-01 11:39:21 +03:00
|
|
|
application to ethers by wraping an existing Web3-compatible (such as a
|
2020-02-02 15:58:29 +03:00
|
|
|
[Web3HttpProvider](link-web3-http)[Web3IpcProvider](link-web3-ipc) or
|
|
|
|
[Web3WsProvider](link-web3-ws)) and exposing it as an ethers.js [[provider]]
|
|
|
|
which can then be used with the rest of the library.
|
2020-01-10 09:01:00 +03:00
|
|
|
|
2020-02-01 11:39:21 +03:00
|
|
|
_property: new ethers.providers.Web3Provider(web3Provider [, network ])
|
|
|
|
Create a new **Web3Provider**, which wraps an [EIP-1193 Provider]() or
|
|
|
|
Web3Provider-compatible Provider.
|
2020-01-10 09:01:00 +03:00
|
|
|
|
2020-02-01 11:39:21 +03:00
|
|
|
_property: web3Provider.provider => Web3CompatibleProvider
|
|
|
|
The provider used to create this instance.
|
2020-01-10 09:01:00 +03:00
|
|
|
|