get_wallet/
get_wallet.rs

1//! Get Wallet Example
2//!
3//! This example demonstrates how to retrieve a specific wallet by its ID.
4//! It shows how to:
5//! - Initialize a Privy client with app credentials
6//! - Get detailed information about a specific wallet
7//! - Handle the response containing wallet data
8//!
9//! ## Required Environment Variables
10//! - `PRIVY_APP_ID`: Your Privy app ID
11//! - `PRIVY_APP_SECRET`: Your Privy app secret
12//! - `PRIVY_WALLET_ID`: The wallet ID to retrieve
13//!
14//! ## Usage
15//! ```bash
16//! cargo run --example get_wallet
17//! ```
18
19use anyhow::Result;
20use privy_rs::PrivyClient;
21use tracing_subscriber::EnvFilter;
22
23#[tokio::main]
24async fn main() -> Result<()> {
25    tracing_subscriber::fmt()
26        .with_env_filter(
27            EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
28        )
29        .init();
30
31    // Get wallet ID from environment and initialize client
32    let wallet_id =
33        std::env::var("PRIVY_WALLET_ID").expect("PRIVY_WALLET_ID environment variable not set");
34    let client = PrivyClient::new_from_env()?;
35
36    tracing::info!(
37        "initialized privy client from environment, wallet_id: {}",
38        wallet_id
39    );
40
41    let wallet = client.wallets().get(&wallet_id).await?;
42
43    tracing::info!("got wallet: {:?}", wallet);
44
45    Ok(())
46}