Crates.io | tonapi |
lib.rs | tonapi |
version | 0.3.0 |
source | src |
created_at | 2023-12-14 17:20:49.804283 |
updated_at | 2024-08-25 07:51:26.005459 |
description | SDK for integrating TonAPI into Rust apps |
homepage | |
repository | https://github.com/liketurbo/tonapi-rs |
max_upload_size | |
id | 1069761 |
size | 220,423 |
This is a SDK, that provides comprehensive support for interacting with the TonAPI.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = RestApiClientV2::new(Network::Mainnet, None);
let result = client.get_account(ACCOUNT_ID).await.unwrap();
println!("Account balance: {}", result.balance);
Ok(())
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let sse_api = SseApi::new(tonapi::Network::Mainnet, None);
let mut stream = sse_api.transactions_stream(
Some(vec![
"-1:5555555555555555555555555555555555555555555555555555555555555555".to_string(),
]),
None,
);
while let Ok(evt) = stream.next().await {
if let Some(evt) = evt {
println!("Event: {}", evt.tx_hash);
} else {
// Stream ended
break;
}
}
Ok(())
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let ws_api = WsApi::new(Network::Mainnet, None);
let mut stream = ws.transactions_stream(Some(vec![AccountOperations {
account: "-1:5555555555555555555555555555555555555555555555555555555555555555".to_string(),
operations: None
}]));
while let Ok(evt) = stream.next().await {
if let Some(evt) = evt {
println!("Event: {}", evt.params.tx_hash);
} else {
// Stream ended
break;
}
}
Ok(())
}
Contributions to this library is welcomed! If you'd like to contribute, please feel free to open a pull request on GitHub. Your input is highly appreciated and helps improve the SDK for the entire TON community.