Ethereumex.WebsocketClient (ethereumex v0.11.0)

View Source

WebSocket-based Ethereum JSON-RPC client implementation.

This module provides a WebSocket client interface for Ethereum JSON-RPC calls by:

  1. Inheriting the standard JSON-RPC method definitions from BaseClient
  2. Implementing request handling through a persistent WebSocket connection

Usage

iex> Ethereumex.WebsocketClient.eth_block_number()
{:ok, "0x1234"}

iex> Ethereumex.WebsocketClient.eth_get_balance("0x407d73d8a49eeb85d32cf465507dd71d507100c1")
{:ok, "0x0234c8a3397aab58"}

The client maintains a persistent WebSocket connection through WebsocketServer, which handles connection management, request-response matching, and automatic reconnection on failures.

All JSON-RPC methods defined in Ethereumex.Client.BaseClient are available through this client, with requests being sent over WebSocket instead of HTTP.

Summary

Types

error()

@type error() :: Ethereumex.Client.Behaviour.error()

Functions

format_batch(list)

@spec format_batch([map()]) :: [ok: map() | nil | binary(), error: any()]

post_request(payload, opts)