| Crates.io | ev-client |
| lib.rs | ev-client |
| version | 0.0.1 |
| created_at | 2025-08-04 14:09:03.806902+00 |
| updated_at | 2025-08-04 14:09:03.806902+00 |
| description | Rust client library for interacting with Ev nodes via gRPC |
| homepage | |
| repository | https://github.com/evstack/ev-node |
| max_upload_size | |
| id | 1780765 |
| size | 66,771 |
A Rust client library for interacting with Evolve nodes via gRPC.
Add this to your Cargo.toml:
[dependencies]
ev-client = { path = "path/to/client" }
tokio = { version = "1.45", features = ["full"] }
use ev_client::{Client, HealthClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to a Rollkit node
let client = Client::connect("http://localhost:50051").await?;
// Check health
let health = HealthClient::new(&client);
let is_healthy = health.is_healthy().await?;
println!("Node healthy: {}", is_healthy);
Ok(())
}
use ev_client::Client;
use std::time::Duration;
// Create a client with custom timeouts
let client = Client::builder()
.endpoint("http://localhost:50051")
.timeout(Duration::from_secs(30))
.connect_timeout(Duration::from_secs(10))
.build()
.await?;
use ev_client::{Client, ClientTlsConfig};
// Enable TLS with default configuration
let client = Client::builder()
.endpoint("https://secure-node.rollkit.dev")
.tls()
.build()
.await?;
// Or with custom TLS configuration
let tls_config = ClientTlsConfig::new()
.domain_name("secure-node.rollkit.dev");
let client = Client::builder()
.endpoint("https://secure-node.rollkit.dev")
.tls_config(tls_config)
.build()
.await?;
use ev_client::Client;
use std::time::Duration;
// Still supported for backward compatibility
let client = Client::connect_with_config(
"http://localhost:50051",
|endpoint| {
endpoint
.timeout(Duration::from_secs(30))
.connect_timeout(Duration::from_secs(10))
.tcp_keepalive(Some(Duration::from_secs(60)))
}
).await?;
The client provides wrappers for all Rollkit gRPC services. All service methods are now thread-safe and can be called concurrently:
livez() - Check if the node is aliveis_healthy() - Check if the node is healthyget_peer_info() - Get information about connected peersget_net_info() - Get network informationsign(message) - Sign a messageget_public_key() - Get the node's public keyget_block_by_height(height) - Get a block by heightget_block_by_hash(hash) - Get a block by hashget_state() - Get the current stateget_metadata(key) - Get metadata by keySee the examples directory for more detailed usage examples:
cargo run --example basic
use ev_client::{Client, StoreClient};
use tokio::task;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect("http://localhost:50051").await?;
let store = StoreClient::new(&client);
// Service clients can be used concurrently
let mut handles = vec![];
for height in 0..10 {
let store_clone = store.clone();
let handle = task::spawn(async move {
store_clone.get_block_by_height(height).await
});
handles.push(handle);
}
// Wait for all tasks to complete
for handle in handles {
let result = handle.await??;
println!("Got block: {:?}", result);
}
Ok(())
}
All methods return Result<T, ClientError> where ClientError encompasses:
Apache-2.0