A BrowserProvider is intended to wrap an injected provider which adheres to the EIP-1193 standard, which most (if not all) currently do.

Extends

Constructors

new BrowserProvider()

new BrowserProvider(ethereum, network?): BrowserProvider

Connect to the ethereum provider, optionally forcing the network.

Parameters

ParameterTypeDescription
ethereumEip1193ProviderThe EIP-1193 provider.
network?NetworkishThe network to connect to.

Returns

BrowserProvider

Overrides

JsonRpcApiProvider.constructor

Source

providers/provider-browser.ts:72

Accessors

connect

get connect(): FetchRequest[]

Get the list of connected FetchRequests.

Returns

FetchRequest[]

The list of connected FetchRequests.

Source

providers/abstract-provider.ts:1026


destroyed

get destroyed(): boolean

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:2545


paused

get paused(): boolean

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:2577


pollingInterval

get pollingInterval(): number

Get the polling interval.

Returns

number

The polling interval.

Source

providers/abstract-provider.ts:1183


provider

get provider(): this

Returns this, to allow an AbstractProvider to implement the Contract Runner interface.

Returns

this

The provider instance.

Source

providers/abstract-provider.ts:1193


ready

get ready(): boolean

Returns true only if the JsonRpcApiProvider._start | _start has been called.

Returns

boolean

True if the provider is ready.

Source

providers/provider-jsonrpc.ts:1117

Methods

_clearTimeout()

_clearTimeout(timerId): void

Clear a timer created using the AbstractProvider._setTimeout | _setTimeout method.

Parameters

ParameterTypeDescription
timerIdnumberThe ID of the timer to clear.

Returns

void

Inherited from

JsonRpcApiProvider._clearTimeout

Source

providers/abstract-provider.ts:2221


destroy()

destroy(): void

Destroys the provider, stopping all processing and canceling all pending requests.

Returns

void

Inherited from

JsonRpcApiProvider.destroy

Source

providers/provider-jsonrpc.ts:1587


getActiveRegions()

getActiveRegions(): Promise<Shard[]>

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:1110


getActiveZones()

getActiveZones(): Promise<Zone[]>

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:1127


getLatestQiToQuaiRate()

getLatestQiToQuaiRate(zone, amt?): Promise<bigint>

Get the latest Qi rate for a zone.

Parameters

ParameterTypeDescription
zoneZoneThe zone to get the rate for.
amt?bigintThe amount to get the rate for. Default is 1

Returns

Promise<bigint>

A promise that resolves to the latest Qi rate.

Inherited from

JsonRpcApiProvider.getLatestQiToQuaiRate

Source

providers/abstract-provider.ts:1149


getLatestQuaiToQiRate()

getLatestQuaiToQiRate(zone, amt?): Promise<bigint>

Get the latest Quai rate for a zone.

Parameters

ParameterTypeDescription
zoneZoneThe zone to get the rate for.
amt?bigintThe 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.getLatestQuaiToQiRate

Source

providers/abstract-provider.ts:1068


getProtocolExpansionNumber()

getProtocolExpansionNumber(): Promise<number>

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:1101


getQiToQuaiRateAtBlock()

getQiToQuaiRateAtBlock(
   zone, 
   blockTag, 
amt?): Promise<bigint>

Get the Qi rate at a specific block.

Parameters

ParameterTypeDescription
zoneZoneThe zone to get the rate for.
blockTagBlockTagThe block tag to get the rate at.
amt?bigintThe 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.getQiToQuaiRateAtBlock

Source

providers/abstract-provider.ts:1162


getQuaiToQiRateAtBlock()

getQuaiToQiRateAtBlock(
   zone, 
   blockTag, 
amt?): Promise<bigint>

Get the Quai rate at a specific block.

Parameters

ParameterTypeDescription
zoneZoneThe zone to get the rate for.
blockTagBlockTagThe block tag to get the rate at.
amt?bigintThe 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.getQuaiToQiRateAtBlock

Source

providers/abstract-provider.ts:1081


getRpcError()

getRpcError(payload, error): Error

Gets the RPC error.

Parameters

ParameterTypeDescription
payloadJsonRpcPayloadThe JSON-RPC payload.
errorJsonRpcErrorThe JSON-RPC error.

Returns

Error

The RPC error.

Overrides

JsonRpcApiProvider.getRpcError

Source

providers/provider-browser.ts:162


getSigner()

getSigner(address?): Promise<JsonRpcSigner>

Gets the signer for the given address.

Parameters

ParameterTypeDescription
address?string | numberThe address to get the signer for.

Returns

Promise<JsonRpcSigner>

The signer for the address.

Overrides

JsonRpcApiProvider.getSigner

Source

providers/provider-browser.ts:185


hasSigner()

hasSigner(address): Promise<boolean>

Resolves to true if the provider manages the address.

Parameters

ParameterTypeDescription
addressstring | numberThe address to check.

Returns

Promise<boolean>

Resolves to true if the provider manages the address.

Source

providers/provider-browser.ts:101


initialize()

initialize<U>(urls): Promise<void>

Initialize the URL map with the provided URLs.

Type parameters

Type parameterValue
Ustring[] | FetchRequest

Parameters

ParameterTypeDescription
urlsUThe URLs to initialize the map with.

Returns

Promise<void>

A promise that resolves when the map is initialized.

Inherited from

JsonRpcApiProvider.initialize

Source

providers/abstract-provider.ts:874


listAccounts()

listAccounts(): Promise<JsonRpcSigner[]>

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:1579


pause()

pause(dropWhilePaused?): void

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

ParameterTypeDescription
dropWhilePaused?booleanWhether to drop events while paused.

Returns

void

Inherited from

JsonRpcApiProvider.pause

Source

providers/abstract-provider.ts:2598


resume()

resume(): void

Resume the provider.

Returns

void

Inherited from

JsonRpcApiProvider.resume

Source

providers/abstract-provider.ts:2627


send()

send(
   method, 
   params, 
shard?): Promise<any>

Sends a JSON-RPC request.

Parameters

ParameterTypeDescription
methodstringThe method name.
paramsany[] | Record<string, any>The parameters for the method.
shard?Shard-

Returns

Promise<any>

The result of the request.

Overrides

JsonRpcApiProvider.send

Source

providers/provider-browser.ts:122


shardFromHash()

shardFromHash(hash): Shard

Get the shard from a hash.

Parameters

ParameterTypeDescription
hashstringThe hash to get the shard from.

Returns

Shard

The shard.

Inherited from

JsonRpcApiProvider.shardFromHash

Source

providers/abstract-provider.ts:1047


zoneFromAddress()

zoneFromAddress(_address): Promise<Zone>

Get the zone from an address.

Parameters

ParameterTypeDescription
_addressAddressLikeThe 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:1036


zoneFromHash()

zoneFromHash(hash): Zone

Get the zone from a hash.

Parameters

ParameterTypeDescription
hashstringThe hash to get the zone from.

Returns

Zone

The zone.

Inherited from

JsonRpcApiProvider.zoneFromHash

Source

providers/abstract-provider.ts:1057