JsonRpcProvider
The JsonRpcProvider is one of the most common Providers, which performs all operations over HTTP (or HTTPS) requests.
Events are processed by polling the backend for the current block number; when it advances, all block-base events are then checked for updates.
Extends
Accessors
connect
Get the list of connected FetchRequests.
Returns
The list of connected FetchRequests.
Source
providers/abstract-provider.ts:839
destroyed
If this provider has been destroyed using the destroy method.
Once destroyed, all resources are reclaimed, internal event loops and timers are cleaned up and no further requests may be sent to the provider.
Returns
boolean
Source
providers/abstract-provider.ts:2158
paused
Whether the provider is currently paused.
A paused provider will not emit any events, and generally should not make any requests to the network, but that is up to sub-classes to manage.
Setting paused = true
is identical to calling .pause(false)
, which will buffer any events that occur while
paused until the provider is unpaused.
Returns
boolean
Whether the provider is paused.
Source
providers/abstract-provider.ts:2190
pollingInterval
Get the polling interval.
Returns
number
The polling interval.
Source
providers/abstract-provider.ts:996
provider
Returns this
, to allow an AbstractProvider to implement the Contract Runner
interface.
Returns
this
The provider instance.
Source
providers/abstract-provider.ts:1006
ready
Returns true only if the JsonRpcApiProvider._start | _start has been called.
Returns
boolean
True if the provider is ready.
Source
providers/provider-jsonrpc.ts:1079
Methods
_clearTimeout()
Clear a timer created using the AbstractProvider._setTimeout | _setTimeout method.
Parameters
Parameter | Type | Description |
---|---|---|
timerId | number | The ID of the timer to clear. |
Returns
void
Inherited from
JsonRpcApiProvider
._clearTimeout
Source
providers/abstract-provider.ts:1861
destroy()
Destroys the provider, stopping all processing and canceling all pending requests.
Returns
void
Inherited from
Source
providers/provider-jsonrpc.ts:1534
getActiveRegions()
Get the active region shards based on the protocol expansion number.
Returns
Promise
<Shard
[]>
A promise that resolves to the active shards.
Inherited from
JsonRpcApiProvider
.getActiveRegions
Source
providers/abstract-provider.ts:923
getActiveZones()
Get the active zones for a shard based on the protocol expansion number.
Returns
Promise
<Zone
[]>
A promise that resolves to the active zones.
Inherited from
JsonRpcApiProvider
.getActiveZones
Source
providers/abstract-provider.ts:940
getLatestQiRate()
Get the latest Qi rate for a zone.
Parameters
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to get the rate for. |
amt ? | bigint | The amount to get the rate for. Default is 1 |
Returns
Promise
<bigint
>
A promise that resolves to the latest Qi rate.
Inherited from
JsonRpcApiProvider
.getLatestQiRate
Source
providers/abstract-provider.ts:962
getLatestQuaiRate()
Get the latest Quai rate for a zone.
Parameters
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to get the rate for. |
amt ? | bigint | The amount in quais to get the rate for. Default is 1 |
Returns
Promise
<bigint
>
A promise that resolves to the latest Quai -> Qi rate for the given amount.
Inherited from
JsonRpcApiProvider
.getLatestQuaiRate
Source
providers/abstract-provider.ts:881
getProtocolExpansionNumber()
Get the protocol expansion number.
Returns
Promise
<number
>
A promise that resolves to the protocol expansion number.
Inherited from
JsonRpcApiProvider
.getProtocolExpansionNumber
Source
providers/abstract-provider.ts:914
getQiRateAtBlock()
Get the Qi rate at a specific block.
Parameters
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to get the rate for. |
blockTag | BlockTag | The block tag to get the rate at. |
amt ? | bigint | The amount to get the rate for. Default is 1 |
Returns
Promise
<bigint
>
A promise that resolves to the Qi rate at the specified block.
Inherited from
JsonRpcApiProvider
.getQiRateAtBlock
Source
providers/abstract-provider.ts:975
getQuaiRateAtBlock()
Get the Quai rate at a specific block.
Parameters
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to get the rate for. |
blockTag | BlockTag | The block tag to get the rate at. |
amt ? | bigint | The amount to get the rate for. Default is 1 |
Returns
Promise
<bigint
>
A promise that resolves to the Quai rate at the specified block.
Inherited from
JsonRpcApiProvider
.getQuaiRateAtBlock
Source
providers/abstract-provider.ts:894
getSigner()
Returns a JsonRpcSigner for the given address.
Parameters
Parameter | Type | Description |
---|---|---|
address ? | string | number | The address or index of the account. |
Returns
Promise
<JsonRpcSigner
>
A promise that resolves to the JsonRpcSigner.
Inherited from
Throws
If the account is invalid.
Source
providers/provider-jsonrpc.ts:1489
initialize()
Initialize the URL map with the provided URLs.
Type parameters
Type parameter | Value |
---|---|
U | string [] | FetchRequest |
Parameters
Parameter | Type | Description |
---|---|---|
urls | U | The URLs to initialize the map with. |
Returns
Promise
<void
>
A promise that resolves when the map is initialized.
Inherited from
Source
providers/abstract-provider.ts:787
listAccounts()
Returns a list of JsonRpcSigners for all accounts.
Returns
Promise
<JsonRpcSigner
[]>
A promise that resolves to an array of JsonRpcSigners.
Inherited from
JsonRpcApiProvider
.listAccounts
Source
providers/provider-jsonrpc.ts:1526
pause()
Pause the provider. If dropWhilePaused
, any events that occur while paused are dropped, otherwise all events
will be emitted once the provider is unpaused.
Parameters
Parameter | Type | Description |
---|---|---|
dropWhilePaused ? | boolean | Whether to drop events while paused. |
Returns
void
Inherited from
Source
providers/abstract-provider.ts:2211
resume()
Resume the provider.
Returns
void
Inherited from
Source
providers/abstract-provider.ts:2240
shardFromHash()
Get the shard from a hash.
Parameters
Parameter | Type | Description |
---|---|---|
hash | string | The hash to get the shard from. |
Returns
The shard.
Inherited from
JsonRpcApiProvider
.shardFromHash
Source
providers/abstract-provider.ts:860
zoneFromAddress()
Get the zone from an address.
Parameters
Parameter | Type | Description |
---|---|---|
_address | AddressLike | The address to get the zone from. |
Returns
Promise
<Zone
>
A promise that resolves to the zone.
Inherited from
JsonRpcApiProvider
.zoneFromAddress
Source
providers/abstract-provider.ts:849
zoneFromHash()
Get the zone from a hash.
Parameters
Parameter | Type | Description |
---|---|---|
hash | string | The hash to get the zone from. |
Returns
The zone.
Inherited from
JsonRpcApiProvider
.zoneFromHash
Source
Was this page helpful?