Skip to main content
The Helius Rust SDK provides async Rust bindings for all Helius APIs, ideal for high-performance agent workloads.
  • Crate: helius (crates.io)
  • Version: 1.x (uses solana-client 3.0, solana-sdk 3.0)
  • Runtime: Async (tokio 1.x)
  • Rust: 1.85+ (edition 2021)
  • HTTP Client: reqwest
  • License: MIT

Installation

[dependencies]
helius = "1.0.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
solana-sdk = "3.0.0"
The crate defaults to native-tls. For pure-Rust TLS (useful when OpenSSL is unavailable), use:
helius = { version = "1.0.0", default-features = false, features = ["rustls"] }

Quick Start

use helius::error::Result;
use helius::types::*;
use helius::Helius;

#[tokio::main]
async fn main() -> Result<()> {
    let helius = Helius::new("YOUR_API_KEY", Cluster::MainnetBeta)?;

    // Get all NFTs owned by a wallet
    let assets = helius.rpc().get_assets_by_owner(GetAssetsByOwner {
        owner_address: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY".to_string(),
        page: 1,
        limit: Some(50),
        ..Default::default()
    }).await?;

    // Get transaction history (with token account activity)
    let txs = helius.rpc().get_transactions_for_address(
        "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY".to_string(),
        GetTransactionsForAddressOptions {
            limit: Some(100),
            transaction_details: Some(TransactionDetails::Full),
            filters: Some(GetTransactionsFilters {
                token_accounts: Some(TokenAccountsFilter::BalanceChanged),
                ..Default::default()
            }),
            ..Default::default()
        },
    ).await?;

    // Send a transaction via Helius Sender (ultra-low latency)
    let sig = helius.send_smart_transaction_with_sender(
        SmartTransactionConfig {
            create_config: CreateSmartTransactionConfig {
                instructions: vec![transfer_instruction],
                signers: vec![wallet_signer],
                ..Default::default()
            },
            ..Default::default()
        },
        SenderSendOptions {
            region: "US_EAST".to_string(),
            ..Default::default()
        },
    ).await?;

    Ok(())
}

Client Constructors

Helius::new — Basic sync client

let helius = Helius::new("YOUR_API_KEY", Cluster::MainnetBeta)?;
Simplest constructor. No .await needed. Provides RPC methods, webhooks, Enhanced Transactions, smart transactions, and Wallet API. No async Solana client or WebSocket support.
let helius = Helius::new_async("YOUR_API_KEY", Cluster::MainnetBeta).await?;
Recommended for production. Includes async Solana RPC client and Enhanced WebSocket streaming. Requires .await because it establishes a WebSocket connection.

Helius::new_with_url — Custom RPC endpoint

let helius = Helius::new_with_url("http://localhost:8899")?;
For dedicated RPC nodes, proxies, or local development. No API key required.

HeliusBuilder — Advanced configuration

use helius::HeliusBuilder;

let helius = HeliusBuilder::new()
    .with_api_key("YOUR_API_KEY")?
    .with_cluster(Cluster::MainnetBeta)
    .with_async_solana()
    .with_websocket(None, None)
    .with_commitment(CommitmentConfig::confirmed())
    .build()
    .await?;

HeliusFactory — Multi-cluster

let factory = HeliusFactory::new("YOUR_API_KEY");
let devnet_client = factory.create(Cluster::Devnet)?;
let mainnet_client = factory.create(Cluster::MainnetBeta)?;

Accessing embedded Solana clients

helius.connection()          // Sync SolanaRpcClient (Arc)
helius.async_connection()?   // Async SolanaRpcClient (requires new_async or HeliusBuilder)
helius.ws()                  // Enhanced WebSocket (Option)
helius.rpc()                 // Helius RpcClient (Arc)
helius.config()              // Config (Arc)

Deep Dives

Resources