Skip to main content

providers

Index

Namespaces

http

http:

HttpProvider

Re-exports HttpProvider

default

Renames and re-exports HttpProvider

HttpProviderOptions

HttpProviderOptions:

providerOptions

providerOptions: RequestInit

ws

ws:

WebSocketProvider

default

Renames and re-exports WebSocketProvider

Enumerations

Eip6963EventName

Eip6963EventName:

eip6963announceProvider

eip6963announceProvider: eip6963:announceProvider

eip6963requestProvider

eip6963requestProvider: eip6963:requestProvider

Classes

abstractEip1193Provider

Eip1193Provider<API>:

This is an abstract class, which extends Web3BaseProvider class. This class is used to implement a provider that adheres to the EIP-1193 standard for Ethereum providers.


Type parameters

constructor

[symbol]

  • get [symbol](): boolean
  • Returns boolean

asEIP1193Provider

  • Modify the return type of the request method to be fully compatible with EIP-1193

    [deprecated] In the future major releases (&gt;= v5) all providers are supposed to be fully compatible with EIP-1193. So this method will not be needed and would not be available in the future.

    @example
    const provider = new Web3HttpProvider('http://localhost:8545');
    const fullyCompatibleProvider = provider.asEIP1193Provider();
    const result = await fullyCompatibleProvider.request({ method: 'eth_getBalance' });
    console.log(result); // '0x0234c8a3397aab58' or something like that

    Returns Eip1193Compatible<API>

    A new instance of the provider with the request method fully compatible with EIP-1193

abstractconnect

  • connect(): void
  • Returns void

abstractdisconnect

  • disconnect(code?: number, data?: string): void
  • Parameters

    • optionalcode: number
    • optionaldata: string

    Returns void

abstractgetStatus

abstracton

abstractonce

optionalabstractremoveAllListeners

  • removeAllListeners(type: string): void
  • Parameters

    • type: string

    Returns void

abstractremoveListener

abstractrequest

abstractreset

  • reset(): void
  • Returns void

send

  • @deprecated

    Please use .request instead.


    Type parameters

    Parameters

    Returns void

sendAsync

abstractsupportsSubscriptions

  • supportsSubscriptions(): boolean
  • Returns boolean

staticisWeb3Provider

  • isWeb3Provider(provider: unknown): boolean
  • Parameters

    • provider: unknown

    Returns boolean

abstractSocketProvider

SocketProvider<MessageEvent, CloseEvent, ErrorEvent, API>:

This is an abstract class, which extends Web3BaseProvider class. This class is used to implement a provider that adheres to the EIP-1193 standard for Ethereum providers.


Type parameters

constructor

  • new SocketProvider<MessageEvent, CloseEvent, ErrorEvent, API>(socketPath: string, socketOptions?: unknown, reconnectOptions?: Partial<ReconnectOptions>): SocketProvider<MessageEvent, CloseEvent, ErrorEvent, API>
  • This is an abstract class for implementing a socket provider (e.g. WebSocket, IPC). It extends the EIP-1193 provider EIP1193Provider.


    Type parameters

    Parameters

    • socketPath: string

      The path to the socket (e.g. /ipc/path or ws://localhost:8546)

    • optionalsocketOptions: unknown

      The options for the socket connection. Its type is supposed to be specified in the inherited classes.

    • optionalreconnectOptions: Partial<ReconnectOptions>

      The options for the socket reconnection ReconnectOptions

    Returns SocketProvider<MessageEvent, CloseEvent, ErrorEvent, API>

SocketConnection

  • get SocketConnection(): unknown
  • Returns unknown

[symbol]

  • get [symbol](): boolean
  • Returns boolean

asEIP1193Provider

  • Modify the return type of the request method to be fully compatible with EIP-1193

    [deprecated] In the future major releases (&gt;= v5) all providers are supposed to be fully compatible with EIP-1193. So this method will not be needed and would not be available in the future.

    @example
    const provider = new Web3HttpProvider('http://localhost:8545');
    const fullyCompatibleProvider = provider.asEIP1193Provider();
    const result = await fullyCompatibleProvider.request({ method: 'eth_getBalance' });
    console.log(result); // '0x0234c8a3397aab58' or something like that

    Returns Eip1193Compatible<API>

    A new instance of the provider with the request method fully compatible with EIP-1193

clearQueues

connect

  • connect(): void
  • Try to establish a connection to the socket


    Returns void

disconnect

  • disconnect(code?: number, data?: string): void
  • Disconnects the socket


    Parameters

    • optionalcode: number

      The code to be sent to the server

    • optionaldata: string

      The data to be sent to the server

    Returns void

getPendingRequestQueueSize

  • getPendingRequestQueueSize(): number

  • Returns number

    the pendingRequestQueue size

getSentRequestsQueueSize

  • getSentRequestsQueueSize(): number

  • Returns number

    the sendPendingRequests size

abstractgetStatus

on

  • Registers a listener for the specified event type.


    Parameters

    Returns void

once

  • Registers a listener for the specified event type that will be invoked at most once.


    Parameters

    Returns void

removeAllListeners

  • removeAllListeners(type: string): void
  • Removes all listeners for the specified event type.


    Parameters

    • type: string

      The event type to remove the listeners for

    Returns void

removeListener

  • Removes a listener for the specified event type.


    Parameters

    Returns void

request

reset

  • reset(): void
  • Resets the socket, removing all listeners and pending requests


    Returns void

safeDisconnect

  • safeDisconnect(code?: number, data?: string, forceDisconnect?: boolean, ms?: number): Promise<void>
  • Safely disconnects the socket, async and waits for request size to be 0 before disconnecting


    Parameters

    • optionalcode: number

      The code to be sent to the server

    • optionaldata: string

      The data to be sent to the server

    • optionalforceDisconnect: boolean

      If true, will clear queue after 5 attempts of waiting for both pending and sent queue to be 0

    • optionalms: number

      Determines the ms of setInterval

    Returns Promise<void>

send

  • @deprecated

    Please use .request instead.


    Type parameters

    Parameters

    Returns void

sendAsync

supportsSubscriptions

  • supportsSubscriptions(): boolean

  • Returns boolean

    true if the socket supports subscriptions

staticisWeb3Provider

  • isWeb3Provider(provider: unknown): boolean
  • Parameters

    • provider: unknown

    Returns boolean

Interfaces

EIP6963AnnounceProviderEvent

EIP6963AnnounceProviderEvent<API>:

Type parameters

detail

type

type: eip6963announceProvider

EIP6963ProviderDetail

EIP6963ProviderDetail<API>:

Type parameters

info

provider

provider: EIP1193Provider<API>

EIP6963ProviderInfo

EIP6963ProviderInfo:

icon

icon: string

name

name: string

rdns

rdns: string

uuid

uuid: string

EIP6963ProvidersMapUpdateEvent

EIP6963ProvidersMapUpdateEvent:

detail

type

type: string

EIP6963RequestProviderEvent

EIP6963RequestProviderEvent:

type

type: eip6963requestProvider

Type Aliases

EIP6963ProviderResponse

EIP6963ProviderResponse: Map<string, EIP6963ProviderDetail>

Variables

consteip6963ProvidersMap

eip6963ProvidersMap: EIP6963ProviderResponse = ...

constweb3ProvidersMapUpdated

web3ProvidersMapUpdated: web3:providersMapUpdated = 'web3:providersMapUpdated'

Functions

onNewProviderDiscovered

requestEIP6963Providers