hypersync-solana-net-types 0.0.7

Network types shared between Solana HyperSync clients and servers
Documentation

hypersync-client-solana

CI

Rust client for Envio's Solana HyperSync.

Documentation page

Workspace layout

This repository is a Cargo workspace with three crates:

  • hypersync-client-solana - the high-level client (Client, streaming, retry).
  • hypersync-solana-net-types - request/response types shared with the server.
  • hypersync-solana-schema - Arrow schemas for the Solana tables.

Install

[dependencies]
hypersync-client-solana = "0.1"

Quick start

use std::sync::Arc;
use hypersync_client_solana::{Client, config::ClientConfig};
use hypersync_solana_net_types::query::SolanaQuery;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = Arc::new(Client::new(ClientConfig {
        url: "https://solana.hypersync.xyz".into(),
        bearer_token: std::env::var("HYPERSYNC_BEARER_TOKEN").ok(),
        ..Default::default()
    })?);

    let height = client.get_height().await?;
    println!("current slot: {height}");

    let query = SolanaQuery {
        from_slot: height.saturating_sub(100),
        to_slot: Some(height),
        include_all_blocks: true,
        ..Default::default()
    };
    let resp = client.get_arrow(&query).await?;
    for (name, batch) in &resp.data.tables {
        println!("{name}: {} rows", batch.num_rows());
    }
    Ok(())
}

A fluent Client::builder() and SolanaQuery::builder() are coming in the next releases (see PLAN.md).

License

MPL-2.0