Skip to content

Commit

Permalink
Add Example of Config-based Creation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xIchigo committed Nov 28, 2024
1 parent e319103 commit 2f60d31
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/async_config_based_creation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use helius::error::Result;
use helius::types::Cluster;
use helius::config::Config;
use helius::Helius;

/// Demonstrates creating a Helius client with async Solana capabilities using the config-based approach
#[tokio::main]
async fn main() -> Result<()> {
let api_key: &str = "your_api_key";
let cluster: Cluster = Cluster::MainnetBeta;

let config: Config = Config::new(api_key, cluster)?;
let async_client: Helius = config.create_client_with_async()?;

if let Ok(async_conn) = async_client.async_connection() {
println!("Async client - Get Block Height: {:?}", async_conn.get_block_height().await);
}

Ok(())
}

0 comments on commit 2f60d31

Please sign in to comment.