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

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.

> [card] [GitHub Repository](https://github.com/helius-labs/helius-rust-sdk)
>
> Official Helius Rust SDK for Solana development

## Installation

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

**2. 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`.

**3. Keep your SDK updated**

Remember to run `cargo update` regularly to fetch the latest version of the SDK.

## Quick Start

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

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

> [card] [Rust Docs](https://docs.rs/helius/latest/helius/)
>
> Latest docs on docs.rs

> [card] [API Reference](https://www.helius.dev/docs/api-reference.md)
>
> Helius API documentation

> [card] [Examples](https://github.com/helius-labs/helius-rust-sdk/tree/dev/examples)
>
> Code examples in the GitHub repo

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

> [accordion] 400: Bad Request
>
> This occurs when a request has invalid parameters.

> [accordion] 401: Unauthorized
>
> This occurs when an invalid API key is provided or access is restricted due to RPC rules.

> [accordion] 429: Too Many Requests
>
> This indicates that the user has exceeded the request limit in a given timeframe or is out of credits.

> [accordion] 5XX: Internal Server Error
>
> This is a generic error message for server-side issues. Please contact Helius support for assistance.

If you encounter any of these errors:

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

**2. Review the documentation**

Refer to the [Helius documentation](https://www.helius.dev/docs/index.md) for further guidance

**3. Contact support**

Reach out to the Helius support team for more detailed assistance

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


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