### Run Basic Relay Client Example with Cargo Source: https://github.com/symbioticfi/relay-client-rs/blob/main/examples/README.md Demonstrates how to execute the basic usage example for the symbiotic-relay-client using Cargo. It shows the default connection to localhost:8080 and how to specify a different server URL via an environment variable. ```bash cd examples cargo run --bin basic_usage ``` ```bash RELAY_SERVER_URL=my-relay-server:8080 cargo run --bin basic_usage ``` -------------------------------- ### Configure Tonic Transport Endpoint in Rust Source: https://github.com/symbioticfi/relay-client-rs/blob/main/examples/README.md Shows how to configure the transport connection for a gRPC client using Tonic in Rust. It demonstrates setting various timeouts and keepalive options for the endpoint. ```rust use tonic::transport::Endpoint; use std::time::Duration; let endpoint = Endpoint::from_shared("localhost:8080")? .timeout(Duration::from_secs(30)) .connect_timeout(Duration::from_secs(10)) .tcp_keepalive(Some(Duration::from_secs(60))); let channel = endpoint.connect().await?; ``` -------------------------------- ### Get Current Epoch Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Retrieves the current epoch information from the Symbiotic Relay server. This includes the epoch number and its start time. ```APIDOC ## GET /GetCurrentEpoch ### Description Retrieves the current epoch number and its start time from the relay server. ### Method GET ### Endpoint /GetCurrentEpoch ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **epoch** (uint64) - The current epoch number. - **start_time** (google.protobuf.Timestamp) - The timestamp when the current epoch started. #### Response Example ```json { "example": "{\n \"epoch\": 12345,\n \"start_time\": {\n \"seconds\": 1678886400,\n \"nanos\": 0\n }\n}" } ``` ``` -------------------------------- ### Get Aggregation Proofs by Epoch Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Fetches all aggregation proofs associated with a specific epoch from the Symbiotic API. It displays the total count and details of the first three proofs. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetAggregationProofsByEpochRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_proofs_by_epoch( client: &mut SymbioticApiServiceClient, epoch: u64 ) -> Result<(), Box> { let request = tonic::Request::new(GetAggregationProofsByEpochRequest { epoch }); let response = client.get_aggregation_proofs_by_epoch(request).await?; let proofs_data = response.into_inner(); println!("Epoch {} has {} aggregation proofs", epoch, proofs_data.aggregation_proofs.len()); for (idx, proof) in proofs_data.aggregation_proofs.iter().enumerate().take(3) { println!("\nProof {}:", idx + 1); println!(" Request ID: {}", proof.request_id); println!(" Proof length: {} bytes", proof.proof.len()); println!(" Message hash: 0x{}", hex::encode(&proof.message_hash)); } Ok(()) } ``` -------------------------------- ### Add relay-client-rs Dependency to Cargo.toml Source: https://github.com/symbioticfi/relay-client-rs/blob/main/examples/README.md Specifies the necessary dependencies for using the relay-client-rs library in a Rust project. It includes the relay-client-rs crate itself, along with 'tonic' for gRPC and 'tokio' for asynchronous runtime. ```toml [dependencies] relay-client-rs = { path = "../path/to/relay-client-rs" } tonic = "0.12" tokio = { version = "1", features = ["macros", "rt-multi-thread"] } ``` -------------------------------- ### Get Aggregation Proof Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Fetches an aggregated signature proof for a specific request ID from the Symbiotic API. Handles cases where the proof is not yet ready, returning an error. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetAggregationProofRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_aggregation_proof( client: &mut SymbioticApiServiceClient, request_id: String ) -> Result<(), Box> { let request = tonic::Request::new(GetAggregationProofRequest { request_id }); match client.get_aggregation_proof(request).await { Ok(response) => { let proof_data = response.into_inner(); if let Some(proof) = proof_data.aggregation_proof { println!("Aggregation Proof Retrieved:"); println!(" Request ID: {}", proof.request_id); println!(" Proof length: {} bytes", proof.proof.len()); println!(" Message hash length: {} bytes", proof.message_hash.len()); println!(" Proof data: 0x{}", hex::encode(&proof.proof[..proof.proof.len().min(32)])); } }, Err(e) => { eprintln!("Aggregation not ready yet: {}", e.message()); return Err(Box::new(e)); } } Ok(()) } ``` -------------------------------- ### Create and Use Symbiotic Relay Client in Rust Source: https://github.com/symbioticfi/relay-client-rs/blob/main/examples/README.md Illustrates how to instantiate and utilize the Symbiotic Relay Client in Rust. It covers creating a gRPC client connection using Tokio and making a call to retrieve the current epoch information. ```rust use relay_client::gen::api::proto::v1::symbiotic_api_service_client::SymbioticApiServiceClient; use tonic::transport::Endpoint; #[tokio::main] async fn main() -> Result<(), Box> { // Create transport channel let endpoint = Endpoint::from_shared("localhost:8080")?; let channel = endpoint.connect().await?; // Create the gRPC client let mut client = SymbioticApiServiceClient::new(channel); // Use the client for API calls let response = client.get_current_epoch( tonic::Request::new(relay_client::GetCurrentEpochRequest {{}}) ).await?; println!("Current epoch: {}", response.into_inner().epoch); Ok(()) } ``` -------------------------------- ### Complete Application: Sign-and-Verify Workflow (Rust) Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Demonstrates a full sign-and-verify workflow using the Symbiotic Relay Client. It connects to a relay server, gets the current epoch, requests a signature, waits for aggregation, and retrieves the proof. Includes error handling and asynchronous operations with Tokio. ```rust use symbiotic_relay_client::generated::api::proto::v1::symbiotic_api_service_client::SymbioticApiServiceClient; use tonic::transport::Endpoint; use std::env; use std::time::Duration; use tokio::time::sleep; #[tokio::main] async fn main() -> Result<(), Box> { // Connect to relay let server_url = env::var("RELAY_SERVER_URL") .unwrap_or_else(|_| "http://localhost:8080".to_string()); let endpoint = Endpoint::from_shared(server_url)? .timeout(Duration::from_secs(30)); let channel = endpoint.connect().await?; let mut client = SymbioticApiServiceClient::new(channel); println!("=== Connected to Symbiotic Relay ===\n"); // Get current epoch let epoch_request = tonic::Request::new( symbiotic_relay_client::GetCurrentEpochRequest {} ); let epoch_response = client.get_current_epoch(epoch_request).await?; let current_epoch = epoch_response.into_inner().epoch; println!("Current epoch: {}\n", current_epoch); // Submit signature request println!("=== Submitting Signature Request ==="); let message = format!("Transaction at epoch {}", current_epoch); let sign_request = tonic::Request::new( symbiotic_relay_client::SignMessageRequest { key_tag: 15, message: message.as_bytes().to_vec().into(), required_epoch: None, } ); let sign_response = client.sign_message(sign_request).await?; let sign_data = sign_response.into_inner(); let request_id = sign_data.request_id.clone(); println!("Request ID: {}", request_id); println!("Epoch: {}\n", sign_data.epoch); // Wait for aggregation println!("=== Waiting for Signature Aggregation ==="); sleep(Duration::from_secs(5)).await; // Retrieve aggregation proof let proof_request = tonic::Request::new( symbiotic_relay_client::GetAggregationProofRequest { request_id: request_id.clone() } ); match client.get_aggregation_proof(proof_request).await { Ok(proof_response) => { let proof_data = proof_response.into_inner(); if let Some(proof) = proof_data.aggregation_proof { println!("āœ“ Aggregation proof received"); println!(" Proof size: {} bytes", proof.proof.len()); println!(" Message hash: 0x{}", hex::encode(&proof.message_hash[..16])); } }, Err(e) => { println!("Aggregation not ready: {}", e.message()); } } // Get individual signatures let sigs_request = tonic::Request::new( symbiotic_relay_client::GetSignaturesRequest { request_id: request_id.clone() } ); match client.get_signatures(sigs_request).await { Ok(sigs_response) => { let sigs_data = sigs_response.into_inner(); println!("\nāœ“ Retrieved {} individual signatures", sigs_data.signatures.len()); }, Err(e) => { println!("Signatures not available: {}", e.message()); } } println!("\n=== Workflow Complete ==="); Ok(()) } ``` -------------------------------- ### Get Validator Set Information Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Retrieves validator set details for a given epoch using the Symbiotic API. Requires an active gRPC client channel and returns an error if the request fails. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetValidatorSetRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_validator_set(client: &mut SymbioticApiServiceClient, epoch: Option) -> Result<(), Box> { let request = tonic::Request::new(GetValidatorSetRequest { epoch }); let response = client.get_validator_set(request).await?; let validator_set_data = response.into_inner(); if let Some(vs) = validator_set_data.validator_set { println!("Validator Set Information:"); println!(" Version: {}", vs.version); println!(" Epoch: {}", vs.epoch); println!(" Status: {:?}", vs.status()); println!(" Validators: {}", vs.validators.len()); println!(" Quorum threshold: {}", vs.quorum_threshold); for (idx, validator) in vs.validators.iter().enumerate().take(3) { println!("\nValidator {}:", idx + 1); println!(" Operator: {}", validator.operator); println!(" Voting power: {}", validator.voting_power); println!(" Active: {}", validator.is_active); println!(" Keys: {}", validator.keys.len()); } } Ok(()) } ``` -------------------------------- ### Retrieve Current Epoch Information Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt This Rust function queries the Symbiotic Relay server for the current epoch's information, including the epoch number and its start time. It uses the `GetCurrentEpochRequest` and handles the response. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetCurrentEpochRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_epoch(client: &mut SymbioticApiServiceClient) -> Result<(), Box> { let request = tonic::Request::new(GetCurrentEpochRequest {}); let response = client.get_current_epoch(request).await?; let epoch_data = response.into_inner(); println!("Current epoch: {}", epoch_data.epoch); if let Some(start_time) = epoch_data.start_time { println!("Epoch started at: {:?}", start_time); } Ok(()) } ``` -------------------------------- ### Get Individual Signatures Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Retrieves a list of individual validator signatures for a given request ID via the Symbiotic API. It iterates and prints details for the first five signatures found. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetSignaturesRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_signatures( client: &mut SymbioticApiServiceClient, request_id: String ) -> Result<(), Box> { let request = tonic::Request::new(GetSignaturesRequest { request_id }); let response = client.get_signatures(request).await?; let signatures_data = response.into_inner(); println!("Retrieved {} signatures", signatures_data.signatures.len()); for (idx, signature) in signatures_data.signatures.iter().enumerate().take(5) { println!("\nSignature {}:", idx + 1); println!(" Request ID: {}", signature.request_id); println!(" Signature length: {} bytes", signature.signature.len()); println!(" Public key length: {} bytes", signature.public_key.len()); println!(" Message hash length: {} bytes", signature.message_hash.len()); } Ok(()) } ``` -------------------------------- ### Get Signatures by Epoch (Rust) Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Retrieves all signatures associated with a specific epoch from the Symbiotic API. This function requires an active client connection and the epoch number as input. It outputs the number of signatures found for the given epoch. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetSignaturesByEpochRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_signatures_by_epoch( client: &mut SymbioticApiServiceClient, epoch: u64 ) -> Result<(), Box> { let request = tonic::Request::new(GetSignaturesByEpochRequest { epoch }); let response = client.get_signatures_by_epoch(request).await?; let signatures_data = response.into_inner(); println!("Epoch {} has {} signatures", epoch, signatures_data.signatures.len()); Ok(()) } ``` -------------------------------- ### Get Validator by Key (Rust) Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Fetches information about a specific validator using their public key and key tag. This function can optionally filter by epoch. It prints details of the found validator, including operator, voting power, active status, and the number of keys managed. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetValidatorByKeyRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_validator_by_key( client: &mut SymbioticApiServiceClient, key_tag: u32, on_chain_key: Vec, epoch: Option ) -> Result<(), Box> { let request = tonic::Request::new(GetValidatorByKeyRequest { epoch, key_tag, on_chain_key: on_chain_key.into(), }); let response = client.get_validator_by_key(request).await?; let validator_data = response.into_inner(); if let Some(validator) = validator_data.validator { println!("Validator found:"); println!(" Operator: {}", validator.operator); println!(" Voting power: {}", validator.voting_power); println!(" Active: {}", validator.is_active); println!(" Number of keys: {}", validator.keys.len()); } Ok(()) } ``` -------------------------------- ### Get Last Committed Epochs Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Queries the last committed epochs across all chains monitored by the Symbiotic Relay server. It returns a map of chain IDs to their respective last committed epoch information. ```APIDOC ## GET /GetLastAllCommitted ### Description Queries the last committed epochs for all monitored chains. Returns a map where keys are chain IDs and values contain the last committed epoch for that chain. ### Method GET ### Endpoint /GetLastAllCommitted ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **epoch_infos** (map) - A map where keys are chain IDs and values are EpochInfo objects. - **EpochInfo**: - **last_committed_epoch** (uint64) - The last epoch committed on this chain. #### Response Example ```json { "example": "{\n \"epoch_infos\": {\n \"chain1\": { \"last_committed_epoch\": 1000 } ,\n \"chain2\": { \"last_committed_epoch\": 1050 }\n }\n}" } ``` ``` -------------------------------- ### Get Signature Requests by Epoch (Rust) Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Retrieves signature requests associated with a specific epoch. This function requires an initialized `SymbioticApiServiceClient` and the epoch number as input. It outputs details about the signature requests found for that epoch, printing up to the first three. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetSignatureRequestsByEpochRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_signature_requests_by_epoch( client: &mut SymbioticApiServiceClient, epoch: u64 ) -> Result<(), Box> { let request = tonic::Request::new(GetSignatureRequestsByEpochRequest { epoch }); let response = client.get_signature_requests_by_epoch(request).await?; let requests_data = response.into_inner(); println!("Epoch {} has {} signature requests", epoch, requests_data.signature_requests.len()); for (idx, sig_request) in requests_data.signature_requests.iter().take(3).enumerate() { println!("\nSignature Request {}:", idx + 1); println!(" Request ID: {}", sig_request.request_id); println!(" Key tag: {}", sig_request.key_tag); println!(" Message length: {} bytes", sig_request.message.len()); println!(" Required epoch: {}", sig_request.required_epoch); } Ok(()) } ``` -------------------------------- ### Get Signature Request IDs by Epoch (Rust) Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Lists all signature request IDs for a given epoch. This function returns a vector of strings, where each string is a unique signature request ID. It also prints the first 10 request IDs found for the specified epoch. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetSignatureRequestIDsByEpochRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_request_ids_by_epoch( client: &mut SymbioticApiServiceClient, epoch: u64 ) -> Result, Box> { let request = tonic::Request::new(GetSignatureRequestIDsByEpochRequest { epoch }); let response = client.get_signature_request_i_ds_by_epoch(request).await?; let ids_data = response.into_inner(); println!("Epoch {} has {} signature requests", epoch, ids_data.request_ids.len()); for (idx, request_id) in ids_data.request_ids.iter().take(10).enumerate() { println!(" {}: {}", idx + 1, request_id); } Ok(ids_data.request_ids) } ``` -------------------------------- ### Get Local Validator Information (Rust) Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Retrieves details about the local validator node. This function can optionally filter by epoch. It prints the operator, voting power, active status, and a list of managed keys, including their tags and payload lengths. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetLocalValidatorRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_local_validator( client: &mut SymbioticApiServiceClient, epoch: Option ) -> Result<(), Box> { let request = tonic::Request::new(GetLocalValidatorRequest { epoch }); let response = client.get_local_validator(request).await?; let local_validator_data = response.into_inner(); if let Some(validator) = local_validator_data.validator { println!("Local Validator Information:"); println!(" Operator: {}", validator.operator); println!(" Voting power: {}", validator.voting_power); println!(" Active: {}", validator.is_active); println!(" Keys managed: {}", validator.keys.len()); for (idx, key) in validator.keys.iter().enumerate() { println!("\n Key {}:", idx + 1); println!(" Tag: {}", key.tag); println!(" Payload length: {} bytes", key.payload.len()); } } Ok(()) } ``` -------------------------------- ### Stream Validator Set Changes in Real-Time (Rust) Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt This function subscribes to real-time validator set change events from the Symbiotic API. It takes a mutable client and an optional starting epoch as input. The function returns a result indicating success or an error, and it prints updates about validator set changes as they occur. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ ListenValidatorSetRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; use tokio_stream::StreamExt; async fn stream_validator_set_changes( client: &mut SymbioticApiServiceClient, start_epoch: Option ) -> Result<(), Box> { let request = tonic::Request::new(ListenValidatorSetRequest { start_epoch }); let response = client.listen_validator_set(request).await?; let mut stream = response.into_inner(); println!("Listening for validator set changes..."); while let Some(vs_response) = stream.next().await { match vs_response { Ok(vs_data) => { if let Some(vs) = vs_data.validator_set { println!("\n[VALIDATOR SET UPDATE]"); println!(" Epoch: {}", vs.epoch); println!(" Version: {}", vs.version); println!(" Status: {:?}", vs.status()); println!(" Validators: {}", vs.validators.len()); println!(" Quorum threshold: {}", vs.quorum_threshold); } }, Err(e) => { eprintln!("Stream error: {}", e.message()); break; } } } Ok(()) } ``` -------------------------------- ### Connect to Symbiotic Relay Server Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Demonstrates establishing a gRPC connection to a Symbiotic Relay server using Tonic. It configures the connection endpoint with timeouts and keep-alive settings before initiating the connection. ```rust use symbiotic_relay_client::generated::api::proto::v1::symbiotic_api_service_client::SymbioticApiServiceClient; use tonic::transport::Endpoint; use std::time::Duration; #[tokio::main] async fn main() -> Result<(), Box> { // Create endpoint with configuration let endpoint = Endpoint::from_shared("http://localhost:8080")? .timeout(Duration::from_secs(30)) .connect_timeout(Duration::from_secs(10)) .tcp_keepalive(Some(Duration::from_secs(60))); // Establish connection let channel = endpoint.connect().await?; let mut client = SymbioticApiServiceClient::new(channel); println!("Connected to Symbiotic Relay"); Ok(()) } ``` -------------------------------- ### Stream Aggregation Proofs in Real-Time (Rust) Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Subscribes to a stream of aggregation proof events as they are generated. Similar to streaming signatures, this function accepts an optional `start_epoch`. It continuously listens for new proofs and displays details such as request ID, epoch, and proof/message hash lengths. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ ListenProofsRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; use tokio_stream::StreamExt; async fn stream_proofs( client: &mut SymbioticApiServiceClient, start_epoch: Option ) -> Result<(), Box> { let request = tonic::Request::new(ListenProofsRequest { start_epoch }); let response = client.listen_proofs(request).await?; let mut stream = response.into_inner(); println!("Listening for aggregation proofs..."); while let Some(proof_response) = stream.next().await { match proof_response { Ok(proof_data) => { println!("\n[NEW AGGREGATION PROOF]"); println!(" Request ID: {}", proof_data.request_id); println!(" Epoch: {}", proof_data.epoch); if let Some(proof) = proof_data.aggregation_proof { println!(" Proof length: {} bytes", proof.proof.len()); println!(" Message hash: 0x{}", hex::encode(&proof.message_hash[..proof.message_hash.len().min(16)])); } }, Err(e) => { eprintln!("Stream error: {}", e.message()); break; } } } Ok(()) } ``` -------------------------------- ### Stream Signatures in Real-Time (Rust) Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Subscribes to a stream of signature events as they occur. This function takes an optional `start_epoch` to begin listening from a specific point. It continuously listens for new signatures and prints details for each, handling potential stream errors. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ ListenSignaturesRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; use tokio_stream::StreamExt; async fn stream_signatures( client: &mut SymbioticApiServiceClient, start_epoch: Option ) -> Result<(), Box> { let request = tonic::Request::new(ListenSignaturesRequest { start_epoch }); let response = client.listen_signatures(request).await?; let mut stream = response.into_inner(); println!("Listening for signatures..."); while let Some(signature_response) = stream.next().await { match signature_response { Ok(sig_data) => { println!("\n[NEW SIGNATURE]"); println!(" Request ID: {}", sig_data.request_id); println!(" Epoch: {}", sig_data.epoch); if let Some(signature) = sig_data.signature { println!(" Signature length: {} bytes", signature.signature.len()); println!(" Public key length: {} bytes", signature.public_key.len()); } }, Err(e) => { eprintln!("Stream error: {}", e.message()); break; } } } Ok(()) } ``` -------------------------------- ### Initialize Symbiotic Relay Client in Rust Source: https://github.com/symbioticfi/relay-client-rs/blob/main/README.md This Rust code snippet shows how to initialize the Symbiotic Relay Client using Tokio. It establishes a gRPC channel to a local server and creates a client instance for interacting with the Symbiotic API service. ```rust use symbiotic_relay_client::generated::api::proto::v1::symbiotic_api_service_client::SymbioticApiServiceClient; use tonic::transport::Endpoint; #[tokio::main] async fn main() -> Result<(), Box> { let channel = Endpoint::from_shared("http://localhost:8080")?.connect().await?; let mut client = SymbioticApiServiceClient::new(channel); // Use the client; e.g. see examples for requests and streaming usage Ok(()) } ``` -------------------------------- ### Use Development Version of Symbiotic Relay Client Source: https://github.com/symbioticfi/relay-client-rs/blob/main/README.md This snippet demonstrates how to use a development or nightly version of the Symbiotic Relay Client by specifying a git dependency in Cargo.toml. You can use a specific commit hash, branch, or tag. ```toml [dependencies] symbiotic-relay-client = { git = "https://github.com/symbioticfi/relay-client-rs", rev = "9f35b8e" } ``` -------------------------------- ### Sign Message Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt Requests a signature for a given message using the validator network. You can specify a key tag and optionally a required epoch for the signature. ```APIDOC ## POST /SignMessage ### Description Requests the validator network to sign a given message. Allows specifying a key tag and an optional required epoch for the signature. ### Method POST ### Endpoint /SignMessage ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **key_tag** (uint32) - Required - The identifier for the key to use for signing. - **message** (bytes) - Required - The message to be signed, represented as bytes. - **required_epoch** (uint64) - Optional - The epoch by which the signature must be available. If not provided, the latest committed epoch is used. ### Request Example ```json { "example": "{\n \"key_tag\": 15,\n \"message\": \"SGVsbG8sIFN5bWJpb3RpY1JlbGF5IS0=\",\n \"required_epoch\": null\n}" } ``` ### Response #### Success Response (200) - **request_id** (string) - A unique identifier for the signature request. - **epoch** (uint64) - The epoch number associated with the generated signature. #### Response Example ```json { "example": "{\n \"request_id\": \"abc123xyz789\",\n \"epoch\": 12345\n}" } ``` ``` -------------------------------- ### Query Last Committed Epochs Across Chains Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt This function retrieves the last committed epoch information for all chains from the Symbiotic Relay server. It then calculates and prints the minimum committed epoch across all queried chains. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetLastAllCommittedRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn get_last_committed(client: &mut SymbioticApiServiceClient) -> Result> { let request = tonic::Request::new(GetLastAllCommittedRequest {}); let response = client.get_last_all_committed(request).await?; let epoch_infos = response.into_inner(); // Find minimum committed epoch across all chains let mut min_epoch = 0u64; for (chain_id, info) in epoch_infos.epoch_infos.iter() { println!("Chain {}: last committed epoch {}", chain_id, info.last_committed_epoch); if min_epoch == 0 || info.last_committed_epoch < min_epoch { min_epoch = info.last_committed_epoch; } } println!("Minimum committed epoch across all chains: {}", min_epoch); Ok(min_epoch) } ``` -------------------------------- ### Request Message Signature Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt This Rust function demonstrates how to request a cryptographic signature for a given message from the Symbiotic Relay network. It specifies a key tag and the message to be signed, returning a request ID and the epoch in which the signature was processed. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ SignMessageRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn sign_message(client: &mut SymbioticApiServiceClient) -> Result> { let message = "Hello, Symbiotic Relay!".as_bytes().to_vec(); let key_tag = 15u32; let request = tonic::Request::new(SignMessageRequest { key_tag, message: message.into(), required_epoch: None, // Use latest committed epoch }); let response = client.sign_message(request).await?; let sign_data = response.into_inner(); println!("Signature request submitted"); println!("Request ID: {}", sign_data.request_id); println!("Epoch: {}", sign_data.epoch); Ok(sign_data.request_id) } ``` -------------------------------- ### Add Symbiotic Relay Client Dependency to Cargo.toml Source: https://github.com/symbioticfi/relay-client-rs/blob/main/README.md This snippet shows how to add the Symbiotic Relay Client to your project's Cargo.toml file for stable releases. It specifies the package name and version. ```toml [dependencies] symbiotic-relay-client = "0.3.0" ``` -------------------------------- ### Check Custom Schedule Node Status (Rust) Source: https://context7.com/symbioticfi/relay-client-rs/llms.txt This function checks if a node should be active within a custom scheduling scheme using the Symbiotic API. It requires a mutable client and parameters such as epoch, seed, slot duration, and participant limits. The function returns a boolean indicating the node's active status and prints details about the current slot. ```rust use symbiotic_relay_client::generated::api::proto::v1::{ GetCustomScheduleNodeStatusRequest, symbiotic_api_service_client::SymbioticApiServiceClient, }; use tonic::transport::Channel; async fn check_custom_schedule( client: &mut SymbioticApiServiceClient, epoch: Option, seed: Option>, slot_duration_seconds: u64, max_participants: u32, min_participants: u32 ) -> Result> { let request = tonic::Request::new(GetCustomScheduleNodeStatusRequest { epoch, seed: seed.map(|s| s.into()), slot_duration_seconds, max_participants_per_slot: max_participants, min_participants_per_slot: min_participants, }); let response = client.get_custom_schedule_node_status(request).await?; let status_data = response.into_inner(); println!("Custom Schedule Status:"); println!(" Is active: {}", status_data.is_active); if let Some(start_time) = status_data.current_slot_start_time { println!(" Slot start: {:?}", start_time); } if let Some(end_time) = status_data.current_slot_end_time { println!(" Slot end: {:?}", end_time); } Ok(status_data.is_active) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.