> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Helius Rust SDK for Agents

> Complete guide to the Helius Rust SDK for AI agents. Async Rust bindings for DAS API, transactions, Helius Sender, webhooks, Enhanced WebSockets, staking, Wallet API, and full API quick reference.

The [Helius Rust SDK](https://github.com/helius-labs/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

```toml theme={"system"}
[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:

```toml theme={"system"}
helius = { version = "1.0.0", default-features = false, features = ["rustls"] }
```

## Quick Start

```rust theme={"system"}
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

```rust theme={"system"}
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.

### `Helius::new_async` — Full-featured async client

```rust theme={"system"}
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

```rust theme={"system"}
let helius = Helius::new_with_url("http://localhost:8899")?;
```

For dedicated RPC nodes, proxies, or local development. No API key required.

### `HeliusBuilder` — Advanced configuration

```rust theme={"system"}
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

```rust theme={"system"}
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

```rust theme={"system"}
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

<CardGroup cols={2}>
  <Card title="Best Practices" icon="lightbulb" href="/agents/rust-sdk/best-practices">
    Recommended patterns, pagination, common mistakes, and error handling
  </Card>

  <Card title="API Reference" icon="book" href="/agents/rust-sdk/api-reference">
    Full method list for every category
  </Card>
</CardGroup>

## Resources

<CardGroup cols={2}>
  <Card title="GitHub Repository" icon="github" href="https://github.com/helius-labs/helius-rust-sdk">
    Source code, examples, and issue tracking
  </Card>

  <Card title="docs.rs" icon="book" href="https://docs.rs/helius/latest/helius/">
    Full API documentation on docs.rs
  </Card>

  <Card title="Code Examples" icon="code" href="https://github.com/helius-labs/helius-rust-sdk/tree/dev/examples">
    Working examples for every feature organized by category
  </Card>

  <Card title="Migration Guide (0.x to 1.0)" icon="arrow-right" href="https://github.com/helius-labs/helius-rust-sdk/blob/main/MIGRATION.md">
    Upgrade from solana-sdk 1.x to 3.0
  </Card>
</CardGroup>
