IpcProvider <API>
Hierarchy
- SocketProvider<Uint8Array | string, CloseEvent, Error, API>
- IpcProvider
Index
Constructors
publicconstructor
This is a class used for IPC connections. It extends the abstract class SocketProvider SocketProvider that extends the EIP-1193 provider EIP1193Provider.
Type parameters
- API: unknown = EthExecutionAPI
Parameters
socketPath: string
The path to the IPC socket.
optionalsocketOptions: SocketConstructorOpts
The options for the IPC socket connection.
optionalreconnectOptions: Partial<ReconnectOptions>
The options for the socket reconnection ReconnectOptions
Returns default<API>
Accessors
SocketConnection
Returns unknown
[symbol]
Returns boolean
Methods
asEIP1193Provider
Modify the return type of the request method to be fully compatible with EIP-1193
[deprecated] In the future major releases (>= 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.
Returns Eip1193Compatible<API>
A new instance of the provider with the request method fully compatible with EIP-1193
clearQueues
Parameters
optionalevent: ConnectionEvent
Returns void
connect
Try to establish a connection to the socket
Returns void
disconnect
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
Returns number
the pendingRequestQueue size
getSentRequestsQueueSize
Returns number
the sendPendingRequests size
publicgetStatus
Returns Web3ProviderStatus
on
Registers a listener for the specified event type.
Parameters
type: disconnect
The event type to listen for
listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>
The callback to be invoked when the event is emitted
Returns void
once
Registers a listener for the specified event type that will be invoked at most once.
Parameters
type: disconnect
The event type to listen for
listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>
The callback to be invoked when the event is emitted
Returns void
removeAllListeners
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
type: disconnect
The event type to remove the listener for
listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>
The callback to be executed
Returns void
request
Creates a request object to be sent to the server
Type parameters
- Method: string
- ResultType = Web3APIReturnType<API, Method>
Parameters
request: Web3APIPayload<API, Method>
Returns Promise<JsonRpcResponseWithResult<ResultType>>
reset
Resets the socket, removing all listeners and pending requests
Returns void
safeDisconnect
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
Type parameters
- ResultType = JsonRpcResult
- P = unknown
Parameters
payload: JsonRpcPayload<P>
Request Payload
callback: (err: null | Error, response?: JsonRpcResponse<ResultType, JsonRpcResult>) => void
Callback
Returns void
sendAsync
Type parameters
- R = JsonRpcResult
- P = unknown
Parameters
payload: JsonRpcPayload<P>
Request Payload
Returns Promise<JsonRpcResponse<R, JsonRpcResult>>
supportsSubscriptions
Returns boolean
true
if the socket supports subscriptions
staticisWeb3Provider
Parameters
provider: unknown
Returns boolean
The IPC Provider could be used in node.js dapps when running a local node. And it provide the most secure connection.
The second and the third parameters are both optional. And you can for example, the second parameter could be an empty object or undefined. *