Crates.io | helius-sdk |
lib.rs | helius-sdk |
version | 0.2.0 |
source | src |
created_at | 2023-05-02 23:24:03.979539 |
updated_at | 2023-12-11 01:42:41.152929 |
description | Rust implementation of the Helius SDK |
homepage | https://github.com/bgreni/helius-rust-sdk |
repository | https://github.com/bgreni/helius-rust-sdk |
max_upload_size | |
id | 855007 |
size | 172,046 |
For more in depth details about Helius features, please consult the official Typescript SDK
This README will largely present what functionality is available in this implementation
I'm not ready to commit to no breaking changes yet so will be making 0.x.x
releases for now
cargo add helius-sdk
use helius_sdk::*;
fn main() {
let client = Helius::new(env::var("API_KEY").unwrap(), Cluster::MainnetBeta);
}
Other
variant for EnumsMost enums in this crate have an Other(String)
options if new variants have been added to the helius API that have
not yet been included in this crate. When using these variants, do keep in mind there is a high chance that upgrading
to a new version will break your code if you have logic around receiving a response of this form. As they will then
have a proper distinct value in the enum for deserialization.
let hook = client.create_webhook(&CreateWebhookRequest {
data: WebhookData {
webhook_url: "insert url here".to_string(),
transaction_types: vec![TransactionType::NftBid, TransactionType::NftBidCancelled],
account_addresses: vec!["M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K".to_string()],
webhook_type: Some(WebhookType::Discord),
auth_header: None,
txn_status: None,
encoding: None
},
});
Retrieve all webhook for the current user account
let hooks = client.get_all_webhooks();
let hook = client.get_webhook_by_id("insert webhook id here"));
let mut hook = client.get_webhook_by_id(hook.webhook_id.as_str()).unwrap();
hook.webhook_data.webhook_type = WebhookType::Discord.into();
let ehook = client.edit_webhook(EditWebhookRequest{
webhook_id: hook.webhook_id,
data: hook.webhook_data,
});
client.delete_webhook("insert webhook id here");
A convenience method, not actually a part of the helius rest interface.
let res = client.create_collection_webhook(&CreateCollectionWebhookRequest {
data: WebhookData {
webhook_url: "insert url here".to_string(),
transaction_types: vec![TransactionType::NftSale],
account_addresses: vec![],
webhook_type: Some(WebhookType::Discord),
auth_header: None,
txn_status: None,
encoding: None
},
collection_query: CollectionIdentifier::FirstVerifiedCreators(vec!["GVkb5GuwGKydA4xXLT9PNpx63h7bhFNrDLQSxi6j5NuF".to_string()]),
});
let res = client.parse_transaction(
&ParseTransactionsRequest{
transactions: vec!["insert txn id here".to_string()]
}
);
let res = client.get_mintlist(MintlistRequest {
query: CollectionIdentifier::FirstVerifiedCreators(vec!["GVkb5GuwGKydA4xXLT9PNpx63h7bhFNrDLQSxi6j5NuF".into()]),
options: HeliusOptions {limit: 1000.into(), pagination_token: None}.into()
});
let res = client.get_token_metadata(&TokenMetadataRequest{
mint_accounts: vec!["insert token mint address"],
include_off_chain: true,
disable_cache: false
});
Helper methods for common RPC operations
client.rpc.get_tps();
let key = Pubkey::new_unique();
client.rpc.airdrop(&key, 10 * LAMPORTS_PER_SOL).expect();
Users can also access the underlying solana_sdk rpc client to make other standard rpc calls.
let conn = client.rpc.connection();
let inflation = conn.get_inflation_rate();