| Crates.io | drand-client-rs |
| lib.rs | drand-client-rs |
| version | 0.1.0 |
| created_at | 2023-09-11 12:28:20.299065+00 |
| updated_at | 2023-09-11 12:28:20.299065+00 |
| description | A small rust library for retrieving random numbers from drand |
| homepage | |
| repository | |
| max_upload_size | |
| id | 969544 |
| size | 37,372 |
A simple drand client implementation written in rust
pedersen-bls-chained schemepedersen-bls-unchained schemebls-unchained-on-g1 schemebls-unchained-on-g1-rfc9380 schemeuse drand_client_rs::{new_http_client, DrandClientError};
fn main() -> Result<(), DrandClientError> {
// first create the client using one of the relays as a `base_url`
let drand_client = new_http_client("https://api.drand.sh")?;
// you can fetch the latest random value using `latest_randomness`
if let Ok(beacon) = drand_client.latest_randomness() {
println!("the latest round is {}", beacon.round_number);
println!("the latest randomness is {:?}", beacon.randomness);
}
// or a specific round using `randomness`
if let Ok(beacon) = drand_client.randomness(1) {
println!("the selected round is {}", beacon.round_number);
println!("the latest randomness is {:?}", beacon.randomness);
}
Ok(())
}