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.

exception Connection_closed
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 timeout = {
  1. timeout : float;
  2. on_timeout : [ `Retry of int | `Retry_forever | `Fail ];
}
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 create : ?monitoring:monitoring -> ?keep_alive:bool -> Tezos_rpc_http.Media_type.t -> Uri.t -> t

create ?monitoring ?keep_alive media uri creates an EVM node websocket client 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. If keep_alive is true (the default), requests will be retried (and the connection reestablished) if the connection is dropped.

val client_id : t -> int

A uniquely identifying id for a websocket client.

val connect : t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

connect client establishes the websocket connection with client. NOTE: the connection is established automatically when sending a request.

val disconnect : t -> unit Lwt.t

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

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

Send a raw JSON RPC request on the websocket.

val send_jsonrpc : t -> ?timeout:timeout -> ('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.