Giter VIP home page Giter VIP logo

helius-rust-sdk's Introduction

Helius SDK

An asynchronous Helius Rust SDK for building the future of Solana

Documentation

The latest documentation can be found here on docs.rs

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

helius = "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.

Usage

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. The following code is an example of how to use the SDK to fetch info on Mad Lad #8420:

use helius::error::HeliusError;
use helius::types::{Cluster, DisplayOptions, GetAssetRequest, GetAssetResponseForAsset};

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

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

    let request: GetAssetRequest = GetAssetRequest {
        id: "F9Lw3ki3hJ7PF9HQXsBzoY8GyE6sPoEZZdXJBsTTD2rk".to_string(),
        display_options: Some(DisplayOptions {
            show_unverified_collections: false,
            show_collection_metadata: false,
            show_fungible: false,
            show_inscription: false,
        }),
    };

    let response: Result<Option<GetAssetResponseForAsset>, HeliusError> = helius.rpc().get_asset(request).await;

    match response {
        Ok(Some(asset)) => {
            println!("Asset: {:?}", asset);
        },
        Ok(None) => println!("No asset found."),
        Err(e) => println!("Error retrieving asset: {:?}", e),
    }

    Ok(())
}

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.

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.rs for a list of all possible errors returned by the Helius client
  • Refer to the Helius documentation for further guidance
  • Reach out to the Helius support team for more detailed assistance

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

Mint API

Enhanced Transactions API

Webhooks

Helper Methods

helius-rust-sdk's People

Contributors

0xichigo avatar anamansari062 avatar rhh4x0r avatar dougefresh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.