Class WrappedBrowserProvider

Hierarchy

  • BrowserProvider
    • WrappedBrowserProvider

Constructors

  • Parameters

    • ethereum: Eip1193Provider
    • Optionalnetwork: Networkish
    • Optional_options: BrowserProviderOptions

    Returns WrappedBrowserProvider

Properties

ethereumProvider: undefined | EIP1193Provider

Accessors

  • get pollingInterval(): number
  • The polling interval (default: 4000 ms)

    Returns number

  • set pollingInterval(value): void
  • Parameters

    • value: number

    Returns void

  • get _network(): Network
  • Gets the [[Network]] this provider has committed to. On each call, the network is detected, and if it has changed, the call will reject.

    Returns Network

  • get ready(): boolean
  • Returns true only if the [[_start]] has been called.

    Returns boolean

  • get provider(): this
  • Returns this, to allow an AbstractProvider to implement the [[ContractRunner]] interface.

    Returns this

  • get plugins(): AbstractProviderPlugin[]
  • Returns all the registered plug-ins.

    Returns AbstractProviderPlugin[]

  • get disableCcipRead(): boolean
  • Prevent any CCIP-read operation, regardless of whether requested in a [[call]] using enableCcipRead.

    Returns boolean

  • set disableCcipRead(value): void
  • Parameters

    • value: boolean

    Returns void

  • 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

  • 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

  • set paused(pause): void
  • Parameters

    • pause: boolean

    Returns void

Methods

  • 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.

    Parameters

    • method: string
    • params: any[] | Record<string, any>

    Returns Promise<any>

  • Sends a JSON-RPC %%payload%% (or a batch) to the underlying channel.

    Sub-classes MUST override this.

    Parameters

    • payload: JsonRpcPayload | JsonRpcPayload[]

    Returns Promise<(JsonRpcResult | JsonRpcError)[]>

  • Returns an ethers-style Error for the given JSON-RPC error %%payload%%, coalescing the various strings and error shapes that different nodes return, coercing them into a machine-readable standardized error.

    Parameters

    • payload: JsonRpcPayload
    • error: JsonRpcError

    Returns Error

  • Resolves to true if the provider manages the %%address%%.

    Parameters

    • address: string | number

    Returns Promise<boolean>

  • 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).

    Throws if the account doesn't exist.

    Parameters

    • Optionaladdress: string | number

    Returns Promise<JsonRpcSigner>

  • Return a Subscriber that will manage the %%sub%%.

    Sub-classes may override this to modify the behavior of subscription management.

    Parameters

    • sub: Subscription

    Returns Subscriber

  • Returns the value associated with the option %%key%%.

    Sub-classes can use this to inquire about configuration options.

    Type Parameters

    • K extends keyof JsonRpcApiProviderOptions

    Parameters

    • key: K

    Returns JsonRpcApiProviderOptions[K]

  • Resolves to the non-normalized value by performing %%req%%.

    Sub-classes may override this to modify behavior of actions, and should generally call super._perform as a fallback.

    Parameters

    • req: PerformActionRequest

    Returns Promise<any>

  • Sub-classes may override this; it detects the actual network that we are currently connected to.

    Keep in mind that [[send]] may only be used once [[ready]], otherwise the _send primitive must be used instead.

    Returns Promise<Network>

  • Sub-classes MUST call this. Until [[_start]] has been called, no calls will be passed to [[_send]] from [[send]]. If it is overridden, then super._start() MUST be called.

    Calling it multiple times is safe and has no effect.

    Returns void

  • Resolves once the [[_start]] has been called. This can be used in sub-classes to defer sending data until the connection has been established.

    Returns Promise<void>

  • Returns %%tx%% as a normalized JSON-RPC transaction request, which has all values hexlified and any numeric values converted to Quantity values.

    Parameters

    • tx: TransactionRequest

    Returns JsonRpcTransactionRequest

  • Returns the request method and arguments required to perform %%req%%.

    Parameters

    • req: PerformActionRequest

    Returns null | {
        method: string;
        args: any[];
    }

  • Returns Promise<JsonRpcSigner[]>

  • Sub-classes may use this to shutdown any sockets or release their resources and reject any pending requests.

    Sub-classes must call super.destroy().

    Returns void

  • Attach a new plug-in.

    Parameters

    • plugin: AbstractProviderPlugin

    Returns this

  • Get a plugin by name.

    Type Parameters

    • T extends AbstractProviderPlugin = AbstractProviderPlugin

    Parameters

    • name: string

    Returns null | T

  • Resolves to the data for executing the CCIP-read operations.

    Parameters

    • tx: PerformActionTransaction
    • calldata: string
    • urls: string[]

    Returns Promise<null | string>

  • Provides the opportunity for a sub-class to wrap a block before returning it, to add additional properties or an alternate sub-class of [[Block]].

    Parameters

    • value: BlockParams
    • network: Network

    Returns Block

  • Provides the opportunity for a sub-class to wrap a log before returning it, to add additional properties or an alternate sub-class of [[Log]].

    Parameters

    • value: LogParams
    • network: Network

    Returns Log

  • Provides the opportunity for a sub-class to wrap a transaction receipt before returning it, to add additional properties or an alternate sub-class of [[TransactionReceipt]].

    Parameters

    • value: TransactionReceiptParams
    • network: Network

    Returns TransactionReceipt

  • Provides the opportunity for a sub-class to wrap a transaction response before returning it, to add additional properties or an alternate sub-class of [[TransactionResponse]].

    Parameters

    • tx: TransactionResponseParams
    • network: Network

    Returns TransactionResponse

  • Get the current block number.

    Returns Promise<number>

  • Returns or resolves to the address for %%address%%, resolving ENS names and [[Addressable]] objects and returning if already an address.

    Parameters

    • address: AddressLike

    Returns string | Promise<string>

  • Returns or resolves to a valid block tag for %%blockTag%%, resolving negative values and returning if already a valid block tag.

    Parameters

    • OptionalblockTag: BlockTag

    Returns string | Promise<string>

  • Returns or resolves to a filter for %%filter%%, resolving any ENS names or [[Addressable]] object and returning if already a valid filter.

    Parameters

    • filter: Filter | FilterByBlockHash

    Returns PerformActionFilter | Promise<PerformActionFilter>

  • Returns or resolves to a transaction for %%request%%, resolving any ENS names or [[Addressable]] and returning if already a valid transaction.

    Parameters

    • _request: TransactionRequest

    Returns PerformActionTransaction | Promise<PerformActionTransaction>

  • Get the connected [[Network]].

    Returns Promise<Network>

  • Get the best guess at the recommended [[FeeData]].

    Returns Promise<FeeData>

  • Estimates the amount of gas required to execute %%tx%%.

    Parameters

    • _tx: TransactionRequest

    Returns Promise<bigint>

  • Simulate the execution of %%tx%%. If the call reverts, it will throw a [[CallExceptionError]] which includes the revert data.

    Parameters

    • _tx: TransactionRequest

    Returns Promise<string>

  • Get the account balance (in wei) of %%address%%. If %%blockTag%% is specified and the node supports archive access for that %%blockTag%%, the balance is as of that [[BlockTag]].

    Parameters

    • address: AddressLike
    • OptionalblockTag: BlockTag

    Returns Promise<bigint>

    On nodes without archive access enabled, the %%blockTag%% may be silently ignored by the node, which may cause issues if relied on.

  • Get the number of transactions ever sent for %%address%%, which is used as the nonce when sending a transaction. If %%blockTag%% is specified and the node supports archive access for that %%blockTag%%, the transaction count is as of that [[BlockTag]].

    Parameters

    • address: AddressLike
    • OptionalblockTag: BlockTag

    Returns Promise<number>

    On nodes without archive access enabled, the %%blockTag%% may be silently ignored by the node, which may cause issues if relied on.

  • Get the bytecode for %%address%%.

    Parameters

    • address: AddressLike
    • OptionalblockTag: BlockTag

    Returns Promise<string>

    On nodes without archive access enabled, the %%blockTag%% may be silently ignored by the node, which may cause issues if relied on.

  • Get the storage slot value for %%address%% at slot %%position%%.

    Parameters

    • address: AddressLike
    • _position: BigNumberish
    • OptionalblockTag: BlockTag

    Returns Promise<string>

    On nodes without archive access enabled, the %%blockTag%% may be silently ignored by the node, which may cause issues if relied on.

  • Broadcasts the %%signedTx%% to the network, adding it to the memory pool of any node for which the transaction meets the rebroadcast requirements.

    Parameters

    • signedTx: string

    Returns Promise<TransactionResponse>

  • Resolves to the block for %%blockHashOrBlockTag%%.

    If %%prefetchTxs%%, and the backend supports including transactions with block requests, all transactions will be included and the [[Block]] object will not need to make remote calls for getting transactions.

    Parameters

    • block: BlockTag
    • OptionalprefetchTxs: boolean

    Returns Promise<null | Block>

  • Resolves to the transaction for %%hash%%.

    If the transaction is unknown or on pruning nodes which discard old transactions this resolves to null.

    Parameters

    • hash: string

    Returns Promise<null | TransactionResponse>

  • Resolves to the transaction receipt for %%hash%%, if mined.

    If the transaction has not been mined, is unknown or on pruning nodes which discard old transactions this resolves to null.

    Parameters

    • hash: string

    Returns Promise<null | TransactionReceipt>

  • Resolves to the result returned by the executions of %%hash%%.

    This is only supported on nodes with archive access and with the necessary debug APIs enabled.

    Parameters

    • hash: string

    Returns Promise<null | string>

  • Resolves to the list of Logs that match %%filter%%

    Parameters

    • _filter: Filter | FilterByBlockHash

    Returns Promise<Log[]>

  • Parameters

    • chainId: number

    Returns AbstractProvider

  • Parameters

    • name: string

    Returns Promise<null | EnsResolver>

  • Parameters

    • name: string

    Returns Promise<null | string>

  • Resolves to the address configured for the %%ensName%% or null if unconfigured.

    Parameters

    • name: string

    Returns Promise<null | string>

  • Resolves to the ENS name associated for the %%address%% or null if the //primary name// is not configured.

    Users must perform additional steps to configure a //primary name//, which is not currently common.

    Parameters

    • address: string

    Returns Promise<null | string>

  • Waits until the transaction %%hash%% is mined and has %%confirms%% confirmations.

    Parameters

    • hash: string
    • Optional_confirms: null | number
    • Optionaltimeout: null | number

    Returns Promise<null | TransactionReceipt>

  • Resolves to the block at %%blockTag%% once it has been mined.

    This can be useful for waiting some number of blocks by using the currentBlockNumber + N.

    Parameters

    • OptionalblockTag: BlockTag

    Returns Promise<Block>

  • Clear a timer created using the [[_setTimeout]] method.

    Parameters

    • timerId: number

    Returns void

  • Create a timer that will execute %%func%% after at least %%timeout%% (in ms). If %%timeout%% is unspecified, then %%func%% will execute in the next event loop.

    Pausing the provider will pause any associated timers.

    Parameters

    • _func: (() => void)
        • (): void
        • Returns void

    • Optionaltimeout: number

    Returns number

  • Perform %%func%% on each subscriber.

    Parameters

    • func: ((s: Subscriber) => void)
        • (s): void
        • Parameters

          • s: Subscriber

          Returns void

    Returns void

  • If a [[Subscriber]] fails and needs to replace itself, this method may be used.

    For example, this is used for providers when using the eth_getFilterChanges method, which can return null if state filters are not supported by the backend, allowing the Subscriber to swap in a [[PollingEventSubscriber]].

    Parameters

    • oldSub: Subscriber
    • newSub: Subscriber

    Returns void

  • Registers a %%listener%% that is called whenever the %%event%% occurs until unregistered.

    Parameters

    • event: ProviderEvent
    • listener: Listener

    Returns Promise<WrappedBrowserProvider>

  • Registers a %%listener%% that is called the next time %%event%% occurs.

    Parameters

    • event: ProviderEvent
    • listener: Listener

    Returns Promise<WrappedBrowserProvider>

  • Triggers each listener for %%event%% with the %%args%%.

    Parameters

    • event: ProviderEvent
    • Rest...args: any[]

    Returns Promise<boolean>

  • Resolves to the number of listeners for %%event%%.

    Parameters

    • Optionalevent: ProviderEvent

    Returns Promise<number>

  • Resolves to the listeners for %%event%%.

    Parameters

    • Optionalevent: ProviderEvent

    Returns Promise<Listener[]>

  • Unregister the %%listener%% for %%event%%. If %%listener%% is unspecified, all listeners are unregistered.

    Parameters

    • event: ProviderEvent
    • Optionallistener: Listener

    Returns Promise<WrappedBrowserProvider>

  • Unregister all listeners for %%event%%.

    Parameters

    • Optionalevent: ProviderEvent

    Returns Promise<WrappedBrowserProvider>

  • Alias for [[on]].

    Parameters

    • event: ProviderEvent
    • listener: Listener

    Returns Promise<WrappedBrowserProvider>

  • Alias for [[off]].

    Parameters

    • event: ProviderEvent
    • listener: Listener

    Returns Promise<WrappedBrowserProvider>

  • 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

    • OptionaldropWhilePaused: boolean

    Returns void

  • Resume the provider.

    Returns void

""