> ## 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 для агентов

> Полное руководство по Helius Rust SDK для ИИ-агентов — асинхронные привязки Rust для Solana: DAS API, транзакции, Sender, вебхуки, WebSocket и стейкинг.

[Helius Rust SDK](https://github.com/helius-labs/helius-rust-sdk) предоставляет асинхронные привязки Rust для всех API Helius и идеально подходит для высокопроизводительных агентских рабочих нагрузок.

* **Крейт**: `helius` (crates.io)
* **Версия**: 1.x (использует `solana-client` 3.0, `solana-sdk` 3.0)
* **Среда выполнения**: асинхронная (`tokio` 1.x)
* **Rust**: 1.85+ (редакция 2021)
* **HTTP-клиент**: `reqwest`
* **Лицензия**: MIT

## Установка

```toml theme={"system"}
[dependencies]
helius = "1.0.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
solana-sdk = "3.0.0"
```

По умолчанию крейт использует `native-tls`. Чтобы использовать TLS исключительно на Rust (это полезно, если OpenSSL недоступен), выполните следующую команду:

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

## Быстрый старт

```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(())
}
```

## Конструкторы клиента

### `Helius::new` — базовый синхронный клиент

```rust theme={"system"}
let helius = Helius::new("YOUR_API_KEY", Cluster::MainnetBeta)?;
```

Самый простой конструктор. `.await` не требуется. Предоставляет методы RPC, вебхуки, расширенные транзакции, умные транзакции и API кошельков. Не поддерживает асинхронный клиент Solana и WebSocket.

### `Helius::new_async` — полнофункциональный асинхронный клиент

```rust theme={"system"}
let helius = Helius::new_async("YOUR_API_KEY", Cluster::MainnetBeta).await?;
```

Рекомендуется для продакшена. Включает асинхронный клиент Solana RPC и расширенную потоковую передачу через WebSocket. Требует `.await`, поскольку устанавливает соединение WebSocket.

### `Helius::new_with_url` — пользовательская конечная точка RPC

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

Для выделенных узлов RPC, прокси-серверов или локальной разработки. Ключ API не требуется.

### `HeliusBuilder` — расширенная конфигурация

```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` — несколько кластеров

```rust theme={"system"}
let factory = HeliusFactory::new("YOUR_API_KEY");
let devnet_client = factory.create(Cluster::Devnet)?;
let mainnet_client = factory.create(Cluster::MainnetBeta)?;
```

### Доступ к встроенным клиентам Solana

```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)
```

## Подробные руководства

<CardGroup cols={2}>
  <Card title="Best Practices" icon="lightbulb" href="/docs/ru/agents/rust-sdk/best-practices">
    Рекомендуемые шаблоны, пагинация, распространенные ошибки и обработка ошибок
  </Card>

  <Card title="API Reference" icon="book" href="/docs/ru/agents/rust-sdk/api-reference">
    Полный список методов для каждой категории
  </Card>
</CardGroup>

## Ресурсы

<CardGroup cols={2}>
  <Card title="GitHub Repository" icon="github" href="https://github.com/helius-labs/helius-rust-sdk">
    Исходный код, примеры и отслеживание проблем
  </Card>

  <Card title="docs.rs" icon="book" href="https://docs.rs/helius/latest/helius/">
    Полная документация API на docs.rs
  </Card>

  <Card title="Code Examples" icon="code" href="https://github.com/helius-labs/helius-rust-sdk/tree/dev/examples">
    Рабочие примеры для каждой функции, организованные по категориям
  </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">
    Переход с solana-sdk 1.x на 3.0
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.