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

HttpClient

A GraphQL + REST client over reqwest that talks to a Dango node.

Setup

use {
    anyhow::Result,
    dango_sdk::HttpClient,
};
 
#[tokio::main]
async fn main() -> Result<()> {
    let client = HttpClient::new("https://api-mainnet.dango.zone")?;
    let _ = client;
    Ok(())
}

new accepts any reqwest::IntoUrl and validates the URL syntactically. It does not perform a network call.

pub struct HttpClient { /* private fields */ }
 
impl HttpClient {
    pub fn new<U>(url: U) -> Result<Self, anyhow::Error>
    where
        U: reqwest::IntoUrl;
}

Configuration

HttpClient does not expose constructor options. It uses reqwest::Client::new() internally with default settings (HTTPS, connection pool, no proxy override). For custom transports — proxies, TLS roots, timeouts — fork the source.

Methods

The methods are split between own pagination helpers and the four trait impls. Bring the trait into scope to call its methods.

Pagination (own methods)

MethodDescription
paginate_allGeneric forward/backward cursor pagination loop.
paginate_accountsAll accounts, forward pagination.
paginate_transfersAll transfers, forward pagination.
paginate_transactionsAll transactions, forward pagination.
paginate_blocksAll blocks, forward pagination.
paginate_eventsAll events, forward pagination.
paginate_messagesAll messages, forward pagination.

impl QueryClient

MethodDescription
query_appRun an app-level query at a given height.
query_storeRead a raw key from store, optionally with a proof.
simulateDry-run an UnsignedTx and return its outcome.

impl BlockClient

MethodDescription
query_blockFetch a block by height (REST /block/info).
query_block_outcomeFetch a block's execution outcome (REST /block/result).

impl BroadcastClient

MethodDescription
broadcast_txSubmit a signed transaction with tx-sync semantics.

impl SearchTxClient

MethodDescription
search_txLook up a transaction outcome by hash.

Extension methods (from QueryClientExt)

QueryClientExt is a blanket trait over QueryClient. It is reachable on HttpClient once QueryClientExt is in scope:

Method
query_app_configTyped AppConfig fetch.
query_balanceSingle denom balance.
query_balancesAll balances for an address.
query_supplyTotal supply for a denom.
query_suppliesAll denom supplies.
query_wasm_smartTyped contract smart query.
query_wasm_rawRaw contract storage slot.
query_codeWasm bytecode by hash.
query_codesList uploaded code hashes.
query_contractContract info.
query_contractsList contracts.

See the QueryClientExt reference for full signatures.

End-to-end example

use {
    anyhow::Result,
    dango_sdk::HttpClient,
    grug::{BlockClient, QueryClient, QueryClientExt},
};
 
#[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);
 
    let cfg = client
        .query_app_config::<dango_types::config::AppConfig>(None)
        .await?;
    println!("account factory: {}", cfg.addresses.account_factory);
 
    Ok(())
}

Notes

  • HttpClient is Debug + Clone. Cloning shares the underlying reqwest::Client connection pool — reuse a single instance.
  • The tracing feature emits tracing::debug! events for every GraphQL request/response. No public symbols change.
  • REST endpoints (query_block, query_block_outcome) hit <url>/block/info and <url>/block/result; GraphQL endpoints hit <url>/graphql.

See also