alchemy-api

Crates.ioalchemy-api
lib.rsalchemy-api
version0.1.0
sourcesrc
created_at2024-01-13 11:34:34.818944
updated_at2024-01-13 11:34:34.818944
descriptionA high-level binding for Alchemy Enhanced APIs, written in Rust.
homepage
repositoryhttps://github.com/phnaharris/alchemy-api-rs.git
max_upload_size
id1098473
size117,219
Nam Anh Pham Hoang (phnaharris)

documentation

README

alchemy-api

Crates.io Documentation codecov Build Status

A high-level binding for Alchemy Enhanced APIs, written in Rust.

Alchemy provides a suite of web3 APIs that dramatically simplify and optimize common request patterns to make your life as a developer easier.

Access the blockchain like never before with Alchemy's continually expanding Enhanced API suite, and web3 developer tools! Query NFTs by the user, trace transactions, get real-time notifications in your dApp, debug smart contracts faster, and do more with Alchemy's supported endpoints.

This crate uses the reqwest crate for a convenient, higher-level HTTP Client, for request and response, to and from Alchemy, and serde for serialize and deserialize from and to appropriate data format.

Examples

Let's start out creating an AddressActivity webhook.

use alchemy_api::{
    alchemy::Alchemy,
    api::notify::{CreateWebhook, WebhookResponse, WebhookType},
    cores::query::Query,
};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = Alchemy::new(&std::env::var("ALCHEMY_TOKEN")?);

    // Create a simple endpoint.
    let endpoint = CreateWebhook::builder()
        .webhook_url(std::env::var("WEBHOOK_URL")?)
        .webhook_type(WebhookType::AddressActivity)
        .addresses(vec![std::env::var("ADDRESS")?.parse()?])
        .build()?;
    println!("{:?}", endpoint);

    // Call the endpoint. The return type decides how to represent the value.
    let webhook: WebhookResponse = endpoint.query(&client).await?;
    println!("webhook: {:?}", webhook);

    anyhow::Ok(())
}

For more examples, take a look at the examples/ directory.

Commit count: 0

cargo fmt