Crates.io | swquery |
lib.rs | swquery |
version | |
source | src |
created_at | 2024-12-24 04:02:12.773115+00 |
updated_at | 2025-03-11 02:11:53.95501+00 |
description | A natural language query for solana wallets |
homepage | |
repository | https://github.com/vict0rcarvalh0/swquery |
max_upload_size | |
id | 1493618 |
Cargo.toml error: | TOML parse error at line 23, column 1 | 23 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
SWQuery is an SDK designed to streamline interaction with Solana blockchain data using enhanced RPC calls. It leverages Helius RPC and integrates with a custom Agent API to provide powerful querying capabilities for developers building Solana-based applications.
The SWQuery SDK simplifies querying Solana blockchain data by offering high-level methods to interact with Solana's RPC API. It automates fetching and aggregating transaction data, token balances, and account states, making it ideal for developers building analytics, dashboards, and dApps on Solana.
To integrate the SWQuery SDK into your project:
cargo add swquery
Alternatively, add it manually to your Cargo.toml
:
[dependencies]
swquery = "0.0.2"
Then, run:
cargo build
To begin using the SDK, instantiate the SWqueryClient
with your API keys:
use swquery::SWqueryClient;
use std::time::Duration;
#[tokio::main]
async fn main() {
let client = SWqueryClient::new(
"YOUR_AGENT_API_KEY".to_string(),
"YOUR_HELIUS_API_KEY".to_string(),
Some(Duration::from_secs(10)),
None,
);
let response = client
.query("Get recent transactions for this wallet", "YourWalletAddress")
.await
.unwrap();
println!("Response: {:#?}", response);
}
new(api_key: String, helius_api_key: String, timeout: Option<Duration>, network: Option<Network>) -> Self
Instantiates a new SWqueryClient with optional timeout and network parameters.
query(input: &str, pubkey: &str) -> Result<Value, SdkError>
Sends a query to the Agent API and fetches data from Solana.
SWQuery SDK returns structured errors using the SdkError
enum, which includes:
InvalidInput(String)
– Raised when input parameters are missing or invalid.NetworkError(String)
– Triggered by network-related issues.ApiRequestFailed(String)
– Indicates a failure from the Agent or Helius RPC.ParseError(String)
– Raised when parsing responses fails.Example:
match client.get_recent_transactions("InvalidAddress", 7).await {
Ok(transactions) => println!("Fetched transactions: {:?}", transactions),
Err(e) => eprintln!("Error: {:?}", e),
}
This project is licensed under the MIT License.