Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

query_block

Fetch a block by height. Hits the REST endpoint GET /block/info[/{height}].

Signature

async fn query_block(&self, height: Option<u64>) -> Result<grug::Block, anyhow::Error>;

From impl BlockClient for HttpClient.

Example

use {
    anyhow::Result,
    dango_sdk::HttpClient,
    grug::BlockClient,
};
 
#[tokio::main]
async fn main() -> Result<()> {
    let client = HttpClient::new("https://api-mainnet.dango.zone")?;
    let block  = client.query_block(None).await?;
    println!("height: {}", block.info.height);
    println!("chain:  {}", block.info.chain_id);
    Ok(())
}

Parameters

heightOption<u64>. Block height to fetch, or None for the latest.

Returns

Block — block info plus the list of transactions included at that height.

Notes

  • REST, not GraphQL — the request goes to <url>/block/info directly. Errors include the HTTP status and response body in the anyhow::Error message.

See also