Skip to main content

Module client

Module client 

Source
Expand description

HTTP client for the Real Markets matching engine.

This module provides the Client struct, which is the primary interface for communicating with the Real Markets matching engine via JSON-RPC over HTTP.

The client handles all network communication, request serialization, response deserialization, and error handling automatically. It provides a simple async interface for sending transactions and querying the matching engine.

§Key Features

  • JSON-RPC over HTTP: Uses standard JSON-RPC 2.0 protocol over HTTP
  • Async/Await Support: All methods are async and work with tokio
  • Automatic Serialization: Handles request/response serialization transparently
  • Error Handling: Provides detailed error context for network and API failures
  • Connection Management: Built-in connection pooling and reuse

§Core Operations

§Usage Pattern

  1. Create a client instance with Client::new
  2. Build and sign transactions using the types module
  3. Send transactions via Client::send_transaction
  4. Handle the returned TransactionReport or errors

§Examples

§Basic Client Setup

use sdk::Client;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = Client::new("https://matching.api.testnet.real.xyz")?;

    // the health call answers with heights and timestamps, not a bool
    let health = client.healthcheck().await?;
    println!(
        "sequencer at height {} ({} ms)",
        health.sequencer_height, health.sequencer_ts
    );

    Ok(())
}

Structs§

Client
HTTP client for communicating with the Real Markets matching engine.
HealthCheck