Exth.Transport.Http (Exth v0.4.2)
View SourceHTTP transport implementation for JSON-RPC requests using Tesla.
Implements the Exth.Transport.Transportable
protocol for making HTTP/HTTPS
requests to JSON-RPC endpoints. Uses Tesla as the HTTP client with Mint as the
default adapter.
Usage
transport = Transportable.new(
%Exth.Transport.Http{},
rpc_url: "https://mainnet.infura.io/v3/YOUR-PROJECT-ID",
)
{:ok, response} = Transportable.call(transport, request)
Summary
Functions
Makes an HTTP request to the JSON-RPC endpoint.
Creates a new HTTP transport with the given options.
Types
@type t() :: %Exth.Transport.Http{client: Tesla.Client.t()}
HTTP transport configuration
Functions
Makes an HTTP request to the JSON-RPC endpoint.
Returns:
{:ok, response}
- Successful request with encoded response{:error, {:http_error, status}}
- HTTP error response{:error, reason}
- Other errors (network, timeout, etc)
Creates a new HTTP transport with the given options.
Options
:rpc_url
- (required) The HTTP/HTTPS endpoint URL:adapter
- Tesla adapter to use (defaults toTesla.Adapter.Mint
):headers
- Additional HTTP headers for requests:timeout
- Request timeout in milliseconds (defaults to 30000)