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
Client::send_transaction: Submit signed transactions containing orders/cancellationsClient::get_version: Retrieve matching engine version informationClient::get_chain_id: Read (and cache) the chain id this endpoint expectsClient::verify_chain_id: Assert the endpoint is the network you expectClient::healthcheck: Read the engine’s height and timestamp snapshot
§Usage Pattern
- Create a client instance with
Client::new - Build and sign transactions using the types module
- Send transactions via
Client::send_transaction - Handle the returned
TransactionReportor 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.
- Health
Check