use aleo_rust_sdk::AleoHttpClient;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
println!("=== Aleo Testnet Query Demo (v2 JSON-RPC) ===\n");
let client = AleoHttpClient::new("https://api.explorer.provable.com/v2/testnet")?;
let height = client.fetch_block_height().await?;
println!("đ Current block height: {height}");
let state_root = client.fetch_state_root_only().await?;
println!("đŦ Latest state root: {state_root}");
match client.fetch_program("credits.aleo").await {
Ok(program) => println!("đ credits.aleo ID: {}", program.id()),
Err(e) => println!("â ī¸ Failed to fetch credits.aleo: {e}"),
}
let test_addr = "aleo1dev793afmhq2xwuv9k7uxrxxwljhyf9hysp883hs7p2ryq5z7pqsk2hp35";
match client.fetch_mapping_value("credits.aleo", "account", test_addr).await {
Ok(Some(balance)) => println!("đ° Faucet address balance: {balance}"),
Ok(None) => println!("âšī¸ No public balance entry found (account may be private-only)"),
Err(e) => println!("â ī¸ Balance query error: {e}"),
}
println!("\n=== Done ===");
Ok(())
}