> ## 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.

# エリウス Rust SDK for Agents

> AIエージェント向けエリウス Rust SDKの完全ガイド。DAS API、トランザクション、Helius Sender、Webhook、拡張WebSocket、ステーキング、ウォレットAPI、完全なAPIクイックリファレンスのための非同期Rustバインディング。

[Helius Rust SDK](https://github.com/helius-labs/helius-rust-sdk)は、高性能なエージェントワークロードに最適な全てのHelius APIへの非同期Rustバインディングを提供します。

* **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

## インストール

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

Crateはデフォルトで`native-tls`を使用します。OpenSSLが利用できない場合に役立つ純粋なRust TLSを使用するには、次を使用します。

```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メソッド、Webhook、拡張トランザクション、スマートトランザクション、ウォレットAPIを提供します。非同期SolanaクライアントやWebSocketサポートはありません。

### `Helius::new_async` — 機能豊富な非同期クライアント

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

プロダクションに推奨されます。非同期Solana RPCクライアントと拡張WebSocketストリーミングを含みます。WebSocket接続を確立するため`.await`が必要です。

### `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="ベストプラクティス" icon="lightbulb" href="/ja/agents/rust-sdk/best-practices">
    おすすめのパターン、ページネーション、一般的なミス、エラーハンドリング
  </Card>

  <Card title="APIリファレンス" icon="book" href="/ja/agents/rust-sdk/api-reference">
    カテゴリごとの完全なメソッドリスト
  </Card>
</CardGroup>

## リソース

<CardGroup cols={2}>
  <Card title="GitHubリポジトリ" 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/">
    docs.rsにある完全なAPIドキュメント
  </Card>

  <Card title="コード例" icon="code" href="https://github.com/helius-labs/helius-rust-sdk/tree/dev/examples">
    カテゴリ別に整理されたすべての機能の動作する例
  </Card>

  <Card title="移行ガイド (0.xから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>
