> ## 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 Solana Rust SDK

> Official Helius Rust SDK for Solana development. Add the helius crate, parse transactions with the Enhanced Transactions API, and handle errors with comprehensive API and DAS support.

The Helius Rust SDK ([`helius`](https://github.com/helius-labs/helius-rust-sdk)) makes developing on Solana easier from Rust. This page covers installing and using the SDK, handling common errors, and where to find the latest documentation.

<CardGroup cols={1}>
  <Card title="GitHub Repository" icon="rust" href="https://github.com/helius-labs/helius-rust-sdk">
    Official Helius Rust SDK for Solana development
  </Card>
</CardGroup>

## Installation

<Steps>
  <Step title="Add dependency to Cargo.toml">
    To start using the Helius Rust SDK in your project, add it as a dependency via [`cargo`](https://doc.rust-lang.org/cargo/). Open your project's `Cargo.toml` and add the following line under `[dependencies]`:

    ```toml theme={"system"}
    helius = "x.y.z"
    ```

    where `x.y.z` is your desired version.
  </Step>

  <Step title="Alternative: Use cargo add command">
    Alternatively, use `cargo add helius` to add the dependency directly via the command line. This will automatically find the latest version compatible with your project and add it to your `Cargo.toml`.
  </Step>

  <Step title="Keep your SDK updated">
    Remember to run `cargo update` regularly to fetch the latest version of the SDK.
  </Step>
</Steps>

## Quick Start

Below is a straightforward example of using the [Enhanced Transactions API](/docs/enhanced-transactions) to [parse a given transaction](/docs/api-reference/enhanced-transactions/gettransactions):

```rust theme={"system"}
use helius::error::Result;
use helius::types::*;
use helius::Helius;

#[tokio::main]
async fn main() -> Result<()> {
    let api_key: &str = "your_api_key";
    let cluster: Cluster = Cluster::MainnetBeta;

    let helius: Helius = Helius::new(api_key, cluster).unwrap();

    let request: ParseTransactionsRequest = ParseTransactionsRequest {
        transactions: vec![
            "2sShYqqcWAcJiGc3oK74iFsYKgLCNiY2DsivMbaJGQT8pRzR8z5iBcdmTMXRobH8cZNZgeV9Ur9VjvLsykfFE2Li".to_string(),
        ],
    };

    let response: Result<Vec<EnhancedTransaction>, HeliusError> = helius.parse_transactions(request).await;
    println!("Assets: {:?}", response);

    Ok(())
}
```

## Documentation

<CardGroup cols={3}>
  <Card title="Rust Docs" icon="book" href="https://docs.rs/helius/latest/helius/">
    Latest docs on docs.rs
  </Card>

  <Card title="API Reference" icon="code" href="/docs/api-reference">
    Helius API documentation
  </Card>

  <Card title="Examples" icon="code-branch" href="https://github.com/helius-labs/helius-rust-sdk/tree/dev/examples">
    Code examples in the GitHub repo
  </Card>
</CardGroup>

## Error Handling

An error message will be thrown when the API returns a non-success (i.e., 4xx or 5xx status code).

For example, below is a 401 thrown for an incorrect getAsset call:

```json theme={"system"}
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32001,
    "message": "Authentication failed. Missing or invalid API key."
  },
  "id": "1"
}
```

### Common Error Codes

When working with the Helius SDK, you may encounter several error codes. Below is a table detailing some of the common error codes along with additional information to help you troubleshoot:

<AccordionGroup>
  <Accordion title="400: Bad Request">
    This occurs when a request has invalid parameters.
  </Accordion>

  <Accordion title="401: Unauthorized">
    This occurs when an invalid API key is provided or access is restricted due to RPC rules.
  </Accordion>

  <Accordion title="429: Too Many Requests">
    This indicates that the user has exceeded the request limit in a given timeframe or is out of credits.
  </Accordion>

  <Accordion title="5XX: Internal Server Error">
    This is a generic error message for server-side issues. Please contact Helius support for assistance.
  </Accordion>
</AccordionGroup>

If you encounter any of these errors:

<Steps>
  <Step title="Check error documentation">
    Refer to [`errors.rs`](https://github.com/helius-labs/helius-rust-sdk/blob/dev/src/error.rs) for a list of all possible errors returned by the `Helius` client
  </Step>

  <Step title="Review the documentation">
    Refer to the [Helius documentation](/docs/) for further guidance
  </Step>

  <Step title="Contact support">
    Reach out to the Helius support team for more detailed assistance
  </Step>
</Steps>

## Contributing

We welcome all contributions to our SDKs! Read the [contributions guide](https://github.com/helius-labs/helius-rust-sdk/blob/dev/CONTRIBUTIONS.md) before opening up a pull request.
