solagent

Crates.iosolagent
lib.rssolagent
version0.1.4
sourcesrc
created_at2025-01-03 07:26:28.200001
updated_at2025-01-08 20:13:52.074164
descriptionconnect any ai agents to solana protocols in Rust.
homepage
repositoryhttps://github.com/zTgx/solagent.rs.git
max_upload_size
id1502193
size235,985
(zTgx)

documentation

README

solagent.rs

crates.io docs.rs crates.io

An open-source toolkit for connecting AI agents to Solana protocols.

WIP

Solagent.rs is still in the early stage of development, and its interfaces may change in the future.
Contributions are welcome! Please feel free to submit a Pull Request.

📦 Installation

[dependencies]
solagent = "0.1.4"

Quick Start

use std::sync::Arc;
use solagent::create_solana_tools;

#[tokio::main]
async fn main() {
    let agent = Arc::new(SolAgent::new("private_key_bs58", "https://api.devnet.solana.com", "openai_api_key"));
    let toolset = create_solana_tools(agent);
}

Usage Examples

Deploy a New Token

    let name = "my ai token".to_string();
    let uri = "uri".to_string();
    let symbol = "SOLA".to_string();
    let decimals = 9;
    let initial_supply = 1_000_000_000_u64;

    let agent = Arc::new(SolAgent::new("private_key_bs58", "https://api.devnet.solana.com", "openai_api_key"));
    let mint_pubkey = agent
      .deploy_token(name, uri, symbol, decimals, Some(initial_supply)).await;
    println!("Token Mint Address: {:?}", mint_pubkey);

Create NFT Collection

    let options = CollectionOptions {
        name: "Solagent Collection".to_string(),
        uri: "https://arweave.net/metadata.json".to_string(),
        royalty_basis_points: Some(500),
        creators: Some(vec![Creator {
            address: wallet.address,
            verified: true,
            share: 100,
        }]),
    };

    let agent = Arc::new(SolAgent::new("private_key_bs58", "https://api.devnet.solana.com", "openai_api_key"));
    let _tx = agent.deploy_collection(options).await;

Mint NFT to Collection

    let name = "My First SolAgent NFT";
    let uri = "https://arweave.net/metadata.json";
    let royalty_basis_points = Some(500);
    let creators = vec![(
        Pubkey::from_str_const("
            8QB5VckaW3CWv4oZWiMLs1GkdrR5pVcjarAS1U6rG6Wh"),
        100,
    )];
    let metadata = NftMetadata::new(name, uri, royalty_basis_points, Some(creators));

    let collection = Pubkey::from_str_const("
        HHV3DX4UT4u3vBek2XCaZeAyox88zuhWfcLRJbFx1oYt");

    let agent = Arc::new(SolAgent::new("private_key_bs58", "https://api.devnet.solana.com", "openai_api_key"));
    let deployed_data = agent
        .mint_nft_to_collection(collection, metadata)
        .await
        .unwrap();
    println!("Mint: {}", deployed_data.mint);
}

Fetch Price Data from Pyth

    let agent = Arc::new(SolAgent::new("private_key_bs58", "https://api.devnet.solana.com", "openai_api_key"));
    let price_feed_id = agent.fetch_pyth_price_feed_id("SOL")
        .await
        .expect("fetch_pyth_price_feed_id");
    let price = agent.fetch_price_by_pyth(&price_feed_id)
        .await
        .expect("fetch_price_by_pyth");
    println!("Price of SOL/USD: {}", price)

More examples

More examples can be found in the examples.

SDKs

Name Language Framework GitHub
solana-agent-kit Typscript Langchain solana-agent-kit
agentipy Python Langchain, pydantic agentipy
solagent.rs Rust rig solagent.rs

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Star History

Star History Chart

License

MIT License

Security

This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.

Commit count: 70

cargo fmt