Crates.io | solagent |
lib.rs | solagent |
version | 0.1.4 |
source | src |
created_at | 2025-01-03 07:26:28.200001 |
updated_at | 2025-01-08 20:13:52.074164 |
description | connect any ai agents to solana protocols in Rust. |
homepage | |
repository | https://github.com/zTgx/solagent.rs.git |
max_upload_size | |
id | 1502193 |
size | 235,985 |
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.
[dependencies]
solagent = "0.1.4"
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);
}
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);
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;
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);
}
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 can be found in the examples.
Name | Language | Framework | GitHub |
---|---|---|---|
solana-agent-kit | Typscript | Langchain | solana-agent-kit |
agentipy | Python | Langchain, pydantic | agentipy |
solagent.rs | Rust | rig | solagent.rs |
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License
This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.