Skip to content

codx-dev/drand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Drand Client

This is a drand client made for rust. It uses reqwest for sending HTTP requests and gets randomness data from the Drand API. It allows performing verification using the drand-verify crate.

To access an available chain from the API (https://drand.cloudflare.com/chains)

use drand::Drand;

#[tokio::main]
async fn main() {
    let mut drand = Drand::available_chains()
        .await
        .expect("Cannot find available chains");

    let chain = drand.chains.remove(0); // drand.chains is a Vec<Chains> to interact with chains 

    let latest = chain.latest().await.expect("Failed to retrieve info").unwrap(); // get the latest round of verified randmoness from the chain
}

chain.latest() will give you Result<OptionVerifiedRandomness>> which is verified autoamtically, unverified randomnesses are not supported. If there's an error in verification then the error the propogated using the drand::DrandError enum.

LICENSE

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages