Helius SDK
An asynchronous Helius Rust SDK for building the future of Solana
Documentation
The latest documentation can be found here on docs.rs
Changelog
See CHANGELOG.md for the full release history.
Contributions
Interested in contributing to the Helius Rust SDK? Read the following contributions guide before opening up a pull request!
Installation
To start using the Helius Rust SDK in your project, add it as a dependency via cargo. Open your project's Cargo.toml and add the following line under [dependencies]:
= "x.y.z"
where x.y.z is your desired version. 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.
Remember to run cargo update regularly to fetch the latest version of the SDK.
TLS Options
The Helius Rust SDK uses the native TLS implementation by default via:
[]
= "x.y.z"
However, the SDK also supports rustls. Add the following to your Cargo.toml to use rustls instead of the native TLS implementation:
[]
= { = "x.y.z", = false, = ["rustls"] }
Using rustls may be preferred in environments where OpenSSL is not available or when a pure Rust TLS implementation is desired. However, it may not support all the same features as the native TLS implementation
Usage
Quick Start
The SDK provides a Helius instance that can be configured with an API key and a given Solana cluster. Developers can generate a new API key on the Helius Developer Dashboard. This instance acts as the main entry point for interacting with the SDK by providing methods to access different Solana and RPC client functionalities.
There are three simple constructors and a builder for advanced configuration:
| Constructor | Use Case |
|---|---|
Helius::new(api_key, cluster) |
Basic RPC operations with Helius endpoints |
Helius::new_async(api_key, cluster) |
Full-featured: async Solana client + WebSocket + confirmed commitment |
Helius::new_with_url(url) |
Custom RPC endpoint (no API key required) |
HeliusBuilder::new() |
Advanced configuration (custom timeouts, TLS, etc.) |
Helius::new() — Basic Client
The simplest way to get started. Creates a client for standard Helius RPC operations. This constructor is synchronous:
use Helius;
use Result;
use ;
async
Helius::new_async() — Full-Featured Client
The recommended constructor for production applications. Includes async Solana RPC, WebSocket streaming, and confirmed commitment level:
use Helius;
use Cluster;
async
Helius::new_with_url() — Custom RPC Endpoint
Use your own RPC node, a third-party provider, or localhost for development. No API key required. This constructor is synchronous:
use Helius;
HeliusBuilder — Advanced Configuration
For fine-grained control over the client configuration, use the builder pattern:
use HeliusBuilder;
use Cluster;
use CommitmentConfig;
use Duration;
async
HeliusFactory
The SDK also comes equipped with HeliusFactory, a factory for creating instances of Helius. This factory allows for a centralized configuration and creation of Helius clients so work can be done across multiple clusters at the same time. Using a factory simplifies client code and enhances maintainability by ensuring that all Helius clients are configured consistently. It has the following functionality:
- A
newmethod used to create a newHeliusFactorycapable of producingHeliusclients. Note this method does not create areqwestclient - A
with_clientmethod used to provide a givenHeliusFactorycreated with thenewmethod its ownreqwestclient - A
createmethod used to create multipleHeliusclients in a thread-safe manner
Embedded Solana Client
The Helius client has an embedded Solana client that can be accessed via helius.connection().request_name() where request_name() is a given RPC method. A full list of all Solana RPC HTTP methods can be found here.
For asynchronous operations, use Helius::new_async() or HeliusBuilder with .with_async_solana(). The async client can be accessed via helius.async_connection()?.some_async_method().await? where some_async_method() is a given async RPC method.
Enhanced WebSockets
Use Helius::new_async() or HeliusBuilder with .with_websocket(None, None) to create a client with WebSocket support. This enables our Enhanced WebSocket methods transactionSubscribe and accountSubscribe
Examples
More examples of how to use the SDK can be found in the examples directory.
Error Handling
Common Error Codes
You may encounter several error codes when working with the Helius Rust SDK. Below is a table detailing some of the common error codes along with additional information to aid with troubleshooting:
| Error Code | Error Message | More Information |
|---|---|---|
| 401 | Unauthorized | This occurs when an invalid API key is provided or access is restricted |
| 429 | Too Many Requests | This indicates that the user has exceeded the request limit in a given timeframe or is out of credits |
| 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:
- Refer to
errors.rsfor a list of all possible errors returned by theHeliusclient - Refer to the Helius documentation for further guidance
- Reach out to the Helius support team for more detailed assistance
Result Type Alias
The SDK also has a handy type alias for Result where Result<(some type), HeliusError> and be simplified to Result<(some type)>
Methods
Our SDK is designed to provide a seamless developer experience when building on Solana. We've separated the core functionality into various segments:
DAS API
get_asset- Gets an asset by its IDget_asset_batch- Gets multiple assets by their IDget_asset_proof- Gets a merkle proof for a compressed asset by its IDget_asset_proof_batch- Gets multiple asset proofs by their IDsget_assets_by_owner- Gets a list of assets owned by a given addressget_assets_by_authority- Gets a list of assets of a given authorityget_assets_by_creator- Gets a list of assets of a given creatorget_assets_by_group- Gets a list of assets by a group key and valuesearch_assets- Gets assets based on the custom search criteria passed inget_signatures_for_asset- Gets transaction signatures for a given assetget_token_accounts- Gets information about all token accounts for a specific mint or ownerget_nft_edition- Gets all the NFT editions associated with a specific master NFT
ZK Compression
get_compressed_account- Gets a compressed account by its address or hashget_compressed_account_proof- Gets a Merkle proof for a compressed accountget_compressed_accounts_by_owner- Gets all compressed accounts owned by a given addressget_compressed_balance- Gets the balance of a compressed accountget_compressed_balance_by_owner- Gets the total compressed SOL balance across all accounts owned by a given addressget_compressed_mint_token_holders- Lists all holders of a specific compressed token mintget_compressed_token_account_balance- Gets the token balance of a compressed token accountget_compressed_token_accounts_by_delegate- Gets all compressed token accounts delegated to a specific addressget_compressed_token_accounts_by_owner- Gets all compressed token accounts owned by a specific addressget_compressed_token_balances_by_owner- Gets all token balances for compressed accounts owned by an addressget_compressed_token_balances_by_owner_v2- Enhanced version ofget_compressed_token_balances_by_ownerwith additional iteration supportget_compression_signatures_for_account- Gets transaction signatures associated with a compressed accountget_compression_signatures_for_owner- Gets transaction signatures for all compressed accounts owned by an addressget_compression_signatures_for_token_owner- Gets transaction signatures for compressed token accounts owned by an addressget_indexer_health- Returns the health status of the compression indexerget_indexer_slot- Gets the latest slot processed by the compression indexerget_latest_compression_signatures- Gets the most recent compression transaction signatures across the networkget_latest_non_voting_signatures- Gets the most recent non-voting transaction signaturesget_multiple_compressed_account_proofs- Gets Merkle proofs for multiple compressed accounts in a single requestget_multiple_compressed_accounts- Gets multiple compressed accounts in a single requestget_multiple_new_address_proofs- Gets proofs for multiple new addressesget_multiple_new_address_proofs_v2- Enhanced version ofget_multiple_new_address_proofswith additional capabilitiesget_transaction_with_compression_info- Gets transaction details including compression-specific metadataget_validity_proof- Gets a validity proof for compressed data
Enhanced Transactions API
parse_transactions- Parses transactions given an array of transaction IDsparsed_transaction_history- Retrieves a parsed transaction history for a specific address
Webhooks
append_addresses_to_webhook- Appends a set of addresses to a given webhookcreate_webhook- Creates a webhook given account addressesdelete_webhook- Deletes a given Helius webhook programmaticallyedit_webhook- Edits a Helius webhook programmaticallyget_all_webhooks- Retrieves all Helius webhooks programmaticallyget_webhook_by_id- Gets a webhook config given a webhook IDremove_addresses_from_webhook- Removes a list of addresses from an existing webhook by its ID
Helius Sender
create_smart_transaction_with_tip_for_sender- Creates an optimized smart transaction with an appended tip transfer instruction for Senderdetermine_tip_lamports- Determines the tip amount in lamports using the 75th percentile floor or falling back to the minimum required by Senderfetch_tip_floor_75th- Fetches the 75th percentile landed tip floor from Jito's endpoint (in SOL)send_and_confirm_via_sender- Send a signed tx via Sender/fastand poll until confirmed (or until timeout/last valid blockhash expiry)send_smart_transaction_with_sender- Builds an optimized tx and sent via Senderwarm_sender_connection- Warms Sender connection by hitting/ping
Smart Transactions
create_smart_transaction- Creates an optimized transaction based on the provided configurationcreate_smart_transaction_with_seeds- Creates a thread-safe, optimized transaction using seed bytescreate_smart_transaction_without_signers- Creates an optimized transaction without requiring any signersget_compute_units- Simulates a transaction to get the total compute units consumedget_compute_units_thread_safe- A thread-safe version ofget_compute_unitspoll_transaction_confirmation- Polls a transaction to check whether it has been confirmed in 5 second intervals with a 15 second timeoutsend_smart_transaction- Builds and sends an optimized transaction, and handles its confirmation statussend_and_confirm_transaction- Sends a transaction and handles its confirmation status with retry logicsend_smart_transaction_with_seeds- Sends a smart transaction using seed bytes. This function is thread-safe
RPC Methods
get_priority_fee_estimate- Gets an estimate of the priority fees required for a transaction to be processed more quicklyget_transactions_for_address- Gets transaction history for a specific address with advanced filtering, sorting, and pagination. Optionally include transactions from associated token accounts
Helper Methods
deserialize_str_to_number- Deserializes aStringto aNumberis_valid_solana_address- Returns whether a given string slice is a valid Solana addressmake_keypairs- Generates a specified number of keypairs
Migrating from 0.x
If you're upgrading from 0.x, see the Migration Guide for details on breaking changes and how to update your code.