One of the most common ways to interact with the blockchain is by a node running a JSON-RPC interface which can be connected to, based on the transport, using:
- HTTP or HTTPS - JsonRpcProvider
- WebSocket - WebSocketProvider
- IPC - IpcSocketProvider
When subscribing to the "debug" event, the Listener will receive this object as the first parameter.
Options for configuring a JsonRpcApiProvider. Much of this is targetted towards sub-classes, which often will not expose any of these options to their consumers.
polling - use the polling strategy is used immediately for events; otherwise, attempt to use filters and fall back onto polling (default: false)
staticNetwork - do not request chain ID on requests to validate the underlying chain has not changed (default: null)
This should ONLY be used if it is certain that the network cannot change, such as when using INFURA (since the URL dictates the network). If the network is assumed static and it does change, this can have tragic consequences. For example, this CANNOT be used with MetaMask, since the user can select a new network from the drop-down at any time.
batchStallTime - how long (ms) to aggregate requests into a single batch. 0 indicates batching will only encompass the current event loop. If batchMaxCount = 1, this is ignored. (default: 10)
batchMaxSize - target maximum size (bytes) to allow per batch request (default: 1Mb)
batchMaxCount - maximum number of requests to allow in a batch. If batchMaxCount = 1, then batching is disabled. (default: 100)
cacheTimeout - passed as AbstractProviderOptions.
Gets the Network this provider has committed to. On each call, the network is detected, and if it has changed, the call will reject.
Resolves once the _start has been called. This can be used in sub-classes to defer sending data until the connection has been established.
Resolves to the Signer account for address managed by the client.
If the address is a number, it is used as an index in the the accounts from listAccounts.
This can only be used on clients which manage accounts (such as Geth with imported account or MetaMask).
Requests the method with params via the JSON-RPC protocol over the underlying channel. This can be used to call methods on the backend that do not have a high-level API within the Provider API.
This method queues requests according to the batch constraints in the options, assigns the request a unique ID.
Do NOT override this method in sub-classes; instead override _send or force the options values in the call to the constructor to modify this method's behavior.
The gas price per wei for transactions prior to EIP-1559.
The maximum fee per gas for EIP-1559 transactions.
The maximum priority fee per gas for EIP-1559 transactions.