Quickstart

Get up and running with the SWquery SDK in no time! This section will guide you through the basic setup and demonstrate how to perform your first wallet query.

Prerequisites

Before starting, ensure you have the following:

  • Rust Toolchain installed (Install Rust).

  • A Solana Wallet Address to query transactions.

  • Access to the SWquery SDK repository or package.

Step 1: Install the SDK

To add the SWquery SDK to your Rust project, include it as a dependency in your Cargo.toml file:

[dependencies]
swquery = "0.0.1" # Replace with the latest version

Step 2: Initialize the SDK

In your Rust project, import and initialize the SDK:

use swquery::SWqueryClient;

fn main() {
    // Initialize the SWquery client
    let client = SWqueryClient::new("your_api_key");
    println!("SWquery SDK is ready to use!");
}

Step 3: Perform Your First Query

The SWquery SDK uses natural language prompts to query on-chain data. Here's an example of querying transactions over 10 SOL:

use swquery::SWqueryClient;

fn main() {
    let client = SWqueryClient::new("your_api_key");

    // Define your natural language query
    let query = "Show all transactions over 10 SOL in the past week";

    // Execute the query
    match client.query_wallet("YourWalletAddressHere", query) {
        Ok(response) => println!("Query Result: {:?}", response),
        Err(e) => eprintln!("Error: {:?}", e),
    }
}

Replace "YourWalletAddressHere" with your actual Solana wallet address.

Step 4: Visualize the Results

The SDK provides structured JSON responses that can be easily integrated into front-end visualizations. Here's a sample output:

{
  "transactions": [
    {
      "date": "2024-12-10",
      "amount": "12.5 SOL",
      "type": "Sent",
      "recipient": "RecipientWalletAddress"
    },
    {
      "date": "2024-12-08",
      "amount": "15 SOL",
      "type": "Received",
      "sender": "SenderWalletAddress"
    }
  ]
}

Next Steps

Now that you've successfully set up and queried your first wallet:

  • Explore the Core Features to unlock advanced functionality.

  • Dive into Code Examples for real-world use cases.

  • Integrate the SDK into your projects and enhance your blockchain applications.

Last updated