Module Evm_node_lib_dev.Websocket_client

Client to communicate with an EVM node over websockets

type t

Type of client connected to a websocket server.

type 'a subscription = {
  1. stream : 'a Lwt_stream.t;
    (*

    The stream of events.

    *)
  2. unsubscribe : unit -> bool Tezos_base.TzPervasives.tzresult Lwt.t;
    (*

    A function to unsubscribe from events notifications.

    *)
}

Subscriptions returned by subscribe.

type (_, _) call =
  1. | Call : (module Rpc_encodings.METHOD with type input = 'input and type output = 'output) * 'input -> ('input, 'output) call

Wrapper type for calling a JSONRPC method with an input

type monitoring = {
  1. ping_timeout : float;
  2. ping_interval : float;
}
val connect : ?monitoring:monitoring -> Tezos_rpc_http.Media_type.t -> Uri.t -> t Lwt.t

connect ?monitoring media uri connects to an EVM node websocket server on uri, communication is either JSON or binary depending on media. If monitoring is provided, the connection is monitored with the given parameters.

val disconnect : t -> unit Lwt.t

Disconnect the websocket client by sending a close frame and closing the connection.

val send_jsonrpc_request : t -> Rpc_encodings.JSONRPC.request -> Rpc_encodings.JSONRPC.value Lwt.t

Send a raw JSON RPC request on the websocket.

val send_jsonrpc : t -> ('input, 'output) call -> 'output Tezos_base.TzPervasives.tzresult Lwt.t

send_jsonrpc client (Call ((module Method), input)) makes a JSONRPC request with the provided Method and input to the websocket client. It returns the corresponding response.

subscribe client kind creates a subscription of kind with the websocket client. It returns a stream with the notifications and a function to unsubscribe.

subscribe_newHeads client is like subscribe but specialized for newHeads events.

subscribe_newHeadNumbers client is like subscribe_newHeads but only parses numbers in blocks.

subscribe_newPendingTransactions client is like subscribe but specialized for newPendingTransactions events.

subscribe_syncing client is like subscribe but specialized for syncing events.

subscribe_logs ?address ?topics client is like subscribe but specialized for logs events filtered by address and/or topics.

Subscribe to L1/L2 levels associations.