Skip to main content

Rust

About

Our Rust SDK is available here blockfrost-rust.

Installation

Rust Latest Release

Add to your project's Cargo.toml:

blockfrost = "0.2.0"

Usage

All the examples are located at the examples/ folder.

You might want to check all_requests.rs and ipfs.rs.

Here is simple_request.rs with the basic setup necessary and no settings customization:

use blockfrost::{load, BlockFrostApi};

fn build_api() -> blockfrost::Result<BlockFrostApi> {
let configurations = load::configurations_from_env()?;
let project_id = configurations["project_id"].as_str().unwrap();
let api = BlockFrostApi::new(project_id, Default::default());
Ok(api)
}

#[tokio::main]
async fn main() -> blockfrost::Result<()> {
let api = build_api()?;
let genesis = api.genesis().await?;

println!("{:#?}", genesis);
Ok(())
}