https://github.com/codx-dev/drand
https://github.com/codx-dev/drand
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codx-dev/drand
- Owner: codx-dev
- Created: 2022-08-16T09:35:17.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-28T18:48:26.000Z (over 2 years ago)
- Last Synced: 2025-02-28T08:45:47.038Z (4 months ago)
- Language: Rust
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://github.com/noislabs/drand-verify) crate.To access an available chain from the API (https://drand.cloudflare.com/chains)
```rust
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 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>` 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